Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInternal raised on any unexpected error due to internal conditions. // Most likely due to the disk failures. ErrInternal = errors.New("internal") // ErrMalformed raised if transaction cannot be decoded properly. ErrMalformed = errors.New("malformed tx") // ErrInvalidNonce raised due to the expected nonce mismatch. ErrInvalidNonce = errors.New("invalid nonce") // ErrNoBalance raised if transaction run out of balance during execution. ErrNoBalance = errors.New("no balance") // ErrMaxGas raised if tx consumed over MaxGas value. ErrMaxGas = errors.New("max gas") // ErrMaxSpend raised if tx transferred over MaxSpend value. ErrMaxSpend = errors.New("max spend") // ErrSpawn raised to block regular spawn. ErrSpawn = errors.New("spawn is not supported") // ErrNotSpawned raised if account is not spawned. ErrNotSpawned = errors.New("account is not spawned") )
Functions ¶
This section is empty.
Types ¶
type AccountLoader ¶
AccountLoader is an interface for loading accounts.
type AccountUpdater ¶
AccountUpdater is an interface for updating accounts.
type Address ¶
Address is an alias to types.Address.
func ComputePrincipal ¶
ComputePrincipal address as the last 20 bytes from sha256(scale(template || args)).
type Context ¶
type Context struct { Loader AccountLoader Handler Handler Template Template Account Account Header Header Args scale.Encodable // contains filtered or unexported fields }
Context serves 2 purposes: - maintains changes to the system state, that will be applied only after succeful execution - accumulates set of reusable objects and data.
func (*Context) Apply ¶
func (c *Context) Apply(updater AccountUpdater) (uint64, error)
Apply is executed if transaction was consumed.
type Handler ¶
type Handler interface { // Parse header and arguments from the payload. Parse(*Context, uint8, *scale.Decoder) (Header, scale.Encodable, error) // Init instance of the template either by decoding state into Template type or from arguments in case of spawn. Init(uint8, any, []byte) (Template, error) // Exec dispatches execution request based on the method selector. Exec(*Context, uint8, scale.Encodable) error }
Handler provides set of static templates method that are not directly attached to the state.
type StagedCache ¶
type StagedCache struct {
// contains filtered or unexported fields
}
StagedCache is a passthrough cache for accounts state and enforces order for updated accounts.
func NewStagedCache ¶
func NewStagedCache(db sql.Executor) *StagedCache
NewStagedCache returns instance of the staged cache.
func (*StagedCache) Get ¶
func (ss *StagedCache) Get(address Address) (Account, error)
Get a copy of the Account state for the address.
func (*StagedCache) IterateChanged ¶
func (ss *StagedCache) IterateChanged(f func(*Account) bool)
IterateChanged accounts in the order they were updated.
func (*StagedCache) Update ¶
func (ss *StagedCache) Update(account Account) error
Update cache with a copy of the account state.
type Template ¶
type Template interface { // Template needs to implement scale.Encodable as mutable and immutable state will be stored as a blob of bytes. scale.Encodable // MaxSpend decodes MaxSpend value for the transaction. Transaction will fail // if it spends more than that. MaxSpend(uint8, any) (uint64, error) // Verify security of the transaction. Verify(*Context, []byte) bool }
Template is a concrete Template type initialized with mutable and immutable state.