From b468baf7ac0d5ca086b79a4156792819e796bd1d Mon Sep 17 00:00:00 2001 From: Jae Kwon Date: Fri, 11 Sep 2015 19:00:27 -0700 Subject: [PATCH] IsCaughtUp works with new networks --- blockchain/pool.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/blockchain/pool.go b/blockchain/pool.go index b03c236b..688cc9e6 100644 --- a/blockchain/pool.go +++ b/blockchain/pool.go @@ -32,6 +32,7 @@ const ( type BlockPool struct { QuitService + startTime time.Time // block requests mtx sync.Mutex @@ -65,6 +66,7 @@ func NewBlockPool(start int, requestsCh chan<- BlockRequest, timeoutsCh chan<- s func (pool *BlockPool) OnStart() error { pool.QuitService.OnStart() go pool.makeRequestsRoutine() + pool.startTime = time.Now() return nil } @@ -136,7 +138,7 @@ func (pool *BlockPool) IsCaughtUp() bool { } pool.peersMtx.Unlock() - return numPeers >= 3 && height > 0 && height == maxPeerHeight + return numPeers >= 3 && (height > 0 || time.Now().Sub(pool.startTime) > 30*time.Second) && (maxPeerHeight == 0 || height == maxPeerHeight) } // We need to see the second block's Validation to validate the first block.