diff --git a/exchange/bitswap/decision/engine.go b/exchange/bitswap/decision/engine.go index f766f5ddf..cb1fc4add 100644 --- a/exchange/bitswap/decision/engine.go +++ b/exchange/bitswap/decision/engine.go @@ -187,13 +187,12 @@ func (e *Engine) MessageReceived(p peer.ID, m bsmsg.BitSwapMessage) error { } for _, block := range m.Blocks() { - // FIXME extract blocks.NumBytes(block) or block.NumBytes() method log.Debug("got block %s %d bytes", block.Key(), len(block.Data)) l.ReceivedBytes(len(block.Data)) for _, l := range e.ledgerMap { - if l.WantListContains(block.Key()) { + if entry, ok := l.WantListContains(block.Key()); ok { newWorkExists = true - e.peerRequestQueue.Push(wl.Entry{block.Key(), 1}, l.Partner) + e.peerRequestQueue.Push(entry, l.Partner) } } } diff --git a/exchange/bitswap/decision/ledger.go b/exchange/bitswap/decision/ledger.go index 273c3e706..8e1eb83ee 100644 --- a/exchange/bitswap/decision/ledger.go +++ b/exchange/bitswap/decision/ledger.go @@ -77,7 +77,7 @@ func (l *ledger) CancelWant(k u.Key) { l.wantList.Remove(k) } -func (l *ledger) WantListContains(k u.Key) bool { +func (l *ledger) WantListContains(k u.Key) (wl.Entry, bool) { return l.wantList.Contains(k) } diff --git a/exchange/bitswap/wantlist/wantlist.go b/exchange/bitswap/wantlist/wantlist.go index aa58ee155..14d729d99 100644 --- a/exchange/bitswap/wantlist/wantlist.go +++ b/exchange/bitswap/wantlist/wantlist.go @@ -55,7 +55,7 @@ func (w *ThreadSafe) Remove(k u.Key) { w.Wantlist.Remove(k) } -func (w *ThreadSafe) Contains(k u.Key) bool { +func (w *ThreadSafe) Contains(k u.Key) (Entry, bool) { // TODO rm defer for perf w.lk.RLock() defer w.lk.RUnlock() @@ -88,9 +88,9 @@ func (w *Wantlist) Remove(k u.Key) { delete(w.set, k) } -func (w *Wantlist) Contains(k u.Key) bool { - _, ok := w.set[k] - return ok +func (w *Wantlist) Contains(k u.Key) (Entry, bool) { + e, ok := w.set[k] + return e, ok } func (w *Wantlist) Entries() []Entry {