Skip to content

Commit

Permalink
fix(dot/sync): remove max size limit from ascending block requests (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
noot committed Jan 31, 2022
1 parent 656fd8d commit e287d7e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
5 changes: 3 additions & 2 deletions dot/sync/chain_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -1015,8 +1015,9 @@ func workerToRequests(w *worker) ([]*network.BlockRequestMessage, error) {

for i := 0; i < numRequests; i++ {
// check if we want to specify a size
var max uint32 = maxResponseSize
if i == numRequests-1 {
max := uint32(maxResponseSize)

if w.direction == network.Descending && i == numRequests-1 {
size := numBlocks % maxResponseSize
if size == 0 {
size = maxResponseSize
Expand Down
11 changes: 5 additions & 6 deletions dot/sync/chain_sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ func TestWorkerToRequests(t *testing.T) {
max128 = uint32(128)
max9 = uint32(9)
max64 = uint32(64)
max1 = uint32(1)
)

testCases := []testCase{
Expand Down Expand Up @@ -333,7 +332,7 @@ func TestWorkerToRequests(t *testing.T) {
StartingBlock: *variadic.MustNewUint64OrHash(1),
EndBlockHash: nil,
Direction: network.Ascending,
Max: &max9,
Max: &max128,
},
},
},
Expand Down Expand Up @@ -374,7 +373,7 @@ func TestWorkerToRequests(t *testing.T) {
StartingBlock: *variadic.MustNewUint64OrHash(1 + maxResponseSize),
EndBlockHash: nil,
Direction: network.Ascending,
Max: &max64,
Max: &max128,
},
},
},
Expand All @@ -392,7 +391,7 @@ func TestWorkerToRequests(t *testing.T) {
StartingBlock: *variadic.MustNewUint64OrHash(1),
EndBlockHash: &(common.Hash{0xa}),
Direction: network.Ascending,
Max: &max9,
Max: &max128,
},
},
},
Expand All @@ -411,7 +410,7 @@ func TestWorkerToRequests(t *testing.T) {
StartingBlock: *variadic.MustNewUint64OrHash(common.Hash{0xb}),
EndBlockHash: &(common.Hash{0xc}),
Direction: network.Ascending,
Max: &max9,
Max: &max128,
},
},
},
Expand All @@ -427,7 +426,7 @@ func TestWorkerToRequests(t *testing.T) {
RequestedData: bootstrapRequestData,
StartingBlock: *variadic.MustNewUint64OrHash(10),
Direction: network.Ascending,
Max: &max1,
Max: &max128,
},
},
},
Expand Down

0 comments on commit e287d7e

Please sign in to comment.