From eafdc1f8e371fd698da33491a01799393249729a Mon Sep 17 00:00:00 2001 From: Péter Szilágyi Date: Tue, 26 May 2015 14:00:21 +0300 Subject: eth, eth/downloader: surface downloaded block origin, drop on error --- eth/downloader/downloader.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'eth/downloader/downloader.go') diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go index fd588d2f3..0634baaed 100644 --- a/eth/downloader/downloader.go +++ b/eth/downloader/downloader.go @@ -93,6 +93,12 @@ type Downloader struct { cancelLock sync.RWMutex // Lock to protect the cancel channel in delivers } +// Block is an origin-tagged blockchain block. +type Block struct { + RawBlock *types.Block + OriginPeer string +} + func New(mux *event.TypeMux, hasBlock hashCheckFn, getBlock getBlockFn) *Downloader { downloader := &Downloader{ mux: mux, @@ -177,7 +183,7 @@ func (d *Downloader) Synchronise(id string, hash common.Hash) error { } // TakeBlocks takes blocks from the queue and yields them to the caller. -func (d *Downloader) TakeBlocks() types.Blocks { +func (d *Downloader) TakeBlocks() []*Block { return d.queue.TakeBlocks() } -- cgit