Commit 9ac61865 authored by Brian Tiger Chow's avatar Brian Tiger Chow Committed by Juan Batiz-Benet

style(bitswap) rename Adapter -> BitSwapNetwork for clarity

parent 014813e8
...@@ -57,7 +57,7 @@ func NetMessageSession(ctx context.Context, p peer.Peer, ...@@ -57,7 +57,7 @@ func NetMessageSession(ctx context.Context, p peer.Peer,
type bitswap struct { type bitswap struct {
// sender delivers messages on behalf of the session // sender delivers messages on behalf of the session
sender bsnet.Adapter sender bsnet.BitSwapNetwork
// blockstore is the local database // blockstore is the local database
// NB: ensure threadsafety // NB: ensure threadsafety
......
...@@ -8,8 +8,8 @@ import ( ...@@ -8,8 +8,8 @@ import (
u "github.com/jbenet/go-ipfs/util" u "github.com/jbenet/go-ipfs/util"
) )
// Adapter provides network connectivity for BitSwap sessions // BitSwapNetwork provides network connectivity for BitSwap sessions
type Adapter interface { type BitSwapNetwork interface {
// DialPeer ensures there is a connection to peer. // DialPeer ensures there is a connection to peer.
DialPeer(context.Context, peer.Peer) error DialPeer(context.Context, peer.Peer) error
...@@ -31,6 +31,7 @@ type Adapter interface { ...@@ -31,6 +31,7 @@ type Adapter interface {
SetDelegate(Receiver) SetDelegate(Receiver)
} }
// Implement Receiver to receive messages from the BitSwapNetwork
type Receiver interface { type Receiver interface {
ReceiveMessage( ReceiveMessage(
ctx context.Context, sender peer.Peer, incoming bsmsg.BitSwapMessage) ( ctx context.Context, sender peer.Peer, incoming bsmsg.BitSwapMessage) (
...@@ -39,7 +40,6 @@ type Receiver interface { ...@@ -39,7 +40,6 @@ type Receiver interface {
ReceiveError(error) ReceiveError(error)
} }
// TODO rename -> Router?
type Routing interface { type Routing interface {
// FindProvidersAsync returns a channel of providers for the given key // FindProvidersAsync returns a channel of providers for the given key
FindProvidersAsync(context.Context, u.Key, int) <-chan peer.Peer FindProvidersAsync(context.Context, u.Key, int) <-chan peer.Peer
......
...@@ -15,7 +15,7 @@ import ( ...@@ -15,7 +15,7 @@ import (
var log = util.Logger("net_message_adapter") var log = util.Logger("net_message_adapter")
// NetMessageAdapter wraps a NetMessage network service // NetMessageAdapter wraps a NetMessage network service
func NetMessageAdapter(s inet.Service, n inet.Network, r Receiver) Adapter { func NetMessageAdapter(s inet.Service, n inet.Network, r Receiver) BitSwapNetwork {
adapter := impl{ adapter := impl{
nms: s, nms: s,
net: n, net: n,
......
...@@ -13,7 +13,7 @@ import ( ...@@ -13,7 +13,7 @@ import (
) )
type Network interface { type Network interface {
Adapter(peer.Peer) bsnet.Adapter Adapter(peer.Peer) bsnet.BitSwapNetwork
HasPeer(peer.Peer) bool HasPeer(peer.Peer) bool
...@@ -43,7 +43,7 @@ type network struct { ...@@ -43,7 +43,7 @@ type network struct {
clients map[util.Key]bsnet.Receiver clients map[util.Key]bsnet.Receiver
} }
func (n *network) Adapter(p peer.Peer) bsnet.Adapter { func (n *network) Adapter(p peer.Peer) bsnet.BitSwapNetwork {
client := &networkClient{ client := &networkClient{
local: p, local: p,
network: n, network: n,
......
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