aboutsummaryrefslogtreecommitdiffstats
path: root/core/chain_manager.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-06-05 20:07:49 +0800
committerobscuren <geffobscura@gmail.com>2015-06-05 23:33:30 +0800
commit7ab87f9f6e3c3032d2d171c402286d7e92e3b98c (patch)
treea9faeec6e51e3f20828bc35ab0cf8d599d9e6934 /core/chain_manager.go
parentb94a76d17e4cd92569157fe9dbde6748b2f93e6c (diff)
downloadgo-tangerine-7ab87f9f6e3c3032d2d171c402286d7e92e3b98c.tar
go-tangerine-7ab87f9f6e3c3032d2d171c402286d7e92e3b98c.tar.gz
go-tangerine-7ab87f9f6e3c3032d2d171c402286d7e92e3b98c.tar.bz2
go-tangerine-7ab87f9f6e3c3032d2d171c402286d7e92e3b98c.tar.lz
go-tangerine-7ab87f9f6e3c3032d2d171c402286d7e92e3b98c.tar.xz
go-tangerine-7ab87f9f6e3c3032d2d171c402286d7e92e3b98c.tar.zst
go-tangerine-7ab87f9f6e3c3032d2d171c402286d7e92e3b98c.zip
wip
Diffstat (limited to 'core/chain_manager.go')
-rw-r--r--core/chain_manager.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/core/chain_manager.go b/core/chain_manager.go
index d14a19fea..86d1c1454 100644
--- a/core/chain_manager.go
+++ b/core/chain_manager.go
@@ -30,8 +30,9 @@ var (
)
const (
- blockCacheLimit = 10000
- maxFutureBlocks = 256
+ blockCacheLimit = 10000
+ maxFutureBlocks = 256
+ maxTimeFutureBlocks = 30
)
func CalcDifficulty(block, parent *types.Header) *big.Int {
@@ -579,6 +580,13 @@ func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) {
}
if err == BlockFutureErr {
+ // Allow up to MaxFuture second in the future blocks. If this limit
+ // is exceeded the chain is discarded and processed at a later time
+ // if given.
+ if max := time.Now().Unix() + maxTimeFutureBlocks; block.Time() > max {
+ return i, fmt.Errorf("%v: BlockFutureErr, %v > %v", BlockFutureErr, block.Time(), max)
+ }
+
block.SetQueued(true)
self.futureBlocks.Push(block)
stats.queued++