erigon-pulse/common/changeset/account_changeset.go
Igor Mandrigin fd77eaf86a
Staged Sync: Execution phase should use "plain state" (#548)
* introduce PlainStateReader with fallbacks

* no 10.000 changes in tests

* even less iterations

* remove even more iterations

* add `go run ./cmd/geth --syncmode staged --plainstate` flag

* fix serialization calls

* make a more sensible file default

doesn’t affect anything, because this flag is always overriden when parsing CLI. but still.
2020-05-15 08:52:45 +01:00

70 lines
1.6 KiB
Go

package changeset
import (
"github.com/ledgerwatch/turbo-geth/common"
)
/* Hashed changesets (key is a hash of common.Address) */
func NewAccountChangeSet() *ChangeSet {
return &ChangeSet{
Changes: make([]Change, 0),
keyLen: common.HashLength,
}
}
func EncodeAccounts(s *ChangeSet) ([]byte, error) {
return encodeAccounts(s)
}
func DecodeAccounts(b []byte) (*ChangeSet, error) {
h := NewAccountChangeSet()
err := decodeAccountsWithKeyLen(b, common.HashLength, h)
if err != nil {
return nil, err
}
return h, nil
}
type AccountChangeSetBytes []byte
func (b AccountChangeSetBytes) Walk(f func(k, v []byte) error) error {
return walkAccountChangeSet(b, common.HashLength, f)
}
func (b AccountChangeSetBytes) FindLast(k []byte) ([]byte, error) {
return findLastKeyInAccountChangeSet(b, k, common.HashLength)
}
/* Plain changesets (key is a common.Address) */
func NewAccountChangeSetPlain() *ChangeSet {
return &ChangeSet{
Changes: make([]Change, 0),
keyLen: common.AddressLength,
}
}
func EncodeAccountsPlain(s *ChangeSet) ([]byte, error) {
return encodeAccounts(s)
}
func DecodeAccountsPlain(b []byte) (*ChangeSet, error) {
h := NewAccountChangeSetPlain()
err := decodeAccountsWithKeyLen(b, common.AddressLength, h)
if err != nil {
return nil, err
}
return h, nil
}
type AccountChangeSetPlainBytes []byte
func (b AccountChangeSetPlainBytes) Walk(f func(k, v []byte) error) error {
return walkAccountChangeSet(b, common.AddressLength, f)
}
func (b AccountChangeSetPlainBytes) FindLast(k []byte) ([]byte, error) {
return findLastKeyInAccountChangeSet(b, k, common.AddressLength)
}