mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 13:16:42 +00:00
polish code
This commit is contained in:
parent
a78978c430
commit
06c7dddd3d
2 changed files with 40 additions and 2 deletions
|
|
@ -241,6 +241,44 @@ func ReadStateHistory(db ethdb.AncientReaderOp, id uint64) ([]byte, []byte, []by
|
||||||
return meta, accountIndex, storageIndex, accountData, storageData, nil
|
return meta, accountIndex, storageIndex, accountData, storageData, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ReadAccountHistory retrieves account-related data from state history.
|
||||||
|
func ReadAccountHistory(db ethdb.AncientReaderOp, id uint64) ([]byte, []byte, []byte, error) {
|
||||||
|
meta, err := db.Ancient(stateHistoryMeta, id-1)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, nil, err
|
||||||
|
}
|
||||||
|
accountIndex, err := db.Ancient(stateHistoryAccountIndex, id-1)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, nil, err
|
||||||
|
}
|
||||||
|
accountData, err := db.Ancient(stateHistoryAccountData, id-1)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, nil, err
|
||||||
|
}
|
||||||
|
return meta, accountIndex, accountData, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadStorageHistory retrieves storage-related data from state history.
|
||||||
|
func ReadStorageHistory(db ethdb.AncientReaderOp, id uint64) ([]byte, []byte, []byte, []byte, error) {
|
||||||
|
meta, err := db.Ancient(stateHistoryMeta, id-1)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, nil, nil, err
|
||||||
|
}
|
||||||
|
accountIndex, err := db.Ancient(stateHistoryAccountIndex, id-1)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, nil, nil, err
|
||||||
|
}
|
||||||
|
storageIndex, err := db.Ancient(stateHistoryStorageIndex, id-1)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, nil, nil, err
|
||||||
|
}
|
||||||
|
storageData, err := db.Ancient(stateHistoryStorageData, id-1)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, nil, nil, err
|
||||||
|
}
|
||||||
|
return meta, accountIndex, storageIndex, storageData, nil
|
||||||
|
}
|
||||||
|
|
||||||
// ReadStateHistoryList retrieves a list of state histories from database with
|
// ReadStateHistoryList retrieves a list of state histories from database with
|
||||||
// specific range. Compute the position of state history in freezer by minus one
|
// specific range. Compute the position of state history in freezer by minus one
|
||||||
// since the id of first state history starts from one(zero for initial state).
|
// since the id of first state history starts from one(zero for initial state).
|
||||||
|
|
|
||||||
|
|
@ -732,7 +732,7 @@ func readStateHistory(reader ethdb.AncientReader, id uint64) (*stateHistory, err
|
||||||
|
|
||||||
// readAccountHistory reads account state history
|
// readAccountHistory reads account state history
|
||||||
func readAccountHistory(reader ethdb.AncientReader, id uint64, targetAddr common.Address) (*stateHistory, error) {
|
func readAccountHistory(reader ethdb.AncientReader, id uint64, targetAddr common.Address) (*stateHistory, error) {
|
||||||
mData, accountIndexes, _, accountData, _, err := rawdb.ReadStateHistory(reader, id)
|
mData, accountIndexes, accountData, err := rawdb.ReadAccountHistory(reader, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -749,7 +749,7 @@ func readAccountHistory(reader ethdb.AncientReader, id uint64, targetAddr common
|
||||||
|
|
||||||
// readSlotHistory reads slot state history
|
// readSlotHistory reads slot state history
|
||||||
func readSlotHistory(reader ethdb.AncientReader, id uint64, targetAddr common.Address, targetSlot common.Hash) (*stateHistory, error) {
|
func readSlotHistory(reader ethdb.AncientReader, id uint64, targetAddr common.Address, targetSlot common.Hash) (*stateHistory, error) {
|
||||||
mData, accountIndexes, storageIndexes, _, storageData, err := rawdb.ReadStateHistory(reader, id)
|
mData, accountIndexes, storageIndexes, storageData, err := rawdb.ReadStorageHistory(reader, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue