aboutsummaryrefslogtreecommitdiffstats
path: root/eth/downloader/peer.go
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2015-07-01 23:16:44 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2015-07-01 23:16:44 +0800
commit5caff3bc247cdd71f2342093d276041afe898ab3 (patch)
treea771298f17987eba6fb05d7bac1e772121296856 /eth/downloader/peer.go
parent507869bff10adab3d4f183aeaf3ef31715041046 (diff)
parentd6f2c0a76f6635ebeb245815c5f686c545ed527d (diff)
downloadgo-tangerine-5caff3bc247cdd71f2342093d276041afe898ab3.tar
go-tangerine-5caff3bc247cdd71f2342093d276041afe898ab3.tar.gz
go-tangerine-5caff3bc247cdd71f2342093d276041afe898ab3.tar.bz2
go-tangerine-5caff3bc247cdd71f2342093d276041afe898ab3.tar.lz
go-tangerine-5caff3bc247cdd71f2342093d276041afe898ab3.tar.xz
go-tangerine-5caff3bc247cdd71f2342093d276041afe898ab3.tar.zst
go-tangerine-5caff3bc247cdd71f2342093d276041afe898ab3.zip
Merge pull request #1351 from karalabe/eth61
Implement eth/61
Diffstat (limited to 'eth/downloader/peer.go')
-rw-r--r--eth/downloader/peer.go26
1 files changed, 16 insertions, 10 deletions
diff --git a/eth/downloader/peer.go b/eth/downloader/peer.go
index f36e133e4..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,20 +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, 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(),
+ id: id,
+ head: head,
+ capacity: 1,
+ getRelHashes: getRelHashes,
+ getAbsHashes: getAbsHashes,
+ getBlocks: getBlocks,
+ ignored: set.New(),
+ version: version,
}
}