aboutsummaryrefslogtreecommitdiffstats
path: root/block_pool.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-09-25 22:57:49 +0800
committerobscuren <geffobscura@gmail.com>2014-09-25 22:57:49 +0800
commit9ed8dc7384deb932be624699d9f628d3d00ba31e (patch)
treec20bab9c5c2b9b13be5f261cb72847ffa97654a2 /block_pool.go
parent2458697dad8ceac5fe93182e141c7f2eb7428417 (diff)
downloadgo-tangerine-9ed8dc7384deb932be624699d9f628d3d00ba31e.tar.gz
go-tangerine-9ed8dc7384deb932be624699d9f628d3d00ba31e.tar.zst
go-tangerine-9ed8dc7384deb932be624699d9f628d3d00ba31e.zip
Attempt to catch up from unknown block
Diffstat (limited to 'block_pool.go')
-rw-r--r--block_pool.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/block_pool.go b/block_pool.go
index 88d1c3739..f768f0f60 100644
--- a/block_pool.go
+++ b/block_pool.go
@@ -73,6 +73,10 @@ func (self *BlockPool) SetBlock(b *ethchain.Block, peer *Peer) {
if self.pool[hash] == nil && !self.eth.BlockChain().HasBlock(b.Hash()) {
self.hashPool = append(self.hashPool, b.Hash())
self.pool[hash] = &block{peer, peer, b, time.Now(), 0}
+
+ if !self.eth.BlockChain().HasBlock(b.PrevHash) && self.pool[string(b.PrevHash)] == nil {
+ peer.QueueMessage(ethwire.NewMessage(ethwire.MsgGetBlockHashesTy, []interface{}{b.PrevHash, uint32(256)}))
+ }
} else if self.pool[hash] != nil {
self.pool[hash].block = b
}
@@ -218,6 +222,7 @@ out:
case <-procTimer.C:
// XXX We can optimize this lifting this on to a new goroutine.
// We'd need to make sure that the pools are properly protected by a mutex
+ // XXX This should moved in The Great Refactor(TM)
amount := self.ProcessCanonical(func(block *ethchain.Block) {
err := self.eth.StateManager().Process(block, false)
if err != nil {