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
0bdc018c
Commit
0bdc018c
authored
May 03, 2019
by
hannahhoward
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(peerrequestqueue): add target to queue
Add a peer id to an active partner queue
parent
0a309a17
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
10 deletions
+7
-10
decision/peer_request_queue.go
decision/peer_request_queue.go
+7
-10
No files found.
decision/peer_request_queue.go
View file @
0bdc018c
...
...
@@ -51,7 +51,7 @@ func (tl *prq) Push(to peer.ID, entries ...wantlist.Entry) {
defer
tl
.
lock
.
Unlock
()
partner
,
ok
:=
tl
.
partners
[
to
]
if
!
ok
{
partner
=
newActivePartner
()
partner
=
newActivePartner
(
to
)
tl
.
pQueue
.
Push
(
partner
)
tl
.
partners
[
to
]
=
partner
}
...
...
@@ -137,13 +137,9 @@ func (tl *prq) Pop() *peerRequestTask {
}
if
partner
.
IsIdle
()
{
for
target
,
testPartner
:=
range
tl
.
partners
{
if
testPartner
==
partner
{
target
:=
partner
.
target
delete
(
tl
.
partners
,
target
)
delete
(
tl
.
frozen
,
target
)
break
}
}
}
else
{
tl
.
pQueue
.
Push
(
partner
)
}
...
...
@@ -262,7 +258,7 @@ func wrapCmp(f func(a, b *peerRequestTask) bool) func(a, b pq.Elem) bool {
}
type
activePartner
struct
{
target
peer
.
ID
// Active is the number of blocks this peer is currently being sent
// active must be locked around as it will be updated externally
activelk
sync
.
Mutex
...
...
@@ -284,8 +280,9 @@ type activePartner struct {
taskQueue
pq
.
PQ
}
func
newActivePartner
()
*
activePartner
{
func
newActivePartner
(
target
peer
.
ID
)
*
activePartner
{
return
&
activePartner
{
target
:
target
,
taskQueue
:
pq
.
New
(
wrapCmp
(
V1
)),
activeBlocks
:
cid
.
NewSet
(),
}
...
...
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