Skip to content

Commit b60dec9

Browse files
committed
eth/protocols/snap: serve snap requests when possible
1 parent 88132af commit b60dec9

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

eth/protocols/snap/handler.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -493,14 +493,8 @@ func ServiceGetTrieNodesQuery(chain *core.BlockChain, req *GetTrieNodesPacket, s
493493
// We don't have the requested state available, bail out
494494
return nil, nil
495495
}
496+
// The 'snap' might be nil, in which case we cannot serve storage slots.
496497
snap := chain.Snapshots().Snapshot(req.Root)
497-
if snap == nil {
498-
// We don't have the requested state snapshotted yet, bail out.
499-
// In reality we could still serve using the account and storage
500-
// tries only, but let's protect the node a bit while it's doing
501-
// snapshot generation.
502-
return nil, nil
503-
}
504498
// Retrieve trie nodes until the packet size limit is reached
505499
var (
506500
nodes [][]byte
@@ -525,6 +519,10 @@ func ServiceGetTrieNodesQuery(chain *core.BlockChain, req *GetTrieNodesPacket, s
525519

526520
default:
527521
// Storage slots requested, open the storage trie and retrieve from there
522+
if snap == nil {
523+
// We don't have the requested state snapshotted yet (or it is stale), bail out.
524+
break
525+
}
528526
account, err := snap.Account(common.BytesToHash(pathset[0]))
529527
loads++ // always account database reads, even for failures
530528
if err != nil || account == nil {

0 commit comments

Comments
 (0)