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
fd0e1ff6
Commit
fd0e1ff6
authored
Mar 24, 2020
by
Dirk McCormick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: log unexpected condition in peerWantManager.prepareSendWants()
parent
7348b26c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
23 deletions
+35
-23
internal/peermanager/peermanager.go
internal/peermanager/peermanager.go
+3
-0
internal/peermanager/peerwantmanager.go
internal/peermanager/peerwantmanager.go
+32
-23
No files found.
internal/peermanager/peermanager.go
View file @
fd0e1ff6
...
...
@@ -4,12 +4,15 @@ import (
"context"
"sync"
logging
"github.com/ipfs/go-log"
"github.com/ipfs/go-metrics-interface"
cid
"github.com/ipfs/go-cid"
peer
"github.com/libp2p/go-libp2p-core/peer"
)
var
log
=
logging
.
Logger
(
"bs:peermgr"
)
// PeerQueue provides a queue of messages to be sent for a single peer.
type
PeerQueue
interface
{
AddBroadcastWantHaves
([]
cid
.
Cid
)
...
...
internal/peermanager/peerwantmanager.go
View file @
fd0e1ff6
...
...
@@ -86,7 +86,17 @@ func (pwm *peerWantManager) prepareSendWants(p peer.ID, wantBlocks []cid.Cid, wa
resWantHvs
:=
make
([]
cid
.
Cid
,
0
)
// Get the existing want-blocks and want-haves for the peer
if
pws
,
ok
:=
pwm
.
peerWants
[
p
];
ok
{
pws
,
ok
:=
pwm
.
peerWants
[
p
]
if
!
ok
{
// In practice this should never happen:
// - PeerManager calls addPeer() as soon as the peer connects
// - PeerManager calls removePeer() as soon as the peer disconnects
// - All calls to PeerWantManager are locked
log
.
Errorf
(
"prepareSendWants() called with peer %s but peer not found in peerWantManager"
,
string
(
p
))
return
resWantBlks
,
resWantHvs
}
// Iterate over the requested want-blocks
for
_
,
c
:=
range
wantBlocks
{
// If the want-block hasn't been sent to the peer
...
...
@@ -116,7 +126,6 @@ func (pwm *peerWantManager) prepareSendWants(p peer.ID, wantBlocks []cid.Cid, wa
resWantHvs
=
append
(
resWantHvs
,
c
)
}
}
}
return
resWantBlks
,
resWantHvs
}
...
...
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