diff options
author | Péter Szilágyi <peterke@gmail.com> | 2015-06-16 22:39:04 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2015-06-18 20:56:07 +0800 |
commit | 057bc237adf9ed0adf615a72cc1e92d9aed15d9e (patch) | |
tree | 20b852d95206d71a71ddb20489cd8f6068e4546b /eth/handler.go | |
parent | 8b64e041d6c41d76994510fdd8bb42ad7c5be5aa (diff) | |
download | go-tangerine-057bc237adf9ed0adf615a72cc1e92d9aed15d9e.tar go-tangerine-057bc237adf9ed0adf615a72cc1e92d9aed15d9e.tar.gz go-tangerine-057bc237adf9ed0adf615a72cc1e92d9aed15d9e.tar.bz2 go-tangerine-057bc237adf9ed0adf615a72cc1e92d9aed15d9e.tar.lz go-tangerine-057bc237adf9ed0adf615a72cc1e92d9aed15d9e.tar.xz go-tangerine-057bc237adf9ed0adf615a72cc1e92d9aed15d9e.tar.zst go-tangerine-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.go | 11 |
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 } |