Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
p2p
go-p2p-kad-dht
Commits
f73b905e
Commit
f73b905e
authored
Oct 06, 2020
by
Adin Schmahmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: move ProtocolMessenger into new package
parent
52b4eb20
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
3 deletions
+7
-3
dht.go
dht.go
+3
-2
wire/messages.go
wire/messages.go
+4
-1
No files found.
dht.go
View file @
f73b905e
...
...
@@ -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
}
...
...
messages.go
→
wire/
messages.go
View file @
f73b905e
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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment