提交 3663eef5 作者: Brian Tiger Chow 提交者: Juan Batiz-Benet

refctor(bitswap/network) replace Network interface with Dialer interface

上级 0b42d77e
...@@ -15,11 +15,11 @@ import ( ...@@ -15,11 +15,11 @@ import (
var log = util.Logger("bitswap_network") var log = util.Logger("bitswap_network")
// NewFromIpfsNetwork returns a BitSwapNetwork supported by underlying IPFS // NewFromIpfsNetwork returns a BitSwapNetwork supported by underlying IPFS
// Network & Service // Dialer & Service
func NewFromIpfsNetwork(s inet.Service, n inet.Network) BitSwapNetwork { func NewFromIpfsNetwork(s inet.Service, dialer inet.Dialer) BitSwapNetwork {
bitswapNetwork := impl{ bitswapNetwork := impl{
service: s, service: s,
net: n, dialer: dialer,
} }
s.SetHandler(&bitswapNetwork) s.SetHandler(&bitswapNetwork)
return &bitswapNetwork return &bitswapNetwork
...@@ -29,7 +29,7 @@ func NewFromIpfsNetwork(s inet.Service, n inet.Network) BitSwapNetwork { ...@@ -29,7 +29,7 @@ func NewFromIpfsNetwork(s inet.Service, n inet.Network) BitSwapNetwork {
// NetMessage objects, into the bitswap network interface. // NetMessage objects, into the bitswap network interface.
type impl struct { type impl struct {
service inet.Service service inet.Service
net inet.Network dialer inet.Dialer
// inbound messages from the network are forwarded to the receiver // inbound messages from the network are forwarded to the receiver
receiver Receiver receiver Receiver
...@@ -68,8 +68,8 @@ func (bsnet *impl) HandleMessage( ...@@ -68,8 +68,8 @@ func (bsnet *impl) HandleMessage(
return outgoing return outgoing
} }
func (adapter *impl) DialPeer(ctx context.Context, p peer.Peer) error { func (bsnet *impl) DialPeer(ctx context.Context, p peer.Peer) error {
return adapter.net.DialPeer(ctx, p) return bsnet.dialer.DialPeer(ctx, p)
} }
func (bsnet *impl) SendMessage( func (bsnet *impl) SendMessage(
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论