Skip to content

Commit

Permalink
refactor: move ProtocolMessenger into new package
Browse files Browse the repository at this point in the history
  • Loading branch information
aschmahmann committed Oct 7, 2020
1 parent 6a512b4 commit 773aa01
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 3 additions & 2 deletions dht.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -95,7 +96,7 @@ type IpfsDHT struct {
ctx context.Context
proc goprocess.Process

protoMessenger *ProtocolMessenger
protoMessenger *wire.ProtocolMessenger
messageMgr *messageManager

plk sync.Mutex
Expand Down Expand Up @@ -191,7 +192,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
}
Expand Down
6 changes: 5 additions & 1 deletion messages.go → wire/messages.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dht
package wire

import (
"bytes"
Expand All @@ -12,12 +12,16 @@ import (

"github.com/libp2p/go-libp2p-core/peer"

logging "github.com/ipfs/go-log"

recpb "github.com/libp2p/go-libp2p-record/pb"

"github.com/libp2p/go-libp2p-kad-dht/internal"
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.
Expand Down

0 comments on commit 773aa01

Please sign in to comment.