util

package
v0.33.21 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: AGPL-3.0 Imports: 18 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsServiceLevelAddress

func IsServiceLevelAddress(address common.Address) bool

IsServiceLevelAddress returns true if the given address is the service level address. Which means it's not an actual account but instead holds service lever registers.

Types

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 MigrationRuntimeInterface

type MigrationRuntimeInterface struct {
	Accounts environment.Accounts
	Programs *environment.Programs

	// GetOrLoadProgramFunc allows for injecting extra logic
	GetOrLoadProgramFunc func(location runtime.Location, load func() (*interpreter.Program, error)) (*interpreter.Program, error)
}

MigrationRuntimeInterface is a runtime interface that can be used in migrations.

func (MigrationRuntimeInterface) AccountKeysCount

func (m MigrationRuntimeInterface) AccountKeysCount(_ runtime.Address) (uint64, error)

func (MigrationRuntimeInterface) AddAccountKey

func (MigrationRuntimeInterface) AddEncodedAccountKey

func (m MigrationRuntimeInterface) AddEncodedAccountKey(_ runtime.Address, _ []byte) error

func (MigrationRuntimeInterface) AllocateStorageIndex

func (m MigrationRuntimeInterface) AllocateStorageIndex(_ []byte) (atree.StorageIndex, error)

func (MigrationRuntimeInterface) BLSAggregatePublicKeys

func (m MigrationRuntimeInterface) BLSAggregatePublicKeys(_ []*runtime.PublicKey) (*runtime.PublicKey, error)

func (MigrationRuntimeInterface) BLSAggregateSignatures

func (m MigrationRuntimeInterface) BLSAggregateSignatures(_ [][]byte) ([]byte, error)

func (MigrationRuntimeInterface) BLSVerifyPOP

func (m MigrationRuntimeInterface) BLSVerifyPOP(_ *runtime.PublicKey, _ []byte) (bool, error)

func (MigrationRuntimeInterface) ComputationUsed

func (m MigrationRuntimeInterface) ComputationUsed() (uint64, error)

func (MigrationRuntimeInterface) CreateAccount

func (m MigrationRuntimeInterface) CreateAccount(_ runtime.Address) (address runtime.Address, err error)

func (MigrationRuntimeInterface) DecodeArgument

func (m MigrationRuntimeInterface) DecodeArgument(_ []byte, _ cadence.Type) (cadence.Value, error)

func (MigrationRuntimeInterface) EmitEvent

func (MigrationRuntimeInterface) GenerateAccountID

func (m MigrationRuntimeInterface) GenerateAccountID(_ common.Address) (uint64, error)

func (MigrationRuntimeInterface) GenerateUUID

func (m MigrationRuntimeInterface) GenerateUUID() (uint64, error)

func (MigrationRuntimeInterface) GetAccountAvailableBalance

func (m MigrationRuntimeInterface) GetAccountAvailableBalance(_ common.Address) (value uint64, err error)

func (MigrationRuntimeInterface) GetAccountBalance

func (m MigrationRuntimeInterface) GetAccountBalance(_ common.Address) (value uint64, err error)

func (MigrationRuntimeInterface) GetAccountContractCode

func (m MigrationRuntimeInterface) GetAccountContractCode(
	l common.AddressLocation,
) (code []byte, err error)

func (MigrationRuntimeInterface) GetAccountContractNames

func (m MigrationRuntimeInterface) GetAccountContractNames(_ runtime.Address) ([]string, error)

func (MigrationRuntimeInterface) GetAccountKey

func (MigrationRuntimeInterface) GetBlockAtHeight

func (m MigrationRuntimeInterface) GetBlockAtHeight(_ uint64) (block runtime.Block, exists bool, err error)

func (MigrationRuntimeInterface) GetCode

func (m MigrationRuntimeInterface) GetCode(location runtime.Location) ([]byte, error)

func (MigrationRuntimeInterface) GetComputationLimit

func (m MigrationRuntimeInterface) GetComputationLimit() uint64

func (MigrationRuntimeInterface) GetCurrentBlockHeight

func (m MigrationRuntimeInterface) GetCurrentBlockHeight() (uint64, error)

func (MigrationRuntimeInterface) GetInterpreterSharedState

func (m MigrationRuntimeInterface) GetInterpreterSharedState() *interpreter.SharedState

func (MigrationRuntimeInterface) GetOrLoadProgram

func (m MigrationRuntimeInterface) GetOrLoadProgram(location runtime.Location, load func() (*interpreter.Program, error)) (*interpreter.Program, error)

func (MigrationRuntimeInterface) GetSigningAccounts

func (m MigrationRuntimeInterface) GetSigningAccounts() ([]runtime.Address, error)

func (MigrationRuntimeInterface) GetStorageCapacity

func (m MigrationRuntimeInterface) GetStorageCapacity(_ runtime.Address) (value uint64, err error)

func (MigrationRuntimeInterface) GetStorageUsed

func (m MigrationRuntimeInterface) GetStorageUsed(_ runtime.Address) (value uint64, err error)

func (MigrationRuntimeInterface) GetValue

func (m MigrationRuntimeInterface) GetValue(_, _ []byte) (value []byte, err error)

func (MigrationRuntimeInterface) Hash

func (MigrationRuntimeInterface) ImplementationDebugLog

func (m MigrationRuntimeInterface) ImplementationDebugLog(_ string) error

func (MigrationRuntimeInterface) InteractionUsed

func (m MigrationRuntimeInterface) InteractionUsed() (uint64, error)

func (MigrationRuntimeInterface) MemoryUsed

func (m MigrationRuntimeInterface) MemoryUsed() (uint64, error)

func (MigrationRuntimeInterface) MeterComputation

func (m MigrationRuntimeInterface) MeterComputation(_ common.ComputationKind, _ uint) error

func (MigrationRuntimeInterface) MeterMemory

func (MigrationRuntimeInterface) ProgramLog

func (m MigrationRuntimeInterface) ProgramLog(_ string) error

func (MigrationRuntimeInterface) ReadRandom

func (m MigrationRuntimeInterface) ReadRandom([]byte) error

func (MigrationRuntimeInterface) RecordTrace

func (MigrationRuntimeInterface) RemoveAccountContractCode

func (m MigrationRuntimeInterface) RemoveAccountContractCode(common.AddressLocation) (err error)

func (MigrationRuntimeInterface) ResolveLocation

func (m MigrationRuntimeInterface) ResolveLocation(
	identifiers []runtime.Identifier,
	location runtime.Location,
) ([]runtime.ResolvedLocation, error)

func (MigrationRuntimeInterface) ResourceOwnerChanged

func (MigrationRuntimeInterface) RevokeAccountKey

func (m MigrationRuntimeInterface) RevokeAccountKey(_ runtime.Address, _ int) (*runtime.AccountKey, error)

func (MigrationRuntimeInterface) RevokeEncodedAccountKey

func (m MigrationRuntimeInterface) RevokeEncodedAccountKey(_ runtime.Address, _ int) (publicKey []byte, err error)

func (MigrationRuntimeInterface) SetComputationUsed

func (m MigrationRuntimeInterface) SetComputationUsed(_ uint64) error

func (MigrationRuntimeInterface) SetInterpreterSharedState

func (m MigrationRuntimeInterface) SetInterpreterSharedState(_ *interpreter.SharedState)

func (MigrationRuntimeInterface) SetValue

func (m MigrationRuntimeInterface) SetValue(_, _, _ []byte) (err error)

func (MigrationRuntimeInterface) UpdateAccountContractCode

func (m MigrationRuntimeInterface) UpdateAccountContractCode(_ common.AddressLocation, _ []byte) (err error)

func (MigrationRuntimeInterface) ValidatePublicKey

func (m MigrationRuntimeInterface) ValidatePublicKey(_ *runtime.PublicKey) error

func (MigrationRuntimeInterface) ValueExists

func (m MigrationRuntimeInterface) ValueExists(_, _ []byte) (exists bool, err error)

func (MigrationRuntimeInterface) VerifySignature

type NopMemoryGauge

type NopMemoryGauge struct{}

NopMemoryGauge is a no-op implementation of the MemoryGauge interface

func (NopMemoryGauge) MeterMemory

func (n NopMemoryGauge) MeterMemory(common.MemoryUsage) error

type NopMeter

type NopMeter struct{}

NopMeter is a meter that does nothing. It can be used in migrations.

func (NopMeter) ComputationAvailable

func (n NopMeter) ComputationAvailable(_ common.ComputationKind, _ uint) bool

func (NopMeter) ComputationIntensities

func (n NopMeter) ComputationIntensities() meter.MeteredComputationIntensities

func (NopMeter) ComputationUsed

func (n NopMeter) ComputationUsed() (uint64, error)

func (NopMeter) InteractionUsed

func (n NopMeter) InteractionUsed() (uint64, error)

func (NopMeter) MemoryUsed

func (n NopMeter) MemoryUsed() (uint64, error)

func (NopMeter) MeterComputation

func (n NopMeter) MeterComputation(_ common.ComputationKind, _ uint) error

func (NopMeter) MeterEmittedEvent

func (n NopMeter) MeterEmittedEvent(_ uint64) error

func (NopMeter) MeterMemory

func (n NopMeter) MeterMemory(_ common.MemoryUsage) error

func (NopMeter) TotalEmittedEventBytes

func (n NopMeter) TotalEmittedEventBytes() uint64

type PayloadAccountGroup

type PayloadAccountGroup struct {
	Address  common.Address
	Payloads []*ledger.Payload
}

PayloadAccountGroup is a grouping of payloads by account

type PayloadAccountGrouping

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

PayloadAccountGrouping is a grouping of payloads by account.

func GroupPayloadsByAccount

func GroupPayloadsByAccount(
	log zerolog.Logger,
	payloads []*ledger.Payload,
	nWorkers int,
) *PayloadAccountGrouping

GroupPayloadsByAccount takes a list of payloads and groups them by account. it uses nWorkers to sort the payloads by address and find the start and end indexes of each account.

func (*PayloadAccountGrouping) AllPayloadsCount

func (g *PayloadAccountGrouping) AllPayloadsCount() int

AllPayloadsCount the number of payloads

func (*PayloadAccountGrouping) Len

func (g *PayloadAccountGrouping) Len() int

Len returns the number of accounts

func (*PayloadAccountGrouping) Next

Next returns the next account group. If there is no more account group, it returns nil. The zero address is used for global Payloads and is not an actual account.

type PayloadSnapshot

type PayloadSnapshot struct {
	Payloads map[flow.RegisterID]*ledger.Payload
}

func NewPayloadSnapshot

func NewPayloadSnapshot(payloads []*ledger.Payload) (*PayloadSnapshot, error)

func (PayloadSnapshot) Get

type PayloadsReadonlyLedger

type PayloadsReadonlyLedger struct {
	Snapshot *PayloadSnapshot

	AllocateStorageIndexFunc func(owner []byte) (atree.StorageIndex, error)
	SetValueFunc             func(owner, key, value []byte) (err error)
}

func NewPayloadsReadonlyLedger

func NewPayloadsReadonlyLedger(snapshot *PayloadSnapshot) *PayloadsReadonlyLedger

func (*PayloadsReadonlyLedger) AllocateStorageIndex

func (p *PayloadsReadonlyLedger) AllocateStorageIndex(owner []byte) (atree.StorageIndex, error)

func (*PayloadsReadonlyLedger) GetValue

func (p *PayloadsReadonlyLedger) GetValue(owner, key []byte) (value []byte, err error)

func (*PayloadsReadonlyLedger) SetValue

func (p *PayloadsReadonlyLedger) SetValue(owner, key, value []byte) (err error)

func (*PayloadsReadonlyLedger) ValueExists

func (p *PayloadsReadonlyLedger) ValueExists(owner, key []byte) (exists bool, err error)

Jump to

Keyboard shortcuts

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