|
|
|
@ -31,7 +31,7 @@ import ( |
|
|
|
|
"github.com/ethereum/go-ethereum/trie" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
// stateReq represents a batch of state fetch requests groupped together into
|
|
|
|
|
// stateReq represents a batch of state fetch requests grouped together into
|
|
|
|
|
// a single data retrieval network packet.
|
|
|
|
|
type stateReq struct { |
|
|
|
|
items []common.Hash // Hashes of the state items to download
|
|
|
|
@ -139,7 +139,7 @@ func (d *Downloader) runStateSync(s *stateSync) *stateSync { |
|
|
|
|
|
|
|
|
|
// Handle incoming state packs:
|
|
|
|
|
case pack := <-d.stateCh: |
|
|
|
|
// Discard any data not requested (or previsouly timed out)
|
|
|
|
|
// Discard any data not requested (or previously timed out)
|
|
|
|
|
req := active[pack.PeerId()] |
|
|
|
|
if req == nil { |
|
|
|
|
log.Debug("Unrequested node data", "peer", pack.PeerId(), "len", pack.Items()) |
|
|
|
@ -182,7 +182,7 @@ func (d *Downloader) runStateSync(s *stateSync) *stateSync { |
|
|
|
|
case req := <-d.trackStateReq: |
|
|
|
|
// If an active request already exists for this peer, we have a problem. In
|
|
|
|
|
// theory the trie node schedule must never assign two requests to the same
|
|
|
|
|
// peer. In practive however, a peer might receive a request, disconnect and
|
|
|
|
|
// peer. In practice however, a peer might receive a request, disconnect and
|
|
|
|
|
// immediately reconnect before the previous times out. In this case the first
|
|
|
|
|
// request is never honored, alas we must not silently overwrite it, as that
|
|
|
|
|
// causes valid requests to go missing and sync to get stuck.
|
|
|
|
@ -228,7 +228,7 @@ type stateSync struct { |
|
|
|
|
err error // Any error hit during sync (set before completion)
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// stateTask represents a single trie node download taks, containing a set of
|
|
|
|
|
// stateTask represents a single trie node download task, containing a set of
|
|
|
|
|
// peers already attempted retrieval from to detect stalled syncs and abort.
|
|
|
|
|
type stateTask struct { |
|
|
|
|
attempts map[string]struct{} |
|
|
|
@ -333,7 +333,7 @@ func (s *stateSync) commit(force bool) error { |
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// assignTasks attempts to assing new tasks to all idle peers, either from the
|
|
|
|
|
// assignTasks attempts to assign new tasks to all idle peers, either from the
|
|
|
|
|
// batch currently being retried, or fetching new data from the trie sync itself.
|
|
|
|
|
func (s *stateSync) assignTasks() { |
|
|
|
|
// Iterate over all idle peers and try to assign them state fetches
|
|
|
|
|