@@ -60,7 +60,7 @@ func (tl *prq) Push(to peer.ID, entries ...*wantlist.Entry) {
60
60
defer partner .activelk .Unlock ()
61
61
62
62
var priority int
63
- newEntries := make ([]* wantlist. Entry , 0 , len (entries ))
63
+ newEntries := make ([]* peerRequestTaskEntry , 0 , len (entries ))
64
64
for _ , entry := range entries {
65
65
if partner .activeBlocks .Has (entry .Cid ) {
66
66
continue
@@ -75,7 +75,7 @@ func (tl *prq) Push(to peer.ID, entries ...*wantlist.Entry) {
75
75
if entry .Priority > priority {
76
76
priority = entry .Priority
77
77
}
78
- newEntries = append (newEntries , entry )
78
+ newEntries = append (newEntries , & peerRequestTaskEntry { entry , false } )
79
79
}
80
80
81
81
if len (newEntries ) == 0 {
@@ -86,7 +86,7 @@ func (tl *prq) Push(to peer.ID, entries ...*wantlist.Entry) {
86
86
Entries : newEntries ,
87
87
Target : to ,
88
88
created : time .Now (),
89
- Done : func (e []* wantlist. Entry ) {
89
+ Done : func (e []* peerRequestTaskEntry ) {
90
90
tl .lock .Lock ()
91
91
for _ , entry := range e {
92
92
partner .TaskDone (entry .Cid )
@@ -117,10 +117,10 @@ func (tl *prq) Pop() *peerRequestTask {
117
117
for partner .taskQueue .Len () > 0 && partner .freezeVal == 0 {
118
118
out = partner .taskQueue .Pop ().(* peerRequestTask )
119
119
120
- newEntries := make ([]* wantlist. Entry , 0 , len (out .Entries ))
120
+ newEntries := make ([]* peerRequestTaskEntry , 0 , len (out .Entries ))
121
121
for _ , entry := range out .Entries {
122
122
delete (tl .taskMap , taskEntryKey {out .Target , entry .Cid })
123
- if entry .Trash {
123
+ if entry .trash {
124
124
continue
125
125
}
126
126
partner .requests --
@@ -150,7 +150,7 @@ func (tl *prq) Remove(k cid.Cid, p peer.ID) {
150
150
// remove the task "lazily"
151
151
// simply mark it as trash, so it'll be dropped when popped off the
152
152
// queue.
153
- entry .Trash = true
153
+ entry .trash = true
154
154
break
155
155
}
156
156
}
@@ -197,13 +197,18 @@ func (tl *prq) thawRound() {
197
197
}
198
198
}
199
199
200
+ type peerRequestTaskEntry struct {
201
+ * wantlist.Entry
202
+ // trash in a book-keeping field
203
+ trash bool
204
+ }
200
205
type peerRequestTask struct {
201
- Entries []* wantlist. Entry
206
+ Entries []* peerRequestTaskEntry
202
207
Priority int
203
208
Target peer.ID
204
209
205
210
// A callback to signal that this task has been completed
206
- Done func ([]* wantlist. Entry )
211
+ Done func ([]* peerRequestTaskEntry )
207
212
208
213
// created marks the time that the task was added to the queue
209
214
created time.Time
0 commit comments