diff options
author | obscuren <geffobscura@gmail.com> | 2014-11-19 02:44:17 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-11-19 02:44:17 +0800 |
commit | f8d0cd9906a1ec4a4a1e95868a279312363f8b49 (patch) | |
tree | 04bb1876142343c69a3542d0dbebe7cbefd68105 /miner | |
parent | a1b6a9ac29d0aa8d29a2c0535bafdb5fe4d4830b (diff) | |
download | go-tangerine-f8d0cd9906a1ec4a4a1e95868a279312363f8b49.tar.gz go-tangerine-f8d0cd9906a1ec4a4a1e95868a279312363f8b49.tar.zst go-tangerine-f8d0cd9906a1ec4a4a1e95868a279312363f8b49.zip |
Added a callback mechanism to chain adding.
Not sure if this is the right approach. Why? BlockChain shouldn't need
the "Ethereum" object. BlockChain shouldn't need to worry about
notifying listeners or message propagation.
Diffstat (limited to 'miner')
-rw-r--r-- | miner/miner.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/miner/miner.go b/miner/miner.go index b25e25357..795385424 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -29,6 +29,7 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/ethutil" + "github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/chain" "github.com/ethereum/go-ethereum/chain/types" @@ -218,8 +219,10 @@ func (self *Miner) mine() { if err != nil { minerlogger.Infoln(err) } else { - chainMan.InsertChain(lchain) - //self.eth.EventMux().Post(chain.NewBlockEvent{block}) + chainMan.InsertChain(lchain, func(block *types.Block, _ state.Messages) { + self.eth.EventMux().Post(chain.NewBlockEvent{block}) + }) + self.eth.Broadcast(wire.MsgBlockTy, []interface{}{block.Value().Val}) minerlogger.Infof("🔨 Mined block %x\n", block.Hash()) |