aboutsummaryrefslogtreecommitdiffstats
path: root/core/blockchain.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-04-06 19:58:03 +0800
committerPéter Szilágyi <peterke@gmail.com>2017-04-06 22:34:19 +0800
commit158d603528d2ba36b633a8f22a2bff8329f69717 (patch)
tree7e95ceca2b57686e766182b6e6d14fe10704dcf8 /core/blockchain.go
parent702bef8493f0f3486072f1a7593fa582a1fb53d0 (diff)
downloaddexon-158d603528d2ba36b633a8f22a2bff8329f69717.tar
dexon-158d603528d2ba36b633a8f22a2bff8329f69717.tar.gz
dexon-158d603528d2ba36b633a8f22a2bff8329f69717.tar.bz2
dexon-158d603528d2ba36b633a8f22a2bff8329f69717.tar.lz
dexon-158d603528d2ba36b633a8f22a2bff8329f69717.tar.xz
dexon-158d603528d2ba36b633a8f22a2bff8329f69717.tar.zst
dexon-158d603528d2ba36b633a8f22a2bff8329f69717.zip
consensus, core: drop all the legacy custom core error types
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