eth/downloader: change intial download size (#21366)

This changes how the downloader works, a little bit. Previously, when block sync started,
we immediately started filling up to 8192 blocks. Usually this is fine, blocks are small
in the early numbers. The threshold then is lowered as we measure the size of the blocks
that are filled.

However, if the node is shut down and restarts syncing while we're in a heavy segment,
that might be bad. This PR introduces a more conservative initial threshold of 2K blocks
instead.
This commit is contained in:
Martin Holst Swende
2020-09-02 11:01:46 +02:00
committed by GitHub
parent d90bbce954
commit 3010f9fc75
5 changed files with 26 additions and 24 deletions

View File

@ -97,7 +97,7 @@ func dummyPeer(id string) *peerConnection {
}
func TestBasics(t *testing.T) {
q := newQueue(10)
q := newQueue(10, 10)
if !q.Idle() {
t.Errorf("new queue should be idle")
}
@ -174,7 +174,7 @@ func TestBasics(t *testing.T) {
}
func TestEmptyBlocks(t *testing.T) {
q := newQueue(10)
q := newQueue(10, 10)
q.Prepare(1, FastSync)
// Schedule a batch of headers
@ -244,7 +244,7 @@ func XTestDelivery(t *testing.T) {
log.Root().SetHandler(log.StdoutHandler)
}
q := newQueue(10)
q := newQueue(10, 10)
var wg sync.WaitGroup
q.Prepare(1, FastSync)
wg.Add(1)