aboutsummaryrefslogtreecommitdiffstats
path: root/trie/sync.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2016-10-31 19:55:12 +0800
committerPéter Szilágyi <peterke@gmail.com>2016-10-31 20:19:14 +0800
commit90b16a3e85d82241f4505a7db0f95c2f312642a6 (patch)
tree9b8e11b1127bf96e19599a1f610684bb9d67d06f /trie/sync.go
parentb8dec948d4d7d8257e63aeecf982c25aeec9a180 (diff)
downloaddexon-90b16a3e85d82241f4505a7db0f95c2f312642a6.tar.gz
dexon-90b16a3e85d82241f4505a7db0f95c2f312642a6.tar.zst
dexon-90b16a3e85d82241f4505a7db0f95c2f312642a6.zip
core/state, eth/downloader, trie: reset fast-failure on progress
Diffstat (limited to 'trie/sync.go')
-rw-r--r--trie/sync.go18
1 files changed, 12 insertions, 6 deletions
diff --git a/trie/sync.go b/trie/sync.go
index 58b8a1fb6..2158ab750 100644
--- a/trie/sync.go
+++ b/trie/sync.go
@@ -142,34 +142,40 @@ func (s *TrieSync) Missing(max int) []common.Hash {
return requests
}
-// Process injects a batch of retrieved trie nodes data.
-func (s *TrieSync) Process(results []SyncResult) (int, error) {
+// Process injects a batch of retrieved trie nodes data, returning if something
+// was committed to the database and also the index of an entry if processing of
+// it failed.
+func (s *TrieSync) Process(results []SyncResult) (bool, int, error) {
+ committed := false
+
for i, item := range results {
// If the item was not requested, bail out
request := s.requests[item.Hash]
if request == nil {
- return i, ErrNotRequested
+ return committed, i, ErrNotRequested
}
// If the item is a raw entry request, commit directly
if request.raw {
request.data = item.Data
s.commit(request, nil)
+ committed = true
continue
}
// Decode the node data content and update the request
node, err := decodeNode(item.Hash[:], item.Data, 0)
if err != nil {
- return i, err
+ return committed, i, err
}
request.data = item.Data
// Create and schedule a request for all the children nodes
requests, err := s.children(request, node)
if err != nil {
- return i, err
+ return committed, i, err
}
if len(requests) == 0 && request.deps == 0 {
s.commit(request, nil)
+ committed = true
continue
}
request.deps += len(requests)
@@ -177,7 +183,7 @@ func (s *TrieSync) Process(results []SyncResult) (int, error) {
s.schedule(child)
}
}
- return 0, nil
+ return committed, 0, nil
}
// Pending returns the number of state entries currently pending for download.