mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 14:16:44 +00:00
triedb/pathdb: update comment
This commit is contained in:
parent
8f9c277fe9
commit
79617eea5b
1 changed files with 26 additions and 0 deletions
|
|
@ -83,8 +83,30 @@ func newLookup(head layer, descendant func(state common.Hash, ancestor common.Ha
|
||||||
// layer specified by the stateID: fallback to the disk layer for data retrieval,
|
// layer specified by the stateID: fallback to the disk layer for data retrieval,
|
||||||
// (b) or the layer specified by the stateID is stale: reject the data retrieval.
|
// (b) or the layer specified by the stateID is stale: reject the data retrieval.
|
||||||
func (l *lookup) accountTip(accountHash common.Hash, stateID common.Hash, base common.Hash) common.Hash {
|
func (l *lookup) accountTip(accountHash common.Hash, stateID common.Hash, base common.Hash) common.Hash {
|
||||||
|
// Traverse the mutation history from latest to oldest one. Several
|
||||||
|
// scenarios are possible:
|
||||||
|
//
|
||||||
|
// Chain:
|
||||||
|
// D->C1->C2->C3->C4 (HEAD)
|
||||||
|
// ->C1'->C2'->C3'
|
||||||
|
// State:
|
||||||
|
// x: [C1, C1', C3', C3]
|
||||||
|
// y: []
|
||||||
|
//
|
||||||
|
// - (x, C4) => C3
|
||||||
|
// - (x, C3) => C3
|
||||||
|
// - (x, C2) => C1
|
||||||
|
// - (x, C3') => C3'
|
||||||
|
// - (x, C2') => C1'
|
||||||
|
// - (y, C4) => D
|
||||||
|
// - (y, C3') => D
|
||||||
|
// - (y, C0) => null
|
||||||
list := l.accounts[accountHash]
|
list := l.accounts[accountHash]
|
||||||
for i := len(list) - 1; i >= 0; i-- {
|
for i := len(list) - 1; i >= 0; i-- {
|
||||||
|
// If the current state matches the stateID, or the requested state is a
|
||||||
|
// descendant of it, return the current state as the most recent one
|
||||||
|
// containing the modified data. Otherwise, the current state may be ahead
|
||||||
|
// of the requested one or belong to a different branch.
|
||||||
if list[i] == stateID || l.descendant(stateID, list[i]) {
|
if list[i] == stateID || l.descendant(stateID, list[i]) {
|
||||||
return list[i]
|
return list[i]
|
||||||
}
|
}
|
||||||
|
|
@ -115,6 +137,10 @@ func (l *lookup) storageTip(accountHash common.Hash, slotHash common.Hash, state
|
||||||
if exists {
|
if exists {
|
||||||
list := subset[slotHash]
|
list := subset[slotHash]
|
||||||
for i := len(list) - 1; i >= 0; i-- {
|
for i := len(list) - 1; i >= 0; i-- {
|
||||||
|
// If the current state matches the stateID, or the requested state is a
|
||||||
|
// descendant of it, return the current state as the most recent one
|
||||||
|
// containing the modified data. Otherwise, the current state may be ahead
|
||||||
|
// of the requested one or belong to a different branch.
|
||||||
if list[i] == stateID || l.descendant(stateID, list[i]) {
|
if list[i] == stateID || l.descendant(stateID, list[i]) {
|
||||||
return list[i]
|
return list[i]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue