aboutsummaryrefslogtreecommitdiffstats
path: root/eth
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 /eth
parent764e81bf12bc45b00cec7db216e72d6396cf0c13 (diff)
downloadgo-tangerine-735b029db95bf72c3105674c0f2b4f111e5ccdf5.tar
go-tangerine-735b029db95bf72c3105674c0f2b4f111e5ccdf5.tar.gz
go-tangerine-735b029db95bf72c3105674c0f2b4f111e5ccdf5.tar.bz2
go-tangerine-735b029db95bf72c3105674c0f2b4f111e5ccdf5.tar.lz
go-tangerine-735b029db95bf72c3105674c0f2b4f111e5ccdf5.tar.xz
go-tangerine-735b029db95bf72c3105674c0f2b4f111e5ccdf5.tar.zst
go-tangerine-735b029db95bf72c3105674c0f2b4f111e5ccdf5.zip
core: return the index of the block that failed when inserting a chain
Diffstat (limited to 'eth')
-rw-r--r--eth/downloader/downloader.go9
-rw-r--r--eth/handler.go2
2 files changed, 5 insertions, 6 deletions
diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go
index a3917854f..a7e83a532 100644
--- a/eth/downloader/downloader.go
+++ b/eth/downloader/downloader.go
@@ -37,7 +37,7 @@ var (
)
type hashCheckFn func(common.Hash) bool
-type chainInsertFn func(types.Blocks) error
+type chainInsertFn func(types.Blocks) (int, error)
type hashIterFn func() (common.Hash, error)
type blockPack struct {
@@ -432,12 +432,11 @@ func (d *Downloader) process(peer *peer) error {
// TODO check for parent error. When there's a parent error we should stop
// processing and start requesting the `block.hash` so that it's parent and
// grandparents can be requested and queued.
- err = d.insertChain(blocks[:max])
+ var i int
+ i, err = d.insertChain(blocks[:max])
if err != nil && core.IsParentErr(err) {
- glog.V(logger.Debug).Infoln("Aborting process due to missing parent.")
+ glog.V(logger.Debug).Infof("Aborting process due to missing parent (%d)\n", i)
- // XXX this needs a lot of attention
- blocks = nil
break
} else if err != nil {
// immediatly unregister the false peer but do not disconnect
diff --git a/eth/handler.go b/eth/handler.go
index 61149049e..2dd4c74db 100644
--- a/eth/handler.go
+++ b/eth/handler.go
@@ -376,7 +376,7 @@ func (self *ProtocolManager) handleMsg(p *peer) error {
// if the parent exists we process the block and propagate to our peers
// if the parent does not exists we delegate to the downloader.
if self.chainman.HasBlock(request.Block.ParentHash()) {
- if err := self.chainman.InsertChain(types.Blocks{request.Block}); err != nil {
+ if _, err := self.chainman.InsertChain(types.Blocks{request.Block}); err != nil {
// handle error
return nil
}