@@ -12,10 +12,10 @@ import (
12
12
13
13
// Wantlist is a raw list of wanted blocks and their priorities
14
14
type Wantlist struct {
15
- set map [cid.Cid ]Entry
15
+ set map [cid.Cid ]* Entry
16
16
17
17
// Re-computing this can get expensive so we memoize it.
18
- cached []Entry
18
+ cached []* Entry
19
19
}
20
20
21
21
// Entry is an entry in a want list, consisting of a cid and its priority
@@ -37,7 +37,7 @@ func NewRefEntry(c cid.Cid, p int32) Entry {
37
37
// New generates a new raw Wantlist
38
38
func New () * Wantlist {
39
39
return & Wantlist {
40
- set : make (map [cid.Cid ]Entry ),
40
+ set : make (map [cid.Cid ]* Entry ),
41
41
}
42
42
}
43
43
@@ -55,7 +55,7 @@ func (w *Wantlist) Add(c cid.Cid, priority int32, wantType pb.Message_Wantlist_W
55
55
return false
56
56
}
57
57
58
- w .put (c , Entry {
58
+ w .put (c , & Entry {
59
59
Cid : c ,
60
60
Priority : priority ,
61
61
WantType : wantType ,
@@ -91,7 +91,7 @@ func (w *Wantlist) delete(c cid.Cid) {
91
91
w .cached = nil
92
92
}
93
93
94
- func (w * Wantlist ) put (c cid.Cid , e Entry ) {
94
+ func (w * Wantlist ) put (c cid.Cid , e * Entry ) {
95
95
w .cached = nil
96
96
w .set [c ] = e
97
97
}
@@ -103,23 +103,23 @@ func (w *Wantlist) Has(c cid.Cid) bool {
103
103
104
104
// Get returns the entry, if present, for the given CID, plus whether it was
105
105
// present.
106
- func (w * Wantlist ) Get (c cid.Cid ) (Entry , bool ) {
106
+ func (w * Wantlist ) Get (c cid.Cid ) (* Entry , bool ) {
107
107
e , ok := w .set [c ]
108
108
return e , ok
109
109
}
110
110
111
111
// Entries returns all wantlist entries for a want list, sorted by priority.
112
112
//
113
113
// DO NOT MODIFY. The returned list is cached.
114
- func (w * Wantlist ) Entries () []Entry {
114
+ func (w * Wantlist ) Entries () []* Entry {
115
115
if w .cached != nil {
116
116
return w .cached
117
117
}
118
- es := make ([]Entry , 0 , len (w .set ))
118
+ es := make ([]* Entry , 0 , len (w .set ))
119
119
for _ , e := range w .set {
120
120
es = append (es , e )
121
121
}
122
- slices .SortFunc (es , func (a , b Entry ) int {
122
+ slices .SortFunc (es , func (a , b * Entry ) int {
123
123
return cmp .Compare (b .Priority , a .Priority )
124
124
})
125
125
w .cached = es
0 commit comments