aboutsummaryrefslogtreecommitdiffstats
path: root/core/chain_manager.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-04-29 20:00:24 +0800
committerobscuren <geffobscura@gmail.com>2015-04-29 20:00:24 +0800
commit735b029db95bf72c3105674c0f2b4f111e5ccdf5 (patch)
treed656426d54dbbdd2a187bf22e93ddc0ad9aaeece /core/chain_manager.go
parent764e81bf12bc45b00cec7db216e72d6396cf0c13 (diff)
downloaddexon-735b029db95bf72c3105674c0f2b4f111e5ccdf5.tar.gz
dexon-735b029db95bf72c3105674c0f2b4f111e5ccdf5.tar.zst
dexon-735b029db95bf72c3105674c0f2b4f111e5ccdf5.zip
core: return the index of the block that failed when inserting a chain
Diffstat (limited to 'core/chain_manager.go')
-rw-r--r--core/chain_manager.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/core/chain_manager.go b/core/chain_manager.go
index 32ad4a2ba..253228bfd 100644
--- a/core/chain_manager.go
+++ b/core/chain_manager.go
@@ -497,7 +497,9 @@ func (self *ChainManager) procFutureBlocks() {
self.InsertChain(blocks)
}
-func (self *ChainManager) InsertChain(chain types.Blocks) error {
+// InsertChain will attempt to insert the given chain in to the canonical chain or, otherwise, create a fork. It an error is returned
+// it will return the index number of the failing block as well an error describing what went wrong (for possible errors see core/errors.go).
+func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) {
// A queued approach to delivering events. This is generally faster than direct delivery and requires much less mutex acquiring.
var (
queue = make([]interface{}, len(chain))
@@ -540,7 +542,7 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
glog.V(logger.Error).Infoln(err)
glog.V(logger.Debug).Infoln(block)
- return err
+ return i, err
}
block.Td = new(big.Int).Set(CalculateTD(block, self.GetBlock(block.ParentHash())))
@@ -613,7 +615,7 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
go self.eventMux.Post(queueEvent)
- return nil
+ return 0, nil
}
// diff takes two blocks, an old chain and a new chain and will reconstruct the blocks and inserts them