diff options
author | Felix Lange <fjl@twurst.com> | 2016-07-21 17:36:38 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2016-07-22 19:17:19 +0800 |
commit | 016007bd25f2b5e597c2ac2f7256c4e73574f70e (patch) | |
tree | cf32a5d2edb8f8683ada17fa6bf71f878af50999 /eth/downloader/peer.go | |
parent | a4c4125b1155d9276614029163b498a17643f0f2 (diff) | |
download | go-tangerine-016007bd25f2b5e597c2ac2f7256c4e73574f70e.tar go-tangerine-016007bd25f2b5e597c2ac2f7256c4e73574f70e.tar.gz go-tangerine-016007bd25f2b5e597c2ac2f7256c4e73574f70e.tar.bz2 go-tangerine-016007bd25f2b5e597c2ac2f7256c4e73574f70e.tar.lz go-tangerine-016007bd25f2b5e597c2ac2f7256c4e73574f70e.tar.xz go-tangerine-016007bd25f2b5e597c2ac2f7256c4e73574f70e.tar.zst go-tangerine-016007bd25f2b5e597c2ac2f7256c4e73574f70e.zip |
eth, eth/downloader, eth/fetcher: delete eth/61 code
The eth/61 protocol was disabled in #2776, this commit removes its
message handlers and hash-chain sync logic.
Diffstat (limited to 'eth/downloader/peer.go')
-rw-r--r-- | eth/downloader/peer.go | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/eth/downloader/peer.go b/eth/downloader/peer.go index 94d44fca4..c2b7a52d0 100644 --- a/eth/downloader/peer.go +++ b/eth/downloader/peer.go @@ -37,11 +37,6 @@ const ( measurementImpact = 0.1 // The impact a single measurement has on a peer's final throughput value. ) -// Hash and block fetchers belonging to eth/61 and below -type relativeHashFetcherFn func(common.Hash) error -type absoluteHashFetcherFn func(uint64, int) error -type blockFetcherFn func([]common.Hash) error - // Block header and body fetchers belonging to eth/62 and above type relativeHeaderFetcherFn func(common.Hash, int, int, bool) error type absoluteHeaderFetcherFn func(uint64, int, int, bool) error @@ -79,10 +74,6 @@ type peer struct { lacking map[common.Hash]struct{} // Set of hashes not to request (didn't have previously) - getRelHashes relativeHashFetcherFn // [eth/61] Method to retrieve a batch of hashes from an origin hash - getAbsHashes absoluteHashFetcherFn // [eth/61] Method to retrieve a batch of hashes from an absolute position - getBlocks blockFetcherFn // [eth/61] Method to retrieve a batch of blocks - getRelHeaders relativeHeaderFetcherFn // [eth/62] Method to retrieve a batch of headers from an origin hash getAbsHeaders absoluteHeaderFetcherFn // [eth/62] Method to retrieve a batch of headers from an absolute position getBlockBodies blockBodyFetcherFn // [eth/62] Method to retrieve a batch of block bodies @@ -97,7 +88,6 @@ type peer struct { // newPeer create a new downloader peer, with specific hash and block retrieval // mechanisms. func newPeer(id string, version int, head common.Hash, - getRelHashes relativeHashFetcherFn, getAbsHashes absoluteHashFetcherFn, getBlocks blockFetcherFn, // eth/61 callbacks, remove when upgrading getRelHeaders relativeHeaderFetcherFn, getAbsHeaders absoluteHeaderFetcherFn, getBlockBodies blockBodyFetcherFn, getReceipts receiptFetcherFn, getNodeData stateFetcherFn) *peer { return &peer{ @@ -105,10 +95,6 @@ func newPeer(id string, version int, head common.Hash, head: head, lacking: make(map[common.Hash]struct{}), - getRelHashes: getRelHashes, - getAbsHashes: getAbsHashes, - getBlocks: getBlocks, - getRelHeaders: getRelHeaders, getAbsHeaders: getAbsHeaders, getBlockBodies: getBlockBodies, @@ -138,28 +124,6 @@ func (p *peer) Reset() { p.lacking = make(map[common.Hash]struct{}) } -// Fetch61 sends a block retrieval request to the remote peer. -func (p *peer) Fetch61(request *fetchRequest) error { - // Sanity check the protocol version - if p.version != 61 { - panic(fmt.Sprintf("block fetch [eth/61] requested on eth/%d", p.version)) - } - // Short circuit if the peer is already fetching - if !atomic.CompareAndSwapInt32(&p.blockIdle, 0, 1) { - return errAlreadyFetching - } - p.blockStarted = time.Now() - - // Convert the hash set to a retrievable slice - hashes := make([]common.Hash, 0, len(request.Hashes)) - for hash, _ := range request.Hashes { - hashes = append(hashes, hash) - } - go p.getBlocks(hashes) - - return nil -} - // FetchHeaders sends a header retrieval request to the remote peer. func (p *peer) FetchHeaders(from uint64, count int) error { // Sanity check the protocol version @@ -481,20 +445,6 @@ func (ps *peerSet) AllPeers() []*peer { return list } -// BlockIdlePeers retrieves a flat list of all the currently idle peers within the -// active peer set, ordered by their reputation. -func (ps *peerSet) BlockIdlePeers() ([]*peer, int) { - idle := func(p *peer) bool { - return atomic.LoadInt32(&p.blockIdle) == 0 - } - throughput := func(p *peer) float64 { - p.lock.RLock() - defer p.lock.RUnlock() - return p.blockThroughput - } - return ps.idlePeers(61, 61, idle, throughput) -} - // HeaderIdlePeers retrieves a flat list of all the currently header-idle peers // within the active peer set, ordered by their reputation. func (ps *peerSet) HeaderIdlePeers() ([]*peer, int) { |