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
95f6e624
Commit
95f6e624
authored
Feb 19, 2019
by
hannahhoward
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(wantlist): remove trash field
put trash field only where it is needed, in peer request queues
parent
78386f0e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
11 deletions
+13
-11
decision/peer_request_queue.go
decision/peer_request_queue.go
+13
-8
wantlist/wantlist.go
wantlist/wantlist.go
+0
-3
No files found.
decision/peer_request_queue.go
View file @
95f6e624
...
...
@@ -60,7 +60,7 @@ func (tl *prq) Push(to peer.ID, entries ...*wantlist.Entry) {
defer
partner
.
activelk
.
Unlock
()
var
priority
int
newEntries
:=
make
([]
*
wantlist
.
Entry
,
0
,
len
(
entries
))
newEntries
:=
make
([]
*
peerRequestTask
Entry
,
0
,
len
(
entries
))
for
_
,
entry
:=
range
entries
{
if
partner
.
activeBlocks
.
Has
(
entry
.
Cid
)
{
continue
...
...
@@ -75,7 +75,7 @@ func (tl *prq) Push(to peer.ID, entries ...*wantlist.Entry) {
if
entry
.
Priority
>
priority
{
priority
=
entry
.
Priority
}
newEntries
=
append
(
newEntries
,
entry
)
newEntries
=
append
(
newEntries
,
&
peerRequestTaskEntry
{
entry
,
false
}
)
}
if
len
(
newEntries
)
==
0
{
...
...
@@ -86,7 +86,7 @@ func (tl *prq) Push(to peer.ID, entries ...*wantlist.Entry) {
Entries
:
newEntries
,
Target
:
to
,
created
:
time
.
Now
(),
Done
:
func
(
e
[]
*
wantlist
.
Entry
)
{
Done
:
func
(
e
[]
*
peerRequestTask
Entry
)
{
tl
.
lock
.
Lock
()
for
_
,
entry
:=
range
e
{
partner
.
TaskDone
(
entry
.
Cid
)
...
...
@@ -117,10 +117,10 @@ func (tl *prq) Pop() *peerRequestTask {
for
partner
.
taskQueue
.
Len
()
>
0
&&
partner
.
freezeVal
==
0
{
out
=
partner
.
taskQueue
.
Pop
()
.
(
*
peerRequestTask
)
newEntries
:=
make
([]
*
wantlist
.
Entry
,
0
,
len
(
out
.
Entries
))
newEntries
:=
make
([]
*
peerRequestTask
Entry
,
0
,
len
(
out
.
Entries
))
for
_
,
entry
:=
range
out
.
Entries
{
delete
(
tl
.
taskMap
,
taskEntryKey
{
out
.
Target
,
entry
.
Cid
})
if
entry
.
T
rash
{
if
entry
.
t
rash
{
continue
}
partner
.
requests
--
...
...
@@ -150,7 +150,7 @@ func (tl *prq) Remove(k cid.Cid, p peer.ID) {
// remove the task "lazily"
// simply mark it as trash, so it'll be dropped when popped off the
// queue.
entry
.
T
rash
=
true
entry
.
t
rash
=
true
break
}
}
...
...
@@ -197,13 +197,18 @@ func (tl *prq) thawRound() {
}
}
type
peerRequestTaskEntry
struct
{
*
wantlist
.
Entry
// trash in a book-keeping field
trash
bool
}
type
peerRequestTask
struct
{
Entries
[]
*
wantlist
.
Entry
Entries
[]
*
peerRequestTask
Entry
Priority
int
Target
peer
.
ID
// A callback to signal that this task has been completed
Done
func
([]
*
wantlist
.
Entry
)
Done
func
([]
*
peerRequestTask
Entry
)
// created marks the time that the task was added to the queue
created
time
.
Time
...
...
wantlist/wantlist.go
View file @
95f6e624
...
...
@@ -19,9 +19,6 @@ type Wantlist struct {
type
Entry
struct
{
Cid
cid
.
Cid
Priority
int
// Trash in a book-keeping field
Trash
bool
}
type
sessionTrackedEntry
struct
{
...
...
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