mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-04 01:54:28 +00:00
fd77eaf86a
* 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.
70 lines
1.6 KiB
Go
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)
|
|
}
|