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
7348b26c
Unverified
Commit
7348b26c
authored
Mar 24, 2020
by
Steven Allen
Committed by
GitHub
Mar 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: make pwm internals private (#315)
This makes it easier to tell where module boundaries are.
parent
78886796
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
54 deletions
+54
-54
internal/peermanager/peermanager.go
internal/peermanager/peermanager.go
+10
-10
internal/peermanager/peerwantmanager.go
internal/peermanager/peerwantmanager.go
+8
-8
internal/peermanager/peerwantmanager_test.go
internal/peermanager/peerwantmanager_test.go
+35
-35
internal/wantmanager/wantmanager.go
internal/wantmanager/wantmanager.go
+1
-1
No files found.
internal/peermanager/peermanager.go
View file @
7348b26c
...
...
@@ -94,11 +94,11 @@ func (pm *PeerManager) Connected(p peer.ID, initialWantHaves []cid.Cid) {
// If this is the first connection to the peer
if
pq
.
refcnt
==
1
{
// Inform the peer want manager that there's a new peer
pm
.
pwm
.
A
ddPeer
(
p
)
pm
.
pwm
.
a
ddPeer
(
p
)
// Record that the want-haves are being sent to the peer
pm
.
pwm
.
P
repareSendWants
(
p
,
nil
,
initialWantHaves
)
_
,
wantHaves
:=
pm
.
pwm
.
p
repareSendWants
(
p
,
nil
,
initialWantHaves
)
// Broadcast any live want-haves to the newly connected peers
pq
.
pq
.
AddBroadcastWantHaves
(
initialW
antHaves
)
pq
.
pq
.
AddBroadcastWantHaves
(
w
antHaves
)
// Inform the sessions that the peer has connected
pm
.
signalAvailability
(
p
,
true
)
}
...
...
@@ -126,7 +126,7 @@ func (pm *PeerManager) Disconnected(p peer.ID) {
// Clean up the peer
delete
(
pm
.
peerQueues
,
p
)
pq
.
pq
.
Shutdown
()
pm
.
pwm
.
R
emovePeer
(
p
)
pm
.
pwm
.
r
emovePeer
(
p
)
}
// BroadcastWantHaves broadcasts want-haves to all peers (used by the session
...
...
@@ -137,7 +137,7 @@ func (pm *PeerManager) BroadcastWantHaves(ctx context.Context, wantHaves []cid.C
pm
.
pqLk
.
Lock
()
defer
pm
.
pqLk
.
Unlock
()
for
p
,
ks
:=
range
pm
.
pwm
.
P
repareBroadcastWantHaves
(
wantHaves
)
{
for
p
,
ks
:=
range
pm
.
pwm
.
p
repareBroadcastWantHaves
(
wantHaves
)
{
if
pqi
,
ok
:=
pm
.
peerQueues
[
p
];
ok
{
pqi
.
pq
.
AddBroadcastWantHaves
(
ks
)
}
...
...
@@ -151,7 +151,7 @@ func (pm *PeerManager) SendWants(ctx context.Context, p peer.ID, wantBlocks []ci
defer
pm
.
pqLk
.
Unlock
()
if
pqi
,
ok
:=
pm
.
peerQueues
[
p
];
ok
{
wblks
,
whvs
:=
pm
.
pwm
.
P
repareSendWants
(
p
,
wantBlocks
,
wantHaves
)
wblks
,
whvs
:=
pm
.
pwm
.
p
repareSendWants
(
p
,
wantBlocks
,
wantHaves
)
pqi
.
pq
.
AddWants
(
wblks
,
whvs
)
}
}
...
...
@@ -163,7 +163,7 @@ func (pm *PeerManager) SendCancels(ctx context.Context, cancelKs []cid.Cid) {
defer
pm
.
pqLk
.
Unlock
()
// Send a CANCEL to each peer that has been sent a want-block or want-have
for
p
,
ks
:=
range
pm
.
pwm
.
P
repareSendCancels
(
cancelKs
)
{
for
p
,
ks
:=
range
pm
.
pwm
.
p
repareSendCancels
(
cancelKs
)
{
if
pqi
,
ok
:=
pm
.
peerQueues
[
p
];
ok
{
pqi
.
pq
.
AddCancels
(
ks
)
}
...
...
@@ -175,7 +175,7 @@ func (pm *PeerManager) CurrentWants() []cid.Cid {
pm
.
pqLk
.
RLock
()
defer
pm
.
pqLk
.
RUnlock
()
return
pm
.
pwm
.
G
etWants
()
return
pm
.
pwm
.
g
etWants
()
}
// CurrentWantBlocks returns the list of pending want-blocks
...
...
@@ -183,7 +183,7 @@ func (pm *PeerManager) CurrentWantBlocks() []cid.Cid {
pm
.
pqLk
.
RLock
()
defer
pm
.
pqLk
.
RUnlock
()
return
pm
.
pwm
.
G
etWantBlocks
()
return
pm
.
pwm
.
g
etWantBlocks
()
}
// CurrentWantHaves returns the list of pending want-haves
...
...
@@ -191,7 +191,7 @@ func (pm *PeerManager) CurrentWantHaves() []cid.Cid {
pm
.
pqLk
.
RLock
()
defer
pm
.
pqLk
.
RUnlock
()
return
pm
.
pwm
.
G
etWantHaves
()
return
pm
.
pwm
.
g
etWantHaves
()
}
func
(
pm
*
PeerManager
)
getOrCreate
(
p
peer
.
ID
)
*
peerQueueInstance
{
...
...
internal/peermanager/peerwantmanager.go
View file @
7348b26c
...
...
@@ -39,7 +39,7 @@ func newPeerWantManager(wantBlockGauge Gauge) *peerWantManager {
}
// AddPeer adds a peer whose wants we need to keep track of
func
(
pwm
*
peerWantManager
)
A
ddPeer
(
p
peer
.
ID
)
{
func
(
pwm
*
peerWantManager
)
a
ddPeer
(
p
peer
.
ID
)
{
if
_
,
ok
:=
pwm
.
peerWants
[
p
];
!
ok
{
pwm
.
peerWants
[
p
]
=
&
peerWant
{
wantBlocks
:
cid
.
NewSet
(),
...
...
@@ -49,13 +49,13 @@ func (pwm *peerWantManager) AddPeer(p peer.ID) {
}
// RemovePeer removes a peer and its associated wants from tracking
func
(
pwm
*
peerWantManager
)
R
emovePeer
(
p
peer
.
ID
)
{
func
(
pwm
*
peerWantManager
)
r
emovePeer
(
p
peer
.
ID
)
{
delete
(
pwm
.
peerWants
,
p
)
}
// PrepareBroadcastWantHaves filters the list of want-haves for each peer,
// returning a map of peers to the want-haves they have not yet been sent.
func
(
pwm
*
peerWantManager
)
P
repareBroadcastWantHaves
(
wantHaves
[]
cid
.
Cid
)
map
[
peer
.
ID
][]
cid
.
Cid
{
func
(
pwm
*
peerWantManager
)
p
repareBroadcastWantHaves
(
wantHaves
[]
cid
.
Cid
)
map
[
peer
.
ID
][]
cid
.
Cid
{
res
:=
make
(
map
[
peer
.
ID
][]
cid
.
Cid
)
// Iterate over all known peers
...
...
@@ -81,7 +81,7 @@ func (pwm *peerWantManager) PrepareBroadcastWantHaves(wantHaves []cid.Cid) map[p
// PrepareSendWants filters the list of want-blocks and want-haves such that
// it only contains wants that have not already been sent to the peer.
func
(
pwm
*
peerWantManager
)
P
repareSendWants
(
p
peer
.
ID
,
wantBlocks
[]
cid
.
Cid
,
wantHaves
[]
cid
.
Cid
)
([]
cid
.
Cid
,
[]
cid
.
Cid
)
{
func
(
pwm
*
peerWantManager
)
p
repareSendWants
(
p
peer
.
ID
,
wantBlocks
[]
cid
.
Cid
,
wantHaves
[]
cid
.
Cid
)
([]
cid
.
Cid
,
[]
cid
.
Cid
)
{
resWantBlks
:=
make
([]
cid
.
Cid
,
0
)
resWantHvs
:=
make
([]
cid
.
Cid
,
0
)
...
...
@@ -124,7 +124,7 @@ func (pwm *peerWantManager) PrepareSendWants(p peer.ID, wantBlocks []cid.Cid, wa
// PrepareSendCancels filters the list of cancels for each peer,
// returning a map of peers which only contains cancels for wants that have
// been sent to the peer.
func
(
pwm
*
peerWantManager
)
P
repareSendCancels
(
cancelKs
[]
cid
.
Cid
)
map
[
peer
.
ID
][]
cid
.
Cid
{
func
(
pwm
*
peerWantManager
)
p
repareSendCancels
(
cancelKs
[]
cid
.
Cid
)
map
[
peer
.
ID
][]
cid
.
Cid
{
res
:=
make
(
map
[
peer
.
ID
][]
cid
.
Cid
)
// Iterate over all known peers
...
...
@@ -158,7 +158,7 @@ func (pwm *peerWantManager) PrepareSendCancels(cancelKs []cid.Cid) map[peer.ID][
}
// GetWantBlocks returns the set of all want-blocks sent to all peers
func
(
pwm
*
peerWantManager
)
G
etWantBlocks
()
[]
cid
.
Cid
{
func
(
pwm
*
peerWantManager
)
g
etWantBlocks
()
[]
cid
.
Cid
{
res
:=
cid
.
NewSet
()
// Iterate over all known peers
...
...
@@ -174,7 +174,7 @@ func (pwm *peerWantManager) GetWantBlocks() []cid.Cid {
}
// GetWantHaves returns the set of all want-haves sent to all peers
func
(
pwm
*
peerWantManager
)
G
etWantHaves
()
[]
cid
.
Cid
{
func
(
pwm
*
peerWantManager
)
g
etWantHaves
()
[]
cid
.
Cid
{
res
:=
cid
.
NewSet
()
// Iterate over all known peers
...
...
@@ -190,7 +190,7 @@ func (pwm *peerWantManager) GetWantHaves() []cid.Cid {
}
// GetWants returns the set of all wants (both want-blocks and want-haves).
func
(
pwm
*
peerWantManager
)
G
etWants
()
[]
cid
.
Cid
{
func
(
pwm
*
peerWantManager
)
g
etWants
()
[]
cid
.
Cid
{
res
:=
cid
.
NewSet
()
// Iterate over all known peers
...
...
internal/peermanager/peerwantmanager_test.go
View file @
7348b26c
...
...
@@ -22,10 +22,10 @@ func (g *gauge) Dec() {
func
TestEmpty
(
t
*
testing
.
T
)
{
pwm
:=
newPeerWantManager
(
&
gauge
{})
if
len
(
pwm
.
G
etWantBlocks
())
>
0
{
if
len
(
pwm
.
g
etWantBlocks
())
>
0
{
t
.
Fatal
(
"Expected GetWantBlocks() to have length 0"
)
}
if
len
(
pwm
.
G
etWantHaves
())
>
0
{
if
len
(
pwm
.
g
etWantHaves
())
>
0
{
t
.
Fatal
(
"Expected GetWantHaves() to have length 0"
)
}
}
...
...
@@ -38,11 +38,11 @@ func TestPrepareBroadcastWantHaves(t *testing.T) {
cids2
:=
testutil
.
GenerateCids
(
2
)
cids3
:=
testutil
.
GenerateCids
(
2
)
pwm
.
A
ddPeer
(
peers
[
0
])
pwm
.
A
ddPeer
(
peers
[
1
])
pwm
.
a
ddPeer
(
peers
[
0
])
pwm
.
a
ddPeer
(
peers
[
1
])
// Broadcast 2 cids to 2 peers
bcst
:=
pwm
.
P
repareBroadcastWantHaves
(
cids
)
bcst
:=
pwm
.
p
repareBroadcastWantHaves
(
cids
)
if
len
(
bcst
)
!=
2
{
t
.
Fatal
(
"Expected 2 peers"
)
}
...
...
@@ -53,13 +53,13 @@ func TestPrepareBroadcastWantHaves(t *testing.T) {
}
// Broadcasting same cids should have no effect
bcst2
:=
pwm
.
P
repareBroadcastWantHaves
(
cids
)
bcst2
:=
pwm
.
p
repareBroadcastWantHaves
(
cids
)
if
len
(
bcst2
)
!=
0
{
t
.
Fatal
(
"Expected 0 peers"
)
}
// Broadcast 2 other cids
bcst3
:=
pwm
.
P
repareBroadcastWantHaves
(
cids2
)
bcst3
:=
pwm
.
p
repareBroadcastWantHaves
(
cids2
)
if
len
(
bcst3
)
!=
2
{
t
.
Fatal
(
"Expected 2 peers"
)
}
...
...
@@ -70,7 +70,7 @@ func TestPrepareBroadcastWantHaves(t *testing.T) {
}
// Broadcast mix of old and new cids
bcst4
:=
pwm
.
P
repareBroadcastWantHaves
(
append
(
cids
,
cids3
...
))
bcst4
:=
pwm
.
p
repareBroadcastWantHaves
(
append
(
cids
,
cids3
...
))
if
len
(
bcst4
)
!=
2
{
t
.
Fatal
(
"Expected 2 peers"
)
}
...
...
@@ -84,9 +84,9 @@ func TestPrepareBroadcastWantHaves(t *testing.T) {
// Sending want-block for a cid should prevent broadcast to that peer
cids4
:=
testutil
.
GenerateCids
(
4
)
wantBlocks
:=
[]
cid
.
Cid
{
cids4
[
0
],
cids4
[
2
]}
pwm
.
P
repareSendWants
(
peers
[
0
],
wantBlocks
,
[]
cid
.
Cid
{})
pwm
.
p
repareSendWants
(
peers
[
0
],
wantBlocks
,
[]
cid
.
Cid
{})
bcst5
:=
pwm
.
P
repareBroadcastWantHaves
(
cids4
)
bcst5
:=
pwm
.
p
repareBroadcastWantHaves
(
cids4
)
if
len
(
bcst4
)
!=
2
{
t
.
Fatal
(
"Expected 2 peers"
)
}
...
...
@@ -105,8 +105,8 @@ func TestPrepareBroadcastWantHaves(t *testing.T) {
}
// Add another peer
pwm
.
A
ddPeer
(
peers
[
2
])
bcst6
:=
pwm
.
P
repareBroadcastWantHaves
(
cids
)
pwm
.
a
ddPeer
(
peers
[
2
])
bcst6
:=
pwm
.
p
repareBroadcastWantHaves
(
cids
)
if
len
(
bcst6
)
!=
1
{
t
.
Fatal
(
"Expected 1 peer"
)
}
...
...
@@ -126,11 +126,11 @@ func TestPrepareSendWants(t *testing.T) {
cids
:=
testutil
.
GenerateCids
(
2
)
cids2
:=
testutil
.
GenerateCids
(
2
)
pwm
.
A
ddPeer
(
p0
)
pwm
.
A
ddPeer
(
p1
)
pwm
.
a
ddPeer
(
p0
)
pwm
.
a
ddPeer
(
p1
)
// Send 2 want-blocks and 2 want-haves to p0
wb
,
wh
:=
pwm
.
P
repareSendWants
(
p0
,
cids
,
cids2
)
wb
,
wh
:=
pwm
.
p
repareSendWants
(
p0
,
cids
,
cids2
)
if
!
testutil
.
MatchKeysIgnoreOrder
(
wb
,
cids
)
{
t
.
Fatal
(
"Expected 2 want-blocks"
)
}
...
...
@@ -143,7 +143,7 @@ func TestPrepareSendWants(t *testing.T) {
// - 1 old want-have and 2 new want-haves
cids3
:=
testutil
.
GenerateCids
(
2
)
cids4
:=
testutil
.
GenerateCids
(
2
)
wb2
,
wh2
:=
pwm
.
P
repareSendWants
(
p0
,
append
(
cids3
,
cids
[
0
]),
append
(
cids4
,
cids2
[
0
]))
wb2
,
wh2
:=
pwm
.
p
repareSendWants
(
p0
,
append
(
cids3
,
cids
[
0
]),
append
(
cids4
,
cids2
[
0
]))
if
!
testutil
.
MatchKeysIgnoreOrder
(
wb2
,
cids3
)
{
t
.
Fatal
(
"Expected 2 want-blocks"
)
}
...
...
@@ -154,7 +154,7 @@ func TestPrepareSendWants(t *testing.T) {
// Send to p0 as want-blocks: 1 new want-block, 1 old want-have
cids5
:=
testutil
.
GenerateCids
(
1
)
newWantBlockOldWantHave
:=
append
(
cids5
,
cids2
[
0
])
wb3
,
wh3
:=
pwm
.
P
repareSendWants
(
p0
,
newWantBlockOldWantHave
,
[]
cid
.
Cid
{})
wb3
,
wh3
:=
pwm
.
p
repareSendWants
(
p0
,
newWantBlockOldWantHave
,
[]
cid
.
Cid
{})
// If a want was sent as a want-have, it should be ok to now send it as a
// want-block
if
!
testutil
.
MatchKeysIgnoreOrder
(
wb3
,
newWantBlockOldWantHave
)
{
...
...
@@ -167,7 +167,7 @@ func TestPrepareSendWants(t *testing.T) {
// Send to p0 as want-haves: 1 new want-have, 1 old want-block
cids6
:=
testutil
.
GenerateCids
(
1
)
newWantHaveOldWantBlock
:=
append
(
cids6
,
cids
[
0
])
wb4
,
wh4
:=
pwm
.
P
repareSendWants
(
p0
,
[]
cid
.
Cid
{},
newWantHaveOldWantBlock
)
wb4
,
wh4
:=
pwm
.
p
repareSendWants
(
p0
,
[]
cid
.
Cid
{},
newWantHaveOldWantBlock
)
// If a want was previously sent as a want-block, it should not be
// possible to now send it as a want-have
if
!
testutil
.
MatchKeysIgnoreOrder
(
wh4
,
cids6
)
{
...
...
@@ -178,7 +178,7 @@ func TestPrepareSendWants(t *testing.T) {
}
// Send 2 want-blocks and 2 want-haves to p1
wb5
,
wh5
:=
pwm
.
P
repareSendWants
(
p1
,
cids
,
cids2
)
wb5
,
wh5
:=
pwm
.
p
repareSendWants
(
p1
,
cids
,
cids2
)
if
!
testutil
.
MatchKeysIgnoreOrder
(
wb5
,
cids
)
{
t
.
Fatal
(
"Expected 2 want-blocks"
)
}
...
...
@@ -200,24 +200,24 @@ func TestPrepareSendCancels(t *testing.T) {
allwb
:=
append
(
wb1
,
wb2
...
)
allwh
:=
append
(
wh1
,
wh2
...
)
pwm
.
A
ddPeer
(
p0
)
pwm
.
A
ddPeer
(
p1
)
pwm
.
a
ddPeer
(
p0
)
pwm
.
a
ddPeer
(
p1
)
// Send 2 want-blocks and 2 want-haves to p0
pwm
.
P
repareSendWants
(
p0
,
wb1
,
wh1
)
pwm
.
p
repareSendWants
(
p0
,
wb1
,
wh1
)
// Send 3 want-blocks and 3 want-haves to p1
// (1 overlapping want-block / want-have with p0)
pwm
.
P
repareSendWants
(
p1
,
append
(
wb2
,
wb1
[
1
]),
append
(
wh2
,
wh1
[
1
]))
pwm
.
p
repareSendWants
(
p1
,
append
(
wb2
,
wb1
[
1
]),
append
(
wh2
,
wh1
[
1
]))
if
!
testutil
.
MatchKeysIgnoreOrder
(
pwm
.
G
etWantBlocks
(),
allwb
)
{
if
!
testutil
.
MatchKeysIgnoreOrder
(
pwm
.
g
etWantBlocks
(),
allwb
)
{
t
.
Fatal
(
"Expected 4 cids to be wanted"
)
}
if
!
testutil
.
MatchKeysIgnoreOrder
(
pwm
.
G
etWantHaves
(),
allwh
)
{
if
!
testutil
.
MatchKeysIgnoreOrder
(
pwm
.
g
etWantHaves
(),
allwh
)
{
t
.
Fatal
(
"Expected 4 cids to be wanted"
)
}
// Cancel 1 want-block and 1 want-have that were sent to p0
res
:=
pwm
.
P
repareSendCancels
([]
cid
.
Cid
{
wb1
[
0
],
wh1
[
0
]})
res
:=
pwm
.
p
repareSendCancels
([]
cid
.
Cid
{
wb1
[
0
],
wh1
[
0
]})
// Should cancel the want-block and want-have
if
len
(
res
)
!=
1
{
t
.
Fatal
(
"Expected 1 peer"
)
...
...
@@ -225,16 +225,16 @@ func TestPrepareSendCancels(t *testing.T) {
if
!
testutil
.
MatchKeysIgnoreOrder
(
res
[
p0
],
[]
cid
.
Cid
{
wb1
[
0
],
wh1
[
0
]})
{
t
.
Fatal
(
"Expected 2 cids to be cancelled"
)
}
if
!
testutil
.
MatchKeysIgnoreOrder
(
pwm
.
G
etWantBlocks
(),
append
(
wb2
,
wb1
[
1
]))
{
if
!
testutil
.
MatchKeysIgnoreOrder
(
pwm
.
g
etWantBlocks
(),
append
(
wb2
,
wb1
[
1
]))
{
t
.
Fatal
(
"Expected 3 want-blocks"
)
}
if
!
testutil
.
MatchKeysIgnoreOrder
(
pwm
.
G
etWantHaves
(),
append
(
wh2
,
wh1
[
1
]))
{
if
!
testutil
.
MatchKeysIgnoreOrder
(
pwm
.
g
etWantHaves
(),
append
(
wh2
,
wh1
[
1
]))
{
t
.
Fatal
(
"Expected 3 want-haves"
)
}
// Cancel everything
allCids
:=
append
(
allwb
,
allwh
...
)
res2
:=
pwm
.
P
repareSendCancels
(
allCids
)
res2
:=
pwm
.
p
repareSendCancels
(
allCids
)
// Should cancel the remaining want-blocks and want-haves
if
len
(
res2
)
!=
2
{
t
.
Fatal
(
"Expected 2 peers"
,
len
(
res2
))
...
...
@@ -247,10 +247,10 @@ func TestPrepareSendCancels(t *testing.T) {
if
!
testutil
.
MatchKeysIgnoreOrder
(
res2
[
p1
],
remainingP2
)
{
t
.
Fatal
(
"Expected un-cancelled cids to be cancelled"
)
}
if
len
(
pwm
.
G
etWantBlocks
())
!=
0
{
if
len
(
pwm
.
g
etWantBlocks
())
!=
0
{
t
.
Fatal
(
"Expected 0 want-blocks"
)
}
if
len
(
pwm
.
G
etWantHaves
())
!=
0
{
if
len
(
pwm
.
g
etWantHaves
())
!=
0
{
t
.
Fatal
(
"Expected 0 want-haves"
)
}
}
...
...
@@ -264,10 +264,10 @@ func TestStats(t *testing.T) {
cids
:=
testutil
.
GenerateCids
(
2
)
cids2
:=
testutil
.
GenerateCids
(
2
)
pwm
.
A
ddPeer
(
p0
)
pwm
.
a
ddPeer
(
p0
)
// Send 2 want-blocks and 2 want-haves to p0
pwm
.
P
repareSendWants
(
p0
,
cids
,
cids2
)
pwm
.
p
repareSendWants
(
p0
,
cids
,
cids2
)
if
g
.
count
!=
2
{
t
.
Fatal
(
"Expected 2 want-blocks"
)
...
...
@@ -275,7 +275,7 @@ func TestStats(t *testing.T) {
// Send 1 old want-block and 2 new want-blocks to p0
cids3
:=
testutil
.
GenerateCids
(
2
)
pwm
.
P
repareSendWants
(
p0
,
append
(
cids3
,
cids
[
0
]),
[]
cid
.
Cid
{})
pwm
.
p
repareSendWants
(
p0
,
append
(
cids3
,
cids
[
0
]),
[]
cid
.
Cid
{})
if
g
.
count
!=
4
{
t
.
Fatal
(
"Expected 4 want-blocks"
)
...
...
@@ -284,7 +284,7 @@ func TestStats(t *testing.T) {
// Cancel 1 want-block that was sent to p0
// and 1 want-block that was not sent
cids4
:=
testutil
.
GenerateCids
(
1
)
pwm
.
P
repareSendCancels
(
append
(
cids4
,
cids
[
0
]))
pwm
.
p
repareSendCancels
(
append
(
cids4
,
cids
[
0
]))
if
g
.
count
!=
3
{
t
.
Fatal
(
"Expected 3 want-blocks"
,
g
.
count
)
...
...
internal/wantmanager/wantmanager.go
View file @
7348b26c
...
...
@@ -89,7 +89,7 @@ func (wm *WantManager) BroadcastWantHaves(ctx context.Context, ses uint64, wantH
// RemoveSession is called when the session is shut down
func
(
wm
*
WantManager
)
RemoveSession
(
ctx
context
.
Context
,
ses
uint64
)
{
// Remove session's interest in the given blocks
// Remove session's interest in the given blocks
.
cancelKs
:=
wm
.
sim
.
RemoveSessionInterest
(
ses
)
// Remove broadcast want-haves for session
...
...
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