migrations

package
v0.29.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2023 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KeyToRegisterID

func KeyToRegisterID(key ledger.Key) (flow.RegisterID, error)

func MigrateAccountUsage

func MigrateAccountUsage(payloads []ledger.Payload, nWorker int) ([]ledger.Payload, error)

func MigrateByAccount

func MigrateByAccount(migrator AccountMigrator, allPayloads []ledger.Payload, nWorker int) (
	[]ledger.Payload, error)

MigrateByAccount teaks a migrator function and all the payloads, and return the migrated payloads

func MigrateGroupConcurrently

func MigrateGroupConcurrently(
	migrator AccountMigrator,
	payloadsByAccount map[string][]ledger.Payload,
	nWorker int,
) (
	[]ledger.Payload, error)

MigrateGroupConcurrently migrate the payloads in the given payloadsByAccount map which using the migrator It's similar to MigrateGroupSequentially, except it will migrate different groups concurrently

func MigrateGroupSequentially

func MigrateGroupSequentially(
	migrator AccountMigrator,
	payloadsByAccount map[string][]ledger.Payload,
) (
	[]ledger.Payload, error)

MigrateGroupSequentially migrate the payloads in the given payloadsByAccount map which using the migrator

func NoOpMigration

func NoOpMigration(p []ledger.Payload) ([]ledger.Payload, error)

func PayloadToAccount

func PayloadToAccount(p ledger.Payload) (string, bool, error)

PayloadToAccount takes a payload and return: - (address, true, nil) if the payload is for an account, the account address is returned - ("", false, nil) if the payload is not for an account - ("", false, err) if running into any exception

func PruneMigration

func PruneMigration(payload []ledger.Payload) ([]ledger.Payload, error)

PruneMigration removes all the payloads with empty value this prunes the trie for values that has been deleted

func StorageFeesMigration

func StorageFeesMigration(payload []ledger.Payload) ([]ledger.Payload, error)

iterates through registers keeping a map of register sizes after it has reached the end it add storage used and storage capacity for each address

Types

type AccountMigrator

type AccountMigrator interface {
	MigratePayloads(account string, payloads []ledger.Payload) ([]ledger.Payload, error)
}

AccountMigrator takes all the payloads that belong to the given account and return the migrated payloads

type AccountUsageMigrator

type AccountUsageMigrator struct{}

func (AccountUsageMigrator) MigratePayloads

func (m AccountUsageMigrator) MigratePayloads(account string, payloads []ledger.Payload) ([]ledger.Payload, error)

AccountUsageMigrator iterate through each payload, and calculate the storage usage and update the accoutns status with the updated storage usage

type AccountsAtreeLedger

type AccountsAtreeLedger struct {
	Accounts environment.Accounts
}

func NewAccountsAtreeLedger

func NewAccountsAtreeLedger(accounts environment.Accounts) *AccountsAtreeLedger

func (*AccountsAtreeLedger) AllocateStorageIndex

func (a *AccountsAtreeLedger) AllocateStorageIndex(owner []byte) (atree.StorageIndex, error)

AllocateStorageIndex allocates new storage index under the owner accounts to store a new register

func (*AccountsAtreeLedger) GetValue

func (a *AccountsAtreeLedger) GetValue(owner, key []byte) ([]byte, error)

func (*AccountsAtreeLedger) SetValue

func (a *AccountsAtreeLedger) SetValue(owner, key, value []byte) error

func (*AccountsAtreeLedger) ValueExists

func (a *AccountsAtreeLedger) ValueExists(owner, key []byte) (exists bool, err error)

type PayloadGroup

type PayloadGroup struct {
	NonAccountPayloads []ledger.Payload
	Accounts           map[string][]ledger.Payload
}

PayloadGroup groups payloads by account. For global payloads, it's stored under NonAccountPayloads field

func PayloadGrouping

func PayloadGrouping(groups *PayloadGroup, payload ledger.Payload) (*PayloadGroup, error)

PayloadGrouping is a reducer function that adds the given payload to the corresponding group under its account

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL