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
f292dceb
Commit
f292dceb
authored
Nov 14, 2016
by
Justin Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DRY up NewDHT
parent
e1437ab8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
16 deletions
+2
-16
dht.go
dht.go
+2
-16
No files found.
dht.go
View file @
f292dceb
...
...
@@ -71,25 +71,11 @@ type IpfsDHT struct {
// NewDHT creates a new DHT object with the given peer as the 'local' host
func
NewDHT
(
ctx
context
.
Context
,
h
host
.
Host
,
dstore
ds
.
Batching
)
*
IpfsDHT
{
dht
:=
makeDHT
(
ctx
,
h
,
dstore
)
// register for network notifs.
dht
.
host
.
Network
()
.
Notify
((
*
netNotifiee
)(
dht
))
dht
.
proc
=
goprocessctx
.
WithContextAndTeardown
(
ctx
,
func
()
error
{
// remove ourselves from network notifs.
dht
.
host
.
Network
()
.
StopNotify
((
*
netNotifiee
)(
dht
))
return
nil
})
dht
.
proc
.
AddChild
(
dht
.
providers
.
Process
())
dht
:=
NewDHTClient
(
ctx
,
h
,
dstore
)
h
.
SetStreamHandler
(
ProtocolDHT
,
dht
.
handleNewStream
)
h
.
SetStreamHandler
(
ProtocolDHTOld
,
dht
.
handleNewStream
)
dht
.
Validator
[
"pk"
]
=
record
.
PublicKeyValidator
dht
.
Selector
[
"pk"
]
=
record
.
PublicKeySelector
return
dht
}
...
...
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