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
dms3
go-bitswap
Commits
d310fe30
Commit
d310fe30
authored
Apr 03, 2020
by
Dirk McCormick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: ensure wantlist gauge gets decremented on disconnect
parent
d39c7604
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
0 deletions
+16
-0
internal/peermanager/peerwantmanager.go
internal/peermanager/peerwantmanager.go
+10
-0
internal/peermanager/peerwantmanager_test.go
internal/peermanager/peerwantmanager_test.go
+6
-0
No files found.
internal/peermanager/peerwantmanager.go
View file @
d310fe30
...
...
@@ -50,6 +50,16 @@ func (pwm *peerWantManager) addPeer(p peer.ID) {
// RemovePeer removes a peer and its associated wants from tracking
func
(
pwm
*
peerWantManager
)
removePeer
(
p
peer
.
ID
)
{
pws
,
ok
:=
pwm
.
peerWants
[
p
]
if
!
ok
{
return
}
// Decrement the gauge by the number of pending want-blocks to the peer
for
range
pws
.
wantBlocks
.
Keys
()
{
pwm
.
wantBlockGauge
.
Dec
()
}
delete
(
pwm
.
peerWants
,
p
)
}
...
...
internal/peermanager/peerwantmanager_test.go
View file @
d310fe30
...
...
@@ -289,4 +289,10 @@ func TestStats(t *testing.T) {
if
g
.
count
!=
3
{
t
.
Fatal
(
"Expected 3 want-blocks"
,
g
.
count
)
}
pwm
.
removePeer
(
p0
)
if
g
.
count
!=
0
{
t
.
Fatal
(
"Expected all want-blocks to be removed with peer"
,
g
.
count
)
}
}
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