Commit 90fede8d authored by Jeromy's avatar Jeromy

let wantlist command show other peers wantlists

parent 70f2b6b0
...@@ -175,6 +175,14 @@ func (bs *Bitswap) GetBlock(parent context.Context, k u.Key) (*blocks.Block, err ...@@ -175,6 +175,14 @@ func (bs *Bitswap) GetBlock(parent context.Context, k u.Key) (*blocks.Block, err
} }
} }
func (bs *Bitswap) WantlistForPeer(p peer.ID) []u.Key {
var out []u.Key
for _, e := range bs.engine.WantlistForPeer(p) {
out = append(out, e.Key)
}
return out
}
// GetBlocks returns a channel where the caller may receive blocks that // GetBlocks returns a channel where the caller may receive blocks that
// correspond to the provided |keys|. Returns an error if BitSwap is unable to // correspond to the provided |keys|. Returns an error if BitSwap is unable to
// begin this request within the deadline enforced by the context. // begin this request within the deadline enforced by the context.
......
...@@ -96,6 +96,16 @@ func NewEngine(ctx context.Context, bs bstore.Blockstore) *Engine { ...@@ -96,6 +96,16 @@ func NewEngine(ctx context.Context, bs bstore.Blockstore) *Engine {
return e return e
} }
func (e *Engine) WantlistForPeer(p peer.ID) (out []wl.Entry) {
e.lock.Lock()
partner, ok := e.ledgerMap[p]
if ok {
out = partner.wantList.SortedEntries()
}
e.lock.Unlock()
return out
}
func (e *Engine) taskWorker(ctx context.Context) { func (e *Engine) taskWorker(ctx context.Context) {
defer close(e.outbox) // because taskWorker uses the channel exclusively defer close(e.outbox) // because taskWorker uses the channel exclusively
for { for {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment