diff options
author | Nick Johnson <arachnid@notdot.net> | 2017-07-03 22:17:12 +0800 |
---|---|---|
committer | Nick Johnson <arachnid@notdot.net> | 2017-07-03 22:17:12 +0800 |
commit | be8f8409bc7f0f3124b7ebd1480337e4b1942113 (patch) | |
tree | 1eafc7234f2a312580ccedba1dd3a95e3ac7ac5d /eth/downloader/peer.go | |
parent | ae11545bc5fc0fcf4340d9f33d488eaf81d8bb2d (diff) | |
download | go-tangerine-be8f8409bc7f0f3124b7ebd1480337e4b1942113.tar go-tangerine-be8f8409bc7f0f3124b7ebd1480337e4b1942113.tar.gz go-tangerine-be8f8409bc7f0f3124b7ebd1480337e4b1942113.tar.bz2 go-tangerine-be8f8409bc7f0f3124b7ebd1480337e4b1942113.tar.lz go-tangerine-be8f8409bc7f0f3124b7ebd1480337e4b1942113.tar.xz go-tangerine-be8f8409bc7f0f3124b7ebd1480337e4b1942113.tar.zst go-tangerine-be8f8409bc7f0f3124b7ebd1480337e4b1942113.zip |
eth/downloader, les, light: Changes in response to review
Diffstat (limited to 'eth/downloader/peer.go')
-rw-r--r-- | eth/downloader/peer.go | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/eth/downloader/peer.go b/eth/downloader/peer.go index 71a692688..96870da50 100644 --- a/eth/downloader/peer.go +++ b/eth/downloader/peer.go @@ -75,19 +75,43 @@ type peerConnection struct { lock sync.RWMutex } -type Peer interface { +type LightPeer interface { Head() (common.Hash, *big.Int) RequestHeadersByHash(common.Hash, int, int, bool) error RequestHeadersByNumber(uint64, int, int, bool) error +} + +type Peer interface { + LightPeer RequestBodies([]common.Hash) error RequestReceipts([]common.Hash) error RequestNodeData([]common.Hash) error } -// newPeer create a new downloader peer, with specific hash and block retrieval -// mechanisms. -func newPeerConnection(id string, version int, peer Peer, logger log.Logger) *peerConnection { +// lightPeerWrapper wraps a LightPeer struct, stubbing out the Peer-only methods. +type lightPeerWrapper struct { + peer LightPeer +} +func (w *lightPeerWrapper) Head() (common.Hash, *big.Int) { return w.peer.Head() } +func (w *lightPeerWrapper) RequestHeadersByHash(h common.Hash, amount int, skip int, reverse bool) error { + return w.peer.RequestHeadersByHash(h, amount, skip, reverse) +} +func (w *lightPeerWrapper) RequestHeadersByNumber(i uint64, amount int, skip int, reverse bool) error { + return w.peer.RequestHeadersByNumber(i, amount, skip, reverse) +} +func (w *lightPeerWrapper) RequestBodies([]common.Hash) error { + panic("RequestBodies not supported in light client mode sync") +} +func (w *lightPeerWrapper) RequestReceipts([]common.Hash) error { + panic("RequestReceipts not supported in light client mode sync") +} +func (w *lightPeerWrapper) RequestNodeData([]common.Hash) error { + panic("RequestNodeData not supported in light client mode sync") +} + +// newPeerConnection creates a new downloader peer +func newPeerConnection(id string, version int, peer Peer, logger log.Logger) *peerConnection { return &peerConnection{ id: id, lacking: make(map[common.Hash]struct{}), |