aboutsummaryrefslogtreecommitdiffstats
path: root/eth/handler.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-06-16 22:39:04 +0800
committerPéter Szilágyi <peterke@gmail.com>2015-06-18 20:56:07 +0800
commit057bc237adf9ed0adf615a72cc1e92d9aed15d9e (patch)
tree20b852d95206d71a71ddb20489cd8f6068e4546b /eth/handler.go
parent8b64e041d6c41d76994510fdd8bb42ad7c5be5aa (diff)
downloaddexon-057bc237adf9ed0adf615a72cc1e92d9aed15d9e.tar
dexon-057bc237adf9ed0adf615a72cc1e92d9aed15d9e.tar.gz
dexon-057bc237adf9ed0adf615a72cc1e92d9aed15d9e.tar.bz2
dexon-057bc237adf9ed0adf615a72cc1e92d9aed15d9e.tar.lz
dexon-057bc237adf9ed0adf615a72cc1e92d9aed15d9e.tar.xz
dexon-057bc237adf9ed0adf615a72cc1e92d9aed15d9e.tar.zst
dexon-057bc237adf9ed0adf615a72cc1e92d9aed15d9e.zip
eth, eth/fetcher: use an import queue to store out of order blocks
Diffstat (limited to 'eth/handler.go')
-rw-r--r--eth/handler.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/eth/handler.go b/eth/handler.go
index 99ac4ce68..e5908dc88 100644
--- a/eth/handler.go
+++ b/eth/handler.go
@@ -1,6 +1,7 @@
package eth
import (
+ "errors"
"fmt"
"math"
"math/big"
@@ -94,9 +95,15 @@ func NewProtocolManager(protocolVersion, networkId int, mux *event.TypeMux, txpo
manager.downloader = downloader.New(manager.eventMux, manager.chainman.HasBlock, manager.chainman.GetBlock, manager.chainman.InsertChain, manager.removePeer)
importer := func(peer string, block *types.Block) error {
- return manager.importBlock(manager.peers.Peer(peer), block, nil)
+ if p := manager.peers.Peer(peer); p != nil {
+ return manager.importBlock(manager.peers.Peer(peer), block, nil)
+ }
+ return errors.New("unknown peer")
+ }
+ heighter := func() uint64 {
+ return manager.chainman.CurrentBlock().NumberU64()
}
- manager.fetcher = fetcher.New(manager.chainman.HasBlock, importer)
+ manager.fetcher = fetcher.New(manager.chainman.HasBlock, importer, heighter)
return manager
}