Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions dot/sync/chain_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -973,8 +973,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