8
8
"testing"
9
9
"time"
10
10
11
- "github.com/ipfs/go-cid"
12
11
"github.com/ipfs/go-peertaskqueue/peertask"
13
12
"github.com/ipld/go-ipld-prime"
14
13
cidlink "github.com/ipld/go-ipld-prime/linking/cid"
@@ -17,7 +16,7 @@ import (
17
16
"github.com/stretchr/testify/require"
18
17
19
18
"github.com/ipfs/go-graphsync"
20
- "github.com/ipfs/go-graphsync/cidset "
19
+ "github.com/ipfs/go-graphsync/donotsendfirstblocks "
21
20
"github.com/ipfs/go-graphsync/ipldutil"
22
21
gsmsg "github.com/ipfs/go-graphsync/message"
23
22
"github.com/ipfs/go-graphsync/requestmanager/executor"
@@ -102,21 +101,21 @@ func TestRequestExecutionBlockChain(t *testing.T) {
102
101
require .EqualError (t , ree .terminalError , hooks.ErrPaused {}.Error ())
103
102
},
104
103
},
105
- "preexisting do not send cids " : {
104
+ "preexisting do not send firstBlocks " : {
106
105
configureRequestExecution : func (p peer.ID , requestID graphsync.RequestID , tbc * testutil.TestBlockChain , ree * requestExecutionEnv ) {
107
- ree .doNotSendCids . Add ( tbc . GenisisLink .(cidlink. Link ). Cid )
106
+ ree .doNotSendFirstBlocks = 1
108
107
},
109
108
verifyResults : func (t * testing.T , tbc * testutil.TestBlockChain , ree * requestExecutionEnv , responses []graphsync.ResponseProgress , receivedErrors []error ) {
110
109
tbc .VerifyWholeChainSync (responses )
111
110
require .Empty (t , receivedErrors )
112
111
require .Equal (t , ree .request .ID (), ree .requestsSent [0 ].request .ID ())
113
112
require .Equal (t , ree .request .Root (), ree .requestsSent [0 ].request .Root ())
114
113
require .Equal (t , ree .request .Selector (), ree .requestsSent [0 ].request .Selector ())
115
- doNotSendCidsExt , has := ree .requestsSent [0 ].request .Extension (graphsync .ExtensionDoNotSendCIDs )
114
+ doNotSendFirstBlocksData , has := ree .requestsSent [0 ].request .Extension (graphsync .ExtensionsDoNotSendFirstBlocks )
116
115
require .True (t , has )
117
- cidSet , err := cidset . DecodeCidSet ( doNotSendCidsExt )
116
+ doNotSendFirstBlocks , err := donotsendfirstblocks . DecodeDoNotSendFirstBlocks ( doNotSendFirstBlocksData )
118
117
require .NoError (t , err )
119
- require .Equal (t , 1 , cidSet . Len () )
118
+ require .Equal (t , int64 ( 1 ), doNotSendFirstBlocks )
120
119
require .Len (t , ree .blookHooksCalled , 10 )
121
120
require .NoError (t , ree .terminalError )
122
121
},
@@ -145,11 +144,11 @@ func TestRequestExecutionBlockChain(t *testing.T) {
145
144
require .Equal (t , ree .request .ID (), ree .requestsSent [0 ].request .ID ())
146
145
require .Equal (t , ree .request .Root (), ree .requestsSent [0 ].request .Root ())
147
146
require .Equal (t , ree .request .Selector (), ree .requestsSent [0 ].request .Selector ())
148
- doNotSendCidsExt , has := ree .requestsSent [0 ].request .Extension (graphsync .ExtensionDoNotSendCIDs )
147
+ doNotSendFirstBlocksData , has := ree .requestsSent [0 ].request .Extension (graphsync .ExtensionsDoNotSendFirstBlocks )
149
148
require .True (t , has )
150
- cidSet , err := cidset . DecodeCidSet ( doNotSendCidsExt )
149
+ doNotSendFirstBlocks , err := donotsendfirstblocks . DecodeDoNotSendFirstBlocks ( doNotSendFirstBlocksData )
151
150
require .NoError (t , err )
152
- require .Equal (t , 6 , cidSet . Len () )
151
+ require .Equal (t , int64 ( 6 ), doNotSendFirstBlocks )
153
152
require .Len (t , ree .blookHooksCalled , 10 )
154
153
require .NoError (t , ree .terminalError )
155
154
},
@@ -202,16 +201,16 @@ func TestRequestExecutionBlockChain(t *testing.T) {
202
201
defer requestCancel ()
203
202
var responsesReceived []graphsync.ResponseProgress
204
203
ree := & requestExecutionEnv {
205
- ctx : requestCtx ,
206
- p : p ,
207
- pauseMessages : make (chan struct {}, 1 ),
208
- blockHookResults : make (map [blockHookKey ]hooks.UpdateResult ),
209
- doNotSendCids : cid . NewSet () ,
210
- request : gsmsg .NewRequest (requestID , tbc .TipLink .(cidlink.Link ).Cid , tbc .Selector (), graphsync .Priority (rand .Int31 ())),
211
- fal : fal ,
212
- tbc : tbc ,
213
- initialRequest : true ,
214
- inProgressErr : make (chan error , 1 ),
204
+ ctx : requestCtx ,
205
+ p : p ,
206
+ pauseMessages : make (chan struct {}, 1 ),
207
+ blockHookResults : make (map [blockHookKey ]hooks.UpdateResult ),
208
+ doNotSendFirstBlocks : 0 ,
209
+ request : gsmsg .NewRequest (requestID , tbc .TipLink .(cidlink.Link ).Cid , tbc .Selector (), graphsync .Priority (rand .Int31 ())),
210
+ fal : fal ,
211
+ tbc : tbc ,
212
+ initialRequest : true ,
213
+ inProgressErr : make (chan error , 1 ),
215
214
traverser : ipldutil.TraversalBuilder {
216
215
Root : tbc .TipLink ,
217
216
Selector : tbc .Selector (),
@@ -276,7 +275,7 @@ type requestExecutionEnv struct {
276
275
request gsmsg.GraphSyncRequest
277
276
p peer.ID
278
277
blockHookResults map [blockHookKey ]hooks.UpdateResult
279
- doNotSendCids * cid. Set
278
+ doNotSendFirstBlocks int64
280
279
pauseMessages chan struct {}
281
280
externalPause pauseKey
282
281
loadLocallyUntil int
@@ -304,16 +303,16 @@ func (ree *requestExecutionEnv) GetRequestTask(_ peer.ID, _ *peertask.Task, requ
304
303
lastResponse .Store (gsmsg .NewResponse (ree .request .ID (), graphsync .RequestAcknowledged ))
305
304
306
305
requestExecution := executor.RequestTask {
307
- Ctx : ree .ctx ,
308
- Request : ree .request ,
309
- LastResponse : & lastResponse ,
310
- DoNotSendCids : ree .doNotSendCids ,
311
- PauseMessages : ree .pauseMessages ,
312
- Traverser : ree .traverser ,
313
- P : ree .p ,
314
- InProgressErr : ree .inProgressErr ,
315
- Empty : false ,
316
- InitialRequest : ree .initialRequest ,
306
+ Ctx : ree .ctx ,
307
+ Request : ree .request ,
308
+ LastResponse : & lastResponse ,
309
+ DoNotSendFirstBlocks : ree .doNotSendFirstBlocks ,
310
+ PauseMessages : ree .pauseMessages ,
311
+ Traverser : ree .traverser ,
312
+ P : ree .p ,
313
+ InProgressErr : ree .inProgressErr ,
314
+ Empty : false ,
315
+ InitialRequest : ree .initialRequest ,
317
316
}
318
317
go func () {
319
318
select {
0 commit comments