mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-17 18:30:45 +00:00
trie/bintrie: implement updateBatch
This commit is contained in:
parent
a826f0c6f9
commit
128a491ec9
1 changed files with 25 additions and 4 deletions
|
|
@ -452,10 +452,31 @@ func (t *BinaryTrie) Witness() map[string][]byte {
|
||||||
return t.tracer.Values()
|
return t.tracer.Values()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *BinaryTrie) UpdateStorageBatch(_ common.Address, keys [][]byte, values [][]byte) error {
|
// UpdateStorageBatch updates a list of storage slots sequentially.
|
||||||
panic("not implemented")
|
func (t *BinaryTrie) UpdateStorageBatch(address common.Address, keys [][]byte, values [][]byte) error {
|
||||||
|
if len(keys) != len(values) {
|
||||||
|
return fmt.Errorf("keys and values length mismatch: %d != %d", len(keys), len(values))
|
||||||
|
}
|
||||||
|
for i, key := range keys {
|
||||||
|
if err := t.UpdateStorage(address, key, values[i]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *BinaryTrie) UpdateAccountBatch(addresses []common.Address, accounts []*types.StateAccount, _ []int) error {
|
// UpdateAccountBatch updates a list of accounts sequentially.
|
||||||
panic("not implemented")
|
func (t *BinaryTrie) UpdateAccountBatch(addresses []common.Address, accounts []*types.StateAccount, codeLens []int) error {
|
||||||
|
if len(addresses) != len(accounts) {
|
||||||
|
return fmt.Errorf("addresses and accounts length mismatch: %d != %d", len(addresses), len(accounts))
|
||||||
|
}
|
||||||
|
if len(addresses) != len(codeLens) {
|
||||||
|
return fmt.Errorf("addresses and code length mismatch: %d != %d", len(addresses), len(codeLens))
|
||||||
|
}
|
||||||
|
for i, addr := range addresses {
|
||||||
|
if err := t.UpdateAccount(addr, accounts[i], codeLens[i]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue