migrations

package
v0.33.15 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: AGPL-3.0 Imports: 22 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateAccountBasedMigration added in v0.33.1

func CreateAccountBasedMigration(
	log zerolog.Logger,
	nWorker int,
	migrations []AccountBasedMigration,
) func(payloads []*ledger.Payload) ([]*ledger.Payload, error)

CreateAccountBasedMigration creates a migration function that migrates the payloads account by account using the given migrations accounts are processed concurrently using the given number of workers but each account is processed sequentially by the given migrations in order. The migrations InitMigration function is called once before the migration starts And the Close function is called once after the migration finishes if the migration is a finisher.

func MigrateByAccount added in v0.29.0

func MigrateByAccount(
	log zerolog.Logger,
	nWorker int,
	allPayloads []*ledger.Payload,
	migrations []AccountBasedMigration,
) (
	[]*ledger.Payload,
	error,
)

MigrateByAccount takes migrations and all the Payloads, and returns the migrated Payloads.

func MigrateGroupConcurrently added in v0.29.0

func MigrateGroupConcurrently(
	log zerolog.Logger,
	migrations []AccountBasedMigration,
	accountGroups *util.PayloadAccountGrouping,
	nWorker int,
) ([]*ledger.Payload, error)

MigrateGroupConcurrently migrate the Payloads in the given account groups. It uses nWorker to process the Payloads concurrently. The Payloads in each account are processed sequentially by the given migrations in order.

func NoOpMigration

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

func PruneMigration added in v0.16.2

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

Types

type AccountBasedMigration added in v0.33.1

type AccountBasedMigration interface {
	InitMigration(
		log zerolog.Logger,
		allPayloads []*ledger.Payload,
		nWorkers int,
	) error
	MigrateAccount(
		ctx context.Context,
		address common.Address,
		payloads []*ledger.Payload,
	) ([]*ledger.Payload, error)
	io.Closer
}

AccountBasedMigration is an interface for migrations that migrate account by account concurrently getting all the payloads for each account at a time.

type AccountUsageMigrator added in v0.29.0

type AccountUsageMigrator struct {
	// contains filtered or unexported fields
}

AccountUsageMigrator iterates through each payload, and calculate the storage usage and update the accounts status with the updated storage usage

func (*AccountUsageMigrator) Close added in v0.33.1

func (m *AccountUsageMigrator) Close() error

func (*AccountUsageMigrator) InitMigration added in v0.33.1

func (m *AccountUsageMigrator) InitMigration(
	log zerolog.Logger,
	_ []*ledger.Payload,
	_ int,
) error

func (*AccountUsageMigrator) MigrateAccount added in v0.33.1

func (m *AccountUsageMigrator) MigrateAccount(
	_ context.Context,
	address common.Address,
	payloads []*ledger.Payload,
) ([]*ledger.Payload, error)

type AccountsAtreeLedger added in v0.23.2

type AccountsAtreeLedger struct {
	Accounts environment.Accounts
}

func NewAccountsAtreeLedger added in v0.23.2

func NewAccountsAtreeLedger(accounts environment.Accounts) *AccountsAtreeLedger

func (*AccountsAtreeLedger) AllocateStorageIndex added in v0.23.2

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 added in v0.23.2

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

func (*AccountsAtreeLedger) SetValue added in v0.23.2

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

func (*AccountsAtreeLedger) ValueExists added in v0.23.2

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

type ChangeContractCodeMigration added in v0.33.1

type ChangeContractCodeMigration struct {
	// contains filtered or unexported fields
}

func (*ChangeContractCodeMigration) Close added in v0.33.1

func (*ChangeContractCodeMigration) InitMigration added in v0.33.1

func (d *ChangeContractCodeMigration) InitMigration(
	log zerolog.Logger,
	_ []*ledger.Payload,
	_ int,
) error

func (*ChangeContractCodeMigration) MigrateAccount added in v0.33.1

func (d *ChangeContractCodeMigration) MigrateAccount(
	_ context.Context,
	address common.Address,
	payloads []*ledger.Payload,
) ([]*ledger.Payload, error)

func (*ChangeContractCodeMigration) RegisterContractChange added in v0.33.1

func (d *ChangeContractCodeMigration) RegisterContractChange(
	address common.Address,
	contractName string,
	newContractCode string,
) (
	previousNewContractCode string,
)

type DeduplicateContractNamesMigration added in v0.33.1

type DeduplicateContractNamesMigration struct {
	// contains filtered or unexported fields
}

DeduplicateContractNamesMigration checks if the contract names have been duplicated and removes the duplicate ones.

This migration de-syncs storage used, so it should be run before the StorageUsedMigration.

func (*DeduplicateContractNamesMigration) Close added in v0.33.1

func (*DeduplicateContractNamesMigration) InitMigration added in v0.33.1

func (d *DeduplicateContractNamesMigration) InitMigration(
	log zerolog.Logger,
	_ []*ledger.Payload,
	_ int,
) error

func (*DeduplicateContractNamesMigration) MigrateAccount added in v0.33.1

func (d *DeduplicateContractNamesMigration) MigrateAccount(
	ctx context.Context,
	address common.Address,
	payloads []*ledger.Payload,
) ([]*ledger.Payload, error)

type SystemContractChange added in v0.33.1

type SystemContractChange struct {
	Address         common.Address
	ContractName    string
	NewContractCode string
}

func NewSystemContractChange added in v0.33.1

func NewSystemContractChange(
	systemContract systemcontracts.SystemContract,
	newContractCode []byte,
) SystemContractChange

func SystemContractChanges added in v0.33.1

func SystemContractChanges(chainID flow.ChainID) []SystemContractChange

Jump to

Keyboard shortcuts

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