Documentation ¶
Index ¶
- func IsServiceEvent(event cadence.Event, chain flow.ChainID) (bool, error)
- func NewAccountPublicKey(publicKey *runtime.PublicKey, hashAlgo sema.HashAlgorithm, keyIndex int, ...) (*flow.AccountPublicKey, error)
- type AccountKeyHandler
- func (h *AccountKeyHandler) AddAccountKey(address runtime.Address, publicKey *runtime.PublicKey, ...) (*runtime.AccountKey, error)
- func (e *AccountKeyHandler) AddEncodedAccountKey(address runtime.Address, encodedPublicKey []byte) (err error)
- func (h *AccountKeyHandler) GetAccountKey(address runtime.Address, keyIndex int) (*runtime.AccountKey, error)
- func (e *AccountKeyHandler) RemoveAccountKey(address runtime.Address, keyIndex int) (encodedPublicKey []byte, err error)
- func (h *AccountKeyHandler) RevokeAccountKey(address runtime.Address, keyIndex int) (*runtime.AccountKey, error)
- type AuthorizedAccountsForContractDeploymentFunc
- type ComputationMeter
- type ComputationMeteringHandler
- type ContractHandler
- func (h *ContractHandler) Commit() ([]programs.ContractUpdateKey, error)
- func (h *ContractHandler) GetContract(address runtime.Address, name string) (code []byte, err error)
- func (h *ContractHandler) GetContractNames(address runtime.Address) (names []string, err error)
- func (h *ContractHandler) HasUpdates() bool
- func (h *ContractHandler) RemoveContract(address runtime.Address, name string, signingAccounts []runtime.Address) (err error)
- func (h *ContractHandler) Rollback() error
- func (h *ContractHandler) SetContract(address runtime.Address, name string, code []byte, ...) (err error)
- func (h *ContractHandler) UpdateKeys() []programs.ContractUpdateKey
- type EventCollection
- func (e *EventCollection) AppendEvent(event flow.Event, size uint64)
- func (e *EventCollection) AppendServiceEvent(event flow.Event, size uint64)
- func (e *EventCollection) Child() *EventCollection
- func (e *EventCollection) Events() []flow.Event
- func (e *EventCollection) Merge(other *EventCollection)
- func (e *EventCollection) ServiceEvents() []flow.Event
- func (e *EventCollection) TotalByteSize() uint64
- type EventHandler
- type MetricsHandler
- func (m *MetricsHandler) ProgramChecked(location common.Location, duration time.Duration)
- func (m *MetricsHandler) ProgramInterpreted(location common.Location, duration time.Duration)
- func (m *MetricsHandler) ProgramParsed(location common.Location, duration time.Duration)
- func (m *MetricsHandler) SetNumberOfAccounts(count uint64)
- func (m *MetricsHandler) ValueDecoded(duration time.Duration)
- func (m *MetricsHandler) ValueEncoded(duration time.Duration)
- type MetricsReporter
- type NoopMetricsReporter
- type ProgramsHandler
- type SubComputationMeter
- type UseContractAuditVoucherFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsServiceEvent ¶ added in v0.17.1
IsServiceEvent determines whether or not an emitted Cadence event is considered a service event for the given chain.
func NewAccountPublicKey ¶ added in v0.18.0
func NewAccountPublicKey(publicKey *runtime.PublicKey, hashAlgo sema.HashAlgorithm, keyIndex int, weight int, ) (*flow.AccountPublicKey, error)
NewAccountPublicKey construct an account public key given a runtime public key.
Types ¶
type AccountKeyHandler ¶ added in v0.17.6
type AccountKeyHandler struct {
// contains filtered or unexported fields
}
AccountKeyHandler handles all interaction with account keys such as get/set/revoke
func NewAccountKeyHandler ¶ added in v0.17.6
func NewAccountKeyHandler(accounts state.Accounts) *AccountKeyHandler
func (*AccountKeyHandler) AddAccountKey ¶ added in v0.17.6
func (h *AccountKeyHandler) AddAccountKey(address runtime.Address, publicKey *runtime.PublicKey, hashAlgo runtime.HashAlgorithm, weight int, ) ( *runtime.AccountKey, error, )
AddAccountKey adds a public key to an existing account.
This function returns an error if the specified account does not exist or if the key insertion fails.
func (*AccountKeyHandler) AddEncodedAccountKey ¶ added in v0.17.6
func (e *AccountKeyHandler) AddEncodedAccountKey(address runtime.Address, encodedPublicKey []byte) (err error)
AddEncodedAccountKey adds an encoded public key to an existing account.
This function returns following error * NewAccountNotFoundError - if the specified account does not exist * ValueError - if the provided encodedPublicKey is not valid public key
func (*AccountKeyHandler) GetAccountKey ¶ added in v0.17.6
func (h *AccountKeyHandler) GetAccountKey(address runtime.Address, keyIndex int) (*runtime.AccountKey, error)
GetAccountKey retrieves a public key by index from an existing account.
This function returns a nil key with no errors, if a key doesn't exist at the given index. An error is returned if the specified account does not exist, the provided index is not valid, or if the key retrieval fails.
func (*AccountKeyHandler) RemoveAccountKey ¶ added in v0.17.6
func (e *AccountKeyHandler) RemoveAccountKey(address runtime.Address, keyIndex int) (encodedPublicKey []byte, err error)
RemoveAccountKey revokes a public key by index from an existing account.
This function returns an error if the specified account does not exist, the provided key is invalid, or if key revoking fails.
func (*AccountKeyHandler) RevokeAccountKey ¶ added in v0.17.6
func (h *AccountKeyHandler) RevokeAccountKey(address runtime.Address, keyIndex int) (*runtime.AccountKey, error)
RevokeAccountKey revokes a public key by index from an existing account, and returns the revoked key.
This function returns a nil key with no errors, if a key doesn't exist at the given index. An error is returned if the specified account does not exist, the provided index is not valid, or if the key revoking fails. TODO (ramtin) do we have to return runtime.AccountKey for this method or can be separated into another method
type AuthorizedAccountsForContractDeploymentFunc ¶ added in v0.17.1
type ComputationMeter ¶ added in v0.23.2
type ComputationMeter interface { // Limit gets computation limit Limit() uint64 // AddUsed adds more computation used to the current computation used AddUsed(used uint64) error // Used gets the current computation used Used() uint64 }
ComputationMeter meters computation usage
type ComputationMeteringHandler ¶ added in v0.23.2
type ComputationMeteringHandler interface { ComputationMeter StartSubMeter(limit uint64) SubComputationMeter }
ComputationMeteringHandler handles computation metering on a transaction level
func NewComputationMeteringHandler ¶ added in v0.23.2
func NewComputationMeteringHandler(computationLimit uint64) ComputationMeteringHandler
type ContractHandler ¶
type ContractHandler struct {
// contains filtered or unexported fields
}
ContractHandler handles all interaction with smart contracts such as get/set/update it also captures all changes as deltas and only commit them when called so smart contract updates can be delayed until end of the tx execution
func NewContractHandler ¶
func NewContractHandler(accounts state.Accounts, restrictedDeploymentEnabled bool, authorizedAccounts AuthorizedAccountsForContractDeploymentFunc, useContractAuditVoucher UseContractAuditVoucherFunc) *ContractHandler
func (*ContractHandler) Commit ¶
func (h *ContractHandler) Commit() ([]programs.ContractUpdateKey, error)
func (*ContractHandler) GetContract ¶
func (*ContractHandler) GetContractNames ¶
func (h *ContractHandler) GetContractNames(address runtime.Address) (names []string, err error)
func (*ContractHandler) HasUpdates ¶
func (h *ContractHandler) HasUpdates() bool
func (*ContractHandler) RemoveContract ¶
func (*ContractHandler) Rollback ¶
func (h *ContractHandler) Rollback() error
func (*ContractHandler) SetContract ¶
func (*ContractHandler) UpdateKeys ¶
func (h *ContractHandler) UpdateKeys() []programs.ContractUpdateKey
type EventCollection ¶ added in v0.17.1
type EventCollection struct {
// contains filtered or unexported fields
}
func NewEventCollection ¶ added in v0.17.1
func NewEventCollection() *EventCollection
func (*EventCollection) AppendEvent ¶ added in v0.17.1
func (e *EventCollection) AppendEvent(event flow.Event, size uint64)
func (*EventCollection) AppendServiceEvent ¶ added in v0.17.1
func (e *EventCollection) AppendServiceEvent(event flow.Event, size uint64)
func (*EventCollection) Child ¶ added in v0.17.1
func (e *EventCollection) Child() *EventCollection
func (*EventCollection) Events ¶ added in v0.17.1
func (e *EventCollection) Events() []flow.Event
func (*EventCollection) Merge ¶ added in v0.17.1
func (e *EventCollection) Merge(other *EventCollection)
Merge merges another event collection into this event collection
func (*EventCollection) ServiceEvents ¶ added in v0.17.1
func (e *EventCollection) ServiceEvents() []flow.Event
func (*EventCollection) TotalByteSize ¶ added in v0.17.1
func (e *EventCollection) TotalByteSize() uint64
type EventHandler ¶ added in v0.17.1
type EventHandler struct {
// contains filtered or unexported fields
}
EventHandler collect events, separates out service events, and enforces event size limits
func NewEventHandler ¶ added in v0.17.1
func NewEventHandler(chain flow.Chain, eventCollectionEnabled bool, serviceEventCollectionEnabled bool, eventCollectionByteSizeLimit uint64) *EventHandler
NewEventHandler constructs a new EventHandler
func (*EventHandler) EmitEvent ¶ added in v0.17.1
func (h *EventHandler) EmitEvent(event cadence.Event, txID flow.Identifier, txIndex uint32, payer flow.Address) error
func (*EventHandler) EventCollection ¶ added in v0.17.1
func (h *EventHandler) EventCollection() *EventCollection
func (*EventHandler) Events ¶ added in v0.17.1
func (h *EventHandler) Events() []flow.Event
func (*EventHandler) ServiceEvents ¶ added in v0.17.1
func (h *EventHandler) ServiceEvents() []flow.Event
type MetricsHandler ¶ added in v0.17.6
type MetricsHandler struct { Reporter MetricsReporter TimeSpentOnParsing time.Duration TimeSpentOnChecking time.Duration TimeSpentOnInterpreting time.Duration TimeSpentOnValueEncoding time.Duration TimeSpentOnValueDecoding time.Duration }
A MetricsHandler accumulates performance metrics reported by the Cadence runtime.
func NewMetricsHandler ¶ added in v0.17.6
func NewMetricsHandler(reporter MetricsReporter) *MetricsHandler
NewMetricsHandler constructs a MetricsHandler
func (*MetricsHandler) ProgramChecked ¶ added in v0.17.6
func (m *MetricsHandler) ProgramChecked(location common.Location, duration time.Duration)
ProgramChecked captures time spent on checking a code at specific location
func (*MetricsHandler) ProgramInterpreted ¶ added in v0.17.6
func (m *MetricsHandler) ProgramInterpreted(location common.Location, duration time.Duration)
ProgramInterpreted captures time spent on interpreting a code at specific location
func (*MetricsHandler) ProgramParsed ¶ added in v0.17.6
func (m *MetricsHandler) ProgramParsed(location common.Location, duration time.Duration)
ProgramParsed captures time spent on parsing a code at specific location
func (*MetricsHandler) SetNumberOfAccounts ¶ added in v0.18.3
func (m *MetricsHandler) SetNumberOfAccounts(count uint64)
SetNumberOfAccounts captures total number of accounts on the network
func (*MetricsHandler) ValueDecoded ¶ added in v0.17.6
func (m *MetricsHandler) ValueDecoded(duration time.Duration)
ValueDecoded accumulates time spend on runtime value decoding
func (*MetricsHandler) ValueEncoded ¶ added in v0.17.6
func (m *MetricsHandler) ValueEncoded(duration time.Duration)
ValueEncoded accumulates time spend on runtime value encoding
type MetricsReporter ¶ added in v0.17.6
type MetricsReporter interface { RuntimeTransactionParsed(time.Duration) RuntimeTransactionChecked(time.Duration) RuntimeTransactionInterpreted(time.Duration) RuntimeSetNumberOfAccounts(count uint64) }
MetricsReporter captures and reports metrics to back to the execution environment it is a setup passed to the context.
type NoopMetricsReporter ¶ added in v0.17.6
type NoopMetricsReporter struct{}
NoopMetricsReporter is a MetricReporter that does nothing.
func (NoopMetricsReporter) RuntimeSetNumberOfAccounts ¶ added in v0.18.3
func (NoopMetricsReporter) RuntimeSetNumberOfAccounts(count uint64)
RuntimeSetNumberOfAccounts is a noop
func (NoopMetricsReporter) RuntimeTransactionChecked ¶ added in v0.18.3
func (NoopMetricsReporter) RuntimeTransactionChecked(time.Duration)
RuntimeTransactionChecked is a noop
func (NoopMetricsReporter) RuntimeTransactionInterpreted ¶ added in v0.18.3
func (NoopMetricsReporter) RuntimeTransactionInterpreted(time.Duration)
RuntimeTransactionInterpreted is a noop
func (NoopMetricsReporter) RuntimeTransactionParsed ¶ added in v0.18.3
func (NoopMetricsReporter) RuntimeTransactionParsed(time.Duration)
RuntimeTransactionParsed is a noop
type ProgramsHandler ¶ added in v0.15.0
type ProgramsHandler struct { Programs *programs.Programs // contains filtered or unexported fields }
ProgramsHandler manages operations using Programs storage. It's separation of concern for hostEnv Cadence contract guarantees that Get/Set methods will be called in a LIFO manner, so we use stack based approach here. During successful execution stack should be cleared naturally, making cleanup method essentially no-op. But if something goes wrong, all nested views must be merged in order to make sure they are recorded
func NewProgramsHandler ¶ added in v0.15.0
func NewProgramsHandler(programs *programs.Programs, stateHolder *state.StateHolder) *ProgramsHandler
func (*ProgramsHandler) Cleanup ¶ added in v0.15.0
func (h *ProgramsHandler) Cleanup() error
func (*ProgramsHandler) Get ¶ added in v0.15.0
func (h *ProgramsHandler) Get(location common.Location) (*interpreter.Program, bool)
func (*ProgramsHandler) Set ¶ added in v0.15.0
func (h *ProgramsHandler) Set(location common.Location, program *interpreter.Program) error
type SubComputationMeter ¶ added in v0.23.2
type SubComputationMeter interface { ComputationMeter // Discard discards this computation metering. // This resets the ComputationMeteringHandler to the previous ComputationMeter, // without updating the limit or computation used Discard() error }
SubComputationMeter meters computation usage. Currently, can only be discarded, which can be used to meter fees separately from the transaction invocation. A future expansion is to meter (and charge?) different part of the transaction separately