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 /block_pool.go | |
parent | a1b6a9ac29d0aa8d29a2c0535bafdb5fe4d4830b (diff) | |
download | dexon-f8d0cd9906a1ec4a4a1e95868a279312363f8b49.tar.gz dexon-f8d0cd9906a1ec4a4a1e95868a279312363f8b49.tar.zst dexon-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 'block_pool.go')
-rw-r--r-- | block_pool.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/block_pool.go b/block_pool.go index dcddca58e..38302a4c7 100644 --- a/block_pool.go +++ b/block_pool.go @@ -13,6 +13,7 @@ import ( "github.com/ethereum/go-ethereum/chain/types" "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/logger" + "github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/wire" ) @@ -310,10 +311,6 @@ out: } } - // TODO figure out whether we were catching up - // If caught up and just a new block has been propagated: - // sm.eth.EventMux().Post(NewBlockEvent{block}) - // otherwise process and don't emit anything if len(blocks) > 0 { chainManager := self.eth.ChainManager() // Test and import @@ -335,10 +332,13 @@ out: self.peer = nil } else { if !chain.IsTDError(err) { - chainManager.InsertChain(bchain) - for _, block := range blocks { + chainManager.InsertChain(bchain, func(block *types.Block, messages state.Messages) { + self.eth.EventMux().Post(chain.NewBlockEvent{block}) + self.eth.EventMux().Post(messages) + self.Remove(block.Hash()) - } + }) + } } } |