aboutsummaryrefslogtreecommitdiffstats
path: root/eth/downloader/peer.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-07-01 00:05:06 +0800
committerPéter Szilágyi <peterke@gmail.com>2015-07-01 00:05:06 +0800
commitf43c07cb3ca0d96fd005aa7ce2ddd40876a06d11 (patch)
tree89b208ae35b35c6157711443a449f92fa33b1afd /eth/downloader/peer.go
parentaf51dc4d637dbbb0d416032304f84d52d4f6d951 (diff)
downloadgo-tangerine-f43c07cb3ca0d96fd005aa7ce2ddd40876a06d11.tar
go-tangerine-f43c07cb3ca0d96fd005aa7ce2ddd40876a06d11.tar.gz
go-tangerine-f43c07cb3ca0d96fd005aa7ce2ddd40876a06d11.tar.bz2
go-tangerine-f43c07cb3ca0d96fd005aa7ce2ddd40876a06d11.tar.lz
go-tangerine-f43c07cb3ca0d96fd005aa7ce2ddd40876a06d11.tar.xz
go-tangerine-f43c07cb3ca0d96fd005aa7ce2ddd40876a06d11.tar.zst
go-tangerine-f43c07cb3ca0d96fd005aa7ce2ddd40876a06d11.zip
eth, eth/downloader: transition to eth 61
Diffstat (limited to 'eth/downloader/peer.go')
-rw-r--r--eth/downloader/peer.go25
1 files changed, 14 insertions, 11 deletions
diff --git a/eth/downloader/peer.go b/eth/downloader/peer.go
index 7176cc06b..bd58b4dc8 100644
--- a/eth/downloader/peer.go
+++ b/eth/downloader/peer.go
@@ -15,7 +15,8 @@ import (
"gopkg.in/fatih/set.v0"
)
-type hashFetcherFn func(common.Hash) error
+type relativeHashFetcherFn func(common.Hash) error
+type absoluteHashFetcherFn func(uint64, int) error
type blockFetcherFn func([]common.Hash) error
var (
@@ -37,23 +38,25 @@ type peer struct {
ignored *set.Set // Set of hashes not to request (didn't have previously)
- getHashes hashFetcherFn // Method to retrieve a batch of hashes (mockable for testing)
- getBlocks blockFetcherFn // Method to retrieve a batch of blocks (mockable for testing)
+ getRelHashes relativeHashFetcherFn // Method to retrieve a batch of hashes from an origin hash
+ getAbsHashes absoluteHashFetcherFn // Method to retrieve a batch of hashes from an absolute position
+ getBlocks blockFetcherFn // Method to retrieve a batch of blocks
version int // Eth protocol version number to switch strategies
}
// newPeer create a new downloader peer, with specific hash and block retrieval
// mechanisms.
-func newPeer(id string, version int, head common.Hash, getHashes hashFetcherFn, getBlocks blockFetcherFn) *peer {
+func newPeer(id string, version int, head common.Hash, getRelHashes relativeHashFetcherFn, getAbsHashes absoluteHashFetcherFn, getBlocks blockFetcherFn) *peer {
return &peer{
- id: id,
- head: head,
- capacity: 1,
- getHashes: getHashes,
- getBlocks: getBlocks,
- ignored: set.New(),
- version: version,
+ id: id,
+ head: head,
+ capacity: 1,
+ getRelHashes: getRelHashes,
+ getAbsHashes: getAbsHashes,
+ getBlocks: getBlocks,
+ ignored: set.New(),
+ version: version,
}
}