Commit f73b905e authored by Adin Schmahmann's avatar Adin Schmahmann

refactor: move ProtocolMessenger into new package

parent 52b4eb20
......@@ -20,6 +20,7 @@ import (
pb "github.com/libp2p/go-libp2p-kad-dht/pb"
"github.com/libp2p/go-libp2p-kad-dht/providers"
"github.com/libp2p/go-libp2p-kad-dht/rtrefresh"
"github.com/libp2p/go-libp2p-kad-dht/wire"
kb "github.com/libp2p/go-libp2p-kbucket"
"github.com/libp2p/go-libp2p-kbucket/peerdiversity"
record "github.com/libp2p/go-libp2p-record"
......@@ -95,7 +96,7 @@ type IpfsDHT struct {
ctx context.Context
proc goprocess.Process
protoMessenger *ProtocolMessenger
protoMessenger *wire.ProtocolMessenger
messageMgr *messageManager
plk sync.Mutex
......@@ -193,7 +194,7 @@ func New(ctx context.Context, h host.Host, options ...Option) (*IpfsDHT, error)
strmap: make(map[peer.ID]*messageSender),
protocols: dht.protocols,
}
dht.protoMessenger, err = NewProtocolMessenger(dht.messageMgr, WithValidator(dht.Validator))
dht.protoMessenger, err = wire.NewProtocolMessenger(dht.messageMgr, wire.WithValidator(dht.Validator))
if err != nil {
return nil, err
}
......
package dht
package wire
import (
"bytes"
......@@ -10,6 +10,7 @@ import (
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/routing"
logging "github.com/ipfs/go-log"
record "github.com/libp2p/go-libp2p-record"
recpb "github.com/libp2p/go-libp2p-record/pb"
"github.com/multiformats/go-multihash"
......@@ -18,6 +19,8 @@ import (
pb "github.com/libp2p/go-libp2p-kad-dht/pb"
)
var logger = logging.Logger("dht")
// ProtocolMessenger can be used for sending DHT messages to peers and processing their responses.
// This decouples the wire protocol format from both the DHT protocol implementation and from the implementation of the
// routing.Routing interface.
......
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