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
82c23336
Commit
82c23336
authored
Apr 09, 2020
by
Aarsh Shah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug in periodic peer pinging
parent
0d1a917f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
5 deletions
+5
-5
dht.go
dht.go
+4
-4
dht_bootstrap.go
dht_bootstrap.go
+1
-1
No files found.
dht.go
View file @
82c23336
...
...
@@ -108,10 +108,9 @@ type IpfsDHT struct {
// networks).
enableProviders
,
enableValues
bool
// maxLastSuccessfulOutboundThreshold is the max threshold/upper limit for the value of "lastSuccessfulOutboundQuery"
// of the peer in the bucket above which we will evict it to make place for a new peer if the bucket
// is full
maxLastSuccessfulOutboundThreshold
time
.
Duration
// maxLastSuccessfulOutboundThreshold is the max threshold/upper limit on the time duration
// between the current time and the last time a peer was useful to us.
maxLastSuccessfulOutboundThreshold
float64
fixLowPeersChan
chan
struct
{}
}
...
...
@@ -294,6 +293,7 @@ func makeRoutingTable(dht *IpfsDHT, cfg config) (*kb.RoutingTable, error) {
self
:=
kb
.
ConvertPeerID
(
dht
.
host
.
ID
())
rt
,
err
:=
kb
.
NewRoutingTable
(
cfg
.
bucketSize
,
self
,
time
.
Minute
,
dht
.
host
.
Peerstore
(),
maxLastSuccessfulOutboundThreshold
)
dht
.
maxLastSuccessfulOutboundThreshold
=
maxLastSuccessfulOutboundThreshold
cmgr
:=
dht
.
host
.
ConnManager
()
rt
.
PeerAdded
=
func
(
p
peer
.
ID
)
{
...
...
dht_bootstrap.go
View file @
82c23336
...
...
@@ -128,7 +128,7 @@ func (dht *IpfsDHT) startRefreshing() {
// ping Routing Table peers that haven't been hear of/from in the interval they should have been.
for
_
,
ps
:=
range
dht
.
routingTable
.
GetPeerInfos
()
{
// ping the peer if it's due for a ping and evict it if the ping fails
if
time
.
Since
(
ps
.
LastSuccessfulOutboundQuery
)
>
dht
.
maxLastSuccessfulOutboundThreshold
{
if
float64
(
time
.
Since
(
ps
.
LastSuccessfulOutboundQuery
)
)
>
dht
.
maxLastSuccessfulOutboundThreshold
{
livelinessCtx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
peerPingTimeout
)
if
err
:=
dht
.
host
.
Connect
(
livelinessCtx
,
peer
.
AddrInfo
{
ID
:
ps
.
Id
});
err
!=
nil
{
logger
.
Debugw
(
"evicting peer after failed ping"
,
"peer"
,
ps
.
Id
,
"error"
,
err
)
...
...
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