aboutsummaryrefslogtreecommitdiffstats
path: root/core/blockchain.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-04-07 16:03:11 +0800
committerGitHub <noreply@github.com>2017-04-07 16:03:11 +0800
commitcc13d576f07fb6803e09fb42880591a67b8b0ef6 (patch)
tree6b2371c34416e3697443d836aab3a1f7fc32e77a /core/blockchain.go
parent71fdaa42386173da7bfa13f1728c394aeeb4eb01 (diff)
parent158d603528d2ba36b633a8f22a2bff8329f69717 (diff)
downloaddexon-cc13d576f07fb6803e09fb42880591a67b8b0ef6.tar
dexon-cc13d576f07fb6803e09fb42880591a67b8b0ef6.tar.gz
dexon-cc13d576f07fb6803e09fb42880591a67b8b0ef6.tar.bz2
dexon-cc13d576f07fb6803e09fb42880591a67b8b0ef6.tar.lz
dexon-cc13d576f07fb6803e09fb42880591a67b8b0ef6.tar.xz
dexon-cc13d576f07fb6803e09fb42880591a67b8b0ef6.tar.zst
dexon-cc13d576f07fb6803e09fb42880591a67b8b0ef6.zip
Merge pull request #13870 from karalabe/miners-fixes
all: clean up various error handling in core and the miner
Diffstat (limited to 'core/blockchain.go')
-rw-r--r--core/blockchain.go17
1 files changed, 8 insertions, 9 deletions
diff --git a/core/blockchain.go b/core/blockchain.go
index 4793431d8..b601c462c 100644
--- a/core/blockchain.go
+++ b/core/blockchain.go
@@ -831,7 +831,7 @@ func (self *BlockChain) WriteBlock(block *types.Block) (status WriteStatus, err
// Calculate the total difficulty of the block
ptd := self.GetTd(block.ParentHash(), block.NumberU64()-1)
if ptd == nil {
- return NonStatTy, ParentError(block.ParentHash())
+ return NonStatTy, consensus.ErrUnknownAncestor
}
// Make sure no inconsistent state is leaked during insertion
self.mu.Lock()
@@ -918,9 +918,8 @@ func (self *BlockChain) InsertChain(chain types.Blocks) (int, error) {
}
// If the header is a banned one, straight out abort
if BadHashes[block.Hash()] {
- err := BadHashError(block.Hash())
- self.reportBlock(block, nil, err)
- return i, err
+ self.reportBlock(block, nil, ErrBlacklistedHash)
+ return i, ErrBlacklistedHash
}
// Wait for the block's verification to complete
bstart := time.Now()
@@ -930,25 +929,25 @@ func (self *BlockChain) InsertChain(chain types.Blocks) (int, error) {
err = self.Validator().ValidateBody(block)
}
if err != nil {
- if IsKnownBlockErr(err) {
+ if err == ErrKnownBlock {
stats.ignored++
continue
}
- if err == BlockFutureErr {
+ if err == consensus.ErrFutureBlock {
// 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.
max := big.NewInt(time.Now().Unix() + maxTimeFutureBlocks)
- if block.Time().Cmp(max) == 1 {
- return i, fmt.Errorf("%v: BlockFutureErr, %v > %v", BlockFutureErr, block.Time(), max)
+ if block.Time().Cmp(max) > 0 {
+ return i, fmt.Errorf("future block: %v > %v", block.Time(), max)
}
self.futureBlocks.Add(block.Hash(), block)
stats.queued++
continue
}
- if IsParentErr(err) && self.futureBlocks.Contains(block.ParentHash()) {
+ if err == consensus.ErrUnknownAncestor && self.futureBlocks.Contains(block.ParentHash()) {
self.futureBlocks.Add(block.Hash(), block)
stats.queued++
continue