mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 19:50:36 +00:00
parent
6bf54c951a
commit
12c578b84d
@ -79,9 +79,10 @@ func GenerateCompositeTrieKey(addressHash common.Hash, seckey common.Hash) []byt
|
||||
// AddrHash + incarnation + KeyHash
|
||||
// For contract storage
|
||||
func GenerateCompositeStorageKey(addressHash common.Hash, incarnation uint64, seckey common.Hash) []byte {
|
||||
compositeKey := make([]byte, 0, common.HashLength+common.IncarnationLength+common.HashLength)
|
||||
compositeKey = append(compositeKey, GenerateStoragePrefix(addressHash[:], incarnation)...)
|
||||
compositeKey = append(compositeKey, seckey[:]...)
|
||||
compositeKey := make([]byte, common.HashLength+common.IncarnationLength+common.HashLength)
|
||||
copy(compositeKey, addressHash[:])
|
||||
binary.BigEndian.PutUint64(compositeKey[common.HashLength:], incarnation)
|
||||
copy(compositeKey[common.HashLength+common.IncarnationLength:], seckey[:])
|
||||
return compositeKey
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ package stagedsync
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
@ -211,16 +212,16 @@ func transformPlainStateKey(key []byte) ([]byte, error) {
|
||||
return hash[:], err
|
||||
case common.AddressLength + common.IncarnationLength + common.HashLength:
|
||||
// storage
|
||||
address, incarnation, key := dbutils.PlainParseCompositeStorageKey(key)
|
||||
addrHash, err := common.HashData(address[:])
|
||||
addrHash, err := common.HashData(key[:common.AddressLength])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
secKey, err := common.HashData(key[:])
|
||||
inc := binary.BigEndian.Uint64(key[common.AddressLength:])
|
||||
secKey, err := common.HashData(key[common.AddressLength+common.IncarnationLength:])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
compositeKey := dbutils.GenerateCompositeStorageKey(addrHash, incarnation, secKey)
|
||||
compositeKey := dbutils.GenerateCompositeStorageKey(addrHash, inc, secKey)
|
||||
return compositeKey, nil
|
||||
default:
|
||||
// no other keys are supported
|
||||
|
Loading…
Reference in New Issue
Block a user