Commit 60f3a874 authored by Brian Tiger Chow's avatar Brian Tiger Chow Committed by Juan Batiz-Benet

feat(bitswap/network) expose peerstore

parent a225568f
......@@ -26,6 +26,8 @@ type BitSwapNetwork interface {
peer.ID,
bsmsg.BitSwapMessage) (incoming bsmsg.BitSwapMessage, err error)
Peerstore() peer.Peerstore
// SetDelegate registers the Reciver to handle messages received from the
// network.
SetDelegate(Receiver)
......
......@@ -70,6 +70,10 @@ func (bsnet *impl) SetDelegate(r Receiver) {
bsnet.receiver = r
}
func (bsnet *impl) Peerstore() peer.Peerstore {
return bsnet.Peerstore()
}
// handleNewStream receives a new stream from the network.
func (bsnet *impl) handleNewStream(s inet.Stream) {
......
......@@ -47,8 +47,9 @@ type network struct {
func (n *network) Adapter(p peer.ID) bsnet.BitSwapNetwork {
client := &networkClient{
local: p,
network: n,
local: p,
network: n,
peerstore: peer.NewPeerstore(),
}
n.clients[p] = client
return client
......@@ -148,7 +149,8 @@ func (n *network) SendRequest(
type networkClient struct {
local peer.ID
bsnet.Receiver
network Network
network Network
peerstore peer.Peerstore
}
func (nc *networkClient) SendMessage(
......@@ -176,3 +178,7 @@ func (nc *networkClient) DialPeer(ctx context.Context, p peer.ID) error {
func (nc *networkClient) SetDelegate(r bsnet.Receiver) {
nc.Receiver = r
}
func (nc *networkClient) Peerstore() peer.Peerstore {
return nc.peerstore
}
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