Skip to content

Commit e287d7e

Browse files
authored
fix(dot/sync): remove max size limit from ascending block requests (#2256)
1 parent 656fd8d commit e287d7e

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

dot/sync/chain_sync.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,8 +1015,9 @@ func workerToRequests(w *worker) ([]*network.BlockRequestMessage, error) {
10151015

10161016
for i := 0; i < numRequests; i++ {
10171017
// check if we want to specify a size
1018-
var max uint32 = maxResponseSize
1019-
if i == numRequests-1 {
1018+
max := uint32(maxResponseSize)
1019+
1020+
if w.direction == network.Descending && i == numRequests-1 {
10201021
size := numBlocks % maxResponseSize
10211022
if size == 0 {
10221023
size = maxResponseSize

dot/sync/chain_sync_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,6 @@ func TestWorkerToRequests(t *testing.T) {
275275
max128 = uint32(128)
276276
max9 = uint32(9)
277277
max64 = uint32(64)
278-
max1 = uint32(1)
279278
)
280279

281280
testCases := []testCase{
@@ -333,7 +332,7 @@ func TestWorkerToRequests(t *testing.T) {
333332
StartingBlock: *variadic.MustNewUint64OrHash(1),
334333
EndBlockHash: nil,
335334
Direction: network.Ascending,
336-
Max: &max9,
335+
Max: &max128,
337336
},
338337
},
339338
},
@@ -374,7 +373,7 @@ func TestWorkerToRequests(t *testing.T) {
374373
StartingBlock: *variadic.MustNewUint64OrHash(1 + maxResponseSize),
375374
EndBlockHash: nil,
376375
Direction: network.Ascending,
377-
Max: &max64,
376+
Max: &max128,
378377
},
379378
},
380379
},
@@ -392,7 +391,7 @@ func TestWorkerToRequests(t *testing.T) {
392391
StartingBlock: *variadic.MustNewUint64OrHash(1),
393392
EndBlockHash: &(common.Hash{0xa}),
394393
Direction: network.Ascending,
395-
Max: &max9,
394+
Max: &max128,
396395
},
397396
},
398397
},
@@ -411,7 +410,7 @@ func TestWorkerToRequests(t *testing.T) {
411410
StartingBlock: *variadic.MustNewUint64OrHash(common.Hash{0xb}),
412411
EndBlockHash: &(common.Hash{0xc}),
413412
Direction: network.Ascending,
414-
Max: &max9,
413+
Max: &max128,
415414
},
416415
},
417416
},
@@ -427,7 +426,7 @@ func TestWorkerToRequests(t *testing.T) {
427426
RequestedData: bootstrapRequestData,
428427
StartingBlock: *variadic.MustNewUint64OrHash(10),
429428
Direction: network.Ascending,
430-
Max: &max1,
429+
Max: &max128,
431430
},
432431
},
433432
},

0 commit comments

Comments
 (0)