Commit 806b3c29 authored by Brian Tiger Chow's avatar Brian Tiger Chow

refac(bs:msg) msg.Wantlist() returns []u.Key

parent 96ab8343
......@@ -192,15 +192,14 @@ func (bs *BitSwap) handleMessages() {
// peerWantsBlock will check if we have the block in question,
// and then if we do, check the ledger for whether or not we should send it.
func (bs *BitSwap) peerWantsBlock(p *peer.Peer, want string) {
u.DOut("peer [%s] wants block [%s]\n", p.ID.Pretty(), u.Key(want).Pretty())
func (bs *BitSwap) peerWantsBlock(p *peer.Peer, wanted u.Key) {
u.DOut("peer [%s] wants block [%s]\n", p.ID.Pretty(), wanted.Pretty())
ledger := bs.getLedger(p)
dsk := ds.NewKey(want)
blk_i, err := bs.datastore.Get(dsk)
blk_i, err := bs.datastore.Get(wanted.DatastoreKey())
if err != nil {
if err == ds.ErrNotFound {
ledger.Wants(u.Key(want))
ledger.Wants(wanted)
}
u.PErr("datastore get error: %v\n", err)
return
......
......@@ -14,7 +14,7 @@ import (
)
type BitSwapMessage interface {
Wantlist() []string
Wantlist() []u.Key
Blocks() []blocks.Block
AppendWanted(k u.Key)
AppendBlock(b *blocks.Block)
......@@ -41,8 +41,12 @@ func New() *message {
}
// TODO(brian): convert these into keys
func (m *message) Wantlist() []string {
return m.pb.Wantlist
func (m *message) Wantlist() []u.Key {
wl := make([]u.Key, len(m.pb.Wantlist))
for _, str := range m.pb.Wantlist {
wl = append(wl, u.Key(str))
}
return wl
}
// TODO(brian): convert these into blocks
......
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