core/state: move state account to core/types + abstracted "write account to trie" (#23567)
* core/state: abstracted "write account to trie" method * fix appveyor build * Apply suggestions from code review Co-authored-by: Martin Holst Swende <martin@swende.se> * review feedback * core/state/accounts: move Account to core/types * core/types: rename Account -> StateAccount * core/state: restore EncodeRLP for stateObject * core/types: add the missing file * more review feedback * more review feedback Co-authored-by: Martin Holst Swende <martin@swende.se> Co-authored-by: Felix Lange <fjl@twurst.com>
This commit is contained in:
@ -32,6 +32,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/core/rawdb"
|
||||
"github.com/ethereum/go-ethereum/core/state"
|
||||
"github.com/ethereum/go-ethereum/core/state/snapshot"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/ethdb"
|
||||
"github.com/ethereum/go-ethereum/event"
|
||||
@ -125,8 +126,8 @@ type accountRequest struct {
|
||||
type accountResponse struct {
|
||||
task *accountTask // Task which this request is filling
|
||||
|
||||
hashes []common.Hash // Account hashes in the returned range
|
||||
accounts []*state.Account // Expanded accounts in the returned range
|
||||
hashes []common.Hash // Account hashes in the returned range
|
||||
accounts []*types.StateAccount // Expanded accounts in the returned range
|
||||
|
||||
cont bool // Whether the account range has a continuation
|
||||
}
|
||||
@ -2274,9 +2275,9 @@ func (s *Syncer) OnAccounts(peer SyncPeer, id uint64, hashes []common.Hash, acco
|
||||
s.scheduleRevertAccountRequest(req)
|
||||
return err
|
||||
}
|
||||
accs := make([]*state.Account, len(accounts))
|
||||
accs := make([]*types.StateAccount, len(accounts))
|
||||
for i, account := range accounts {
|
||||
acc := new(state.Account)
|
||||
acc := new(types.StateAccount)
|
||||
if err := rlp.DecodeBytes(account, acc); err != nil {
|
||||
panic(err) // We created these blobs, we must be able to decode them
|
||||
}
|
||||
@ -2740,7 +2741,7 @@ func (s *Syncer) onHealByteCodes(peer SyncPeer, id uint64, bytecodes [][]byte) e
|
||||
// Note it's not concurrent safe, please handle the concurrent issue outside.
|
||||
func (s *Syncer) onHealState(paths [][]byte, value []byte) error {
|
||||
if len(paths) == 1 {
|
||||
var account state.Account
|
||||
var account types.StateAccount
|
||||
if err := rlp.DecodeBytes(value, &account); err != nil {
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user