aboutsummaryrefslogtreecommitdiffstats
path: root/eth/downloader
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-05-21 23:16:04 +0800
committerPéter Szilágyi <peterke@gmail.com>2015-05-21 23:16:04 +0800
commit06a041589f3c2d4b3e66a1ce51e3e03e209fdbff (patch)
tree2c6d15f5ac83fcf642b3c8432da19e937534f5f1 /eth/downloader
parent52db6d8be577669bd5ba659ac223acf61956b05a (diff)
downloaddexon-06a041589f3c2d4b3e66a1ce51e3e03e209fdbff.tar
dexon-06a041589f3c2d4b3e66a1ce51e3e03e209fdbff.tar.gz
dexon-06a041589f3c2d4b3e66a1ce51e3e03e209fdbff.tar.bz2
dexon-06a041589f3c2d4b3e66a1ce51e3e03e209fdbff.tar.lz
dexon-06a041589f3c2d4b3e66a1ce51e3e03e209fdbff.tar.xz
dexon-06a041589f3c2d4b3e66a1ce51e3e03e209fdbff.tar.zst
dexon-06a041589f3c2d4b3e66a1ce51e3e03e209fdbff.zip
eth, eth/downloader: remove duplicate consts, bump hash fetch to 2K
Diffstat (limited to 'eth/downloader')
-rw-r--r--eth/downloader/downloader.go10
-rw-r--r--eth/downloader/downloader_test.go2
-rw-r--r--eth/downloader/queue.go2
3 files changed, 8 insertions, 6 deletions
diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go
index f0629a551..fd588d2f3 100644
--- a/eth/downloader/downloader.go
+++ b/eth/downloader/downloader.go
@@ -15,8 +15,10 @@ import (
)
const (
- maxHashFetch = 512 // Amount of hashes to be fetched per chunk
- maxBlockFetch = 128 // Amount of blocks to be fetched per chunk
+ MinHashFetch = 512 // Minimum amount of hashes to not consider a peer stalling
+ MaxHashFetch = 2048 // Amount of hashes to be fetched per retrieval request
+ MaxBlockFetch = 128 // Amount of blocks to be fetched per retrieval request
+
peerCountTimeout = 12 * time.Second // Amount of time it takes for the peer handler to ignore minDesiredPeerCount
hashTTL = 5 * time.Second // Time it takes for a hash request to time out
)
@@ -290,7 +292,7 @@ func (d *Downloader) fetchHashes(p *peer, h common.Hash) error {
}
if !done {
// Check that the peer is not stalling the sync
- if len(inserts) < maxHashFetch {
+ if len(inserts) < MinHashFetch {
return ErrStallingPeer
}
// Try and fetch a random block to verify the hash batch
@@ -451,7 +453,7 @@ out:
}
// Get a possible chunk. If nil is returned no chunk
// could be returned due to no hashes available.
- request := d.queue.Reserve(peer, maxBlockFetch)
+ request := d.queue.Reserve(peer, MaxBlockFetch)
if request == nil {
continue
}
diff --git a/eth/downloader/downloader_test.go b/eth/downloader/downloader_test.go
index d623a7c76..6299ea162 100644
--- a/eth/downloader/downloader_test.go
+++ b/eth/downloader/downloader_test.go
@@ -135,7 +135,7 @@ func (dl *downloadTester) getBlock(hash common.Hash) *types.Block {
// getHashes retrieves a batch of hashes for reconstructing the chain.
func (dl *downloadTester) getHashes(head common.Hash) error {
- limit := maxHashFetch
+ limit := MaxHashFetch
if dl.maxHashFetch > 0 {
limit = dl.maxHashFetch
}
diff --git a/eth/downloader/queue.go b/eth/downloader/queue.go
index 13ec9a520..591a37773 100644
--- a/eth/downloader/queue.go
+++ b/eth/downloader/queue.go
@@ -17,7 +17,7 @@ import (
)
const (
- blockCacheLimit = 1024 // Maximum number of blocks to cache before throttling the download
+ blockCacheLimit = 8 * MaxBlockFetch // Maximum number of blocks to cache before throttling the download
)
// fetchRequest is a currently running block retrieval operation.