Documentation
¶
Index ¶
- Variables
- func CanPopulateStruct(dstType reflect.Type, srcType reflect.Type) error
- func ConvertStruct(dst interface{}, src interface{}) error
- func PopulateStruct(dst interface{}, src interface{}) error
- func RunBlockTicks(c Core)
- func RunSingleTick(c Core)
- type Action
- type ActionBatch
- type ActionSchema
- type ActionSchemas
- func (a ActionSchemas) ABI() *abi.ABI
- func (a ActionSchemas) ActionIdFromAction(action Action) (ValidActionId, bool)
- func (a ActionSchemas) ActionIdFromName(name string) (ValidActionId, bool)
- func (a *ActionSchemas) ActionToCalldata(action Action) ([]byte, error)
- func (a *ActionSchemas) ActionToLog(action Action) (types.Log, error)
- func (a *ActionSchemas) CalldataToAction(calldata []byte) (Action, error)
- func (a *ActionSchemas) DecodeAction(actionId ValidActionId, data []byte) (Action, error)
- func (a *ActionSchemas) EncodeAction(action Action) (ValidActionId, []byte, error)
- func (a *ActionSchemas) ExecuteAction(action Action, target Core) error
- func (a ActionSchemas) GetActionSchema(actionId ValidActionId) ActionSchema
- func (a *ActionSchemas) LogToAction(log types.Log) (Action, error)
- func (a ActionSchemas) NewActionId(id RawIdType) (ValidActionId, bool)
- type ArchSchemas
- type BaseCore
- func (b *BaseCore) BlockNumber() uint64
- func (b *BaseCore) Datastore() lib.Datastore
- func (b *BaseCore) ExpectTick() bool
- func (b *BaseCore) InBlockTickIndex() uint64
- func (b *BaseCore) KV() lib.KeyValueStore
- func (b *BaseCore) Rebasing() bool
- func (b *BaseCore) SetBlockNumber(blockNumber uint64)
- func (b *BaseCore) SetInBlockTickIndex(index uint64)
- func (b *BaseCore) SetKV(kv lib.KeyValueStore)
- func (b *BaseCore) SetRebasing(rebasing bool)
- func (b *BaseCore) Tick()
- func (b *BaseCore) TicksPerBlock() uint64
- type CanonicalTickAction
- type Core
- type ISetRebasing
- type RawIdType
- type TableSchema
- type TableSchemas
- func (a TableSchemas) ABI() *abi.ABI
- func (t TableSchemas) GetTableSchema(tableId ValidTableId) TableSchema
- func (t TableSchemas) NewTableId(id RawIdType) (ValidTableId, bool)
- func (t TableSchemas) Read(datastore lib.Datastore, tableId ValidTableId, keys ...interface{}) (interface{}, error)
- func (t *TableSchemas) ReadPacked(datastore lib.Datastore, calldata []byte) ([]byte, error)
- func (t TableSchemas) TableIdFromName(name string) (ValidTableId, bool)
- func (t *TableSchemas) TargetTableId(calldata []byte) (ValidTableId, bool)
- type ValidActionId
- type ValidTableId
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidAction = errors.New("invalid action") // ErrInvalidActionId = errors.New("invalid action ID") // ErrInvalidTableId = errors.New("invalid table ID") ErrCalldataIsNotTableRead = errors.New("calldata is not a table read operation") )
Functions ¶
func CanPopulateStruct ¶
CanPopulateStruct returns an error if it is not possible to populate a struct with the values returned by the Get<field name> methods in src.
func ConvertStruct ¶
func ConvertStruct(dst interface{}, src interface{}) error
ConvertStruct copies the fields from src to dst if they have the same name and type. All fields in dst must be set.
func PopulateStruct ¶
func PopulateStruct(dst interface{}, src interface{}) error
PopulateStruct sets all the fields in dst to the values returned by the Get<field name> methods in src.
func RunBlockTicks ¶
func RunBlockTicks(c Core)
func RunSingleTick ¶
func RunSingleTick(c Core)
Types ¶
type ActionBatch ¶
Holds all the actions included to a specific core in a specific block
func NewActionBatch ¶
func NewActionBatch(blockNumber uint64, actions []Action) ActionBatch
NewActionBatch creates a new ActionBatch instance.
func (ActionBatch) Len ¶
func (a ActionBatch) Len() int
Len returns the number of actions in the batch.
type ActionSchema ¶
type ActionSchema struct {
// contains filtered or unexported fields
}
type ActionSchemas ¶
type ActionSchemas struct {
// contains filtered or unexported fields
}
func NewActionSchemas ¶
func NewActionSchemas( abi *abi.ABI, schemas []datamod.TableSchema, types map[string]reflect.Type, ) (ActionSchemas, error)
NewActionSchemas creates a new ActionSchemas instance.
func NewActionSchemasFromRaw ¶
func NewActionSchemasFromRaw( abiJson string, schemasJson string, types map[string]reflect.Type, ) (ActionSchemas, error)
NewActionSchemasFromRaw creates a new ActionSchemas instance from raw JSON strings.
func (ActionSchemas) ActionIdFromAction ¶
func (a ActionSchemas) ActionIdFromAction(action Action) (ValidActionId, bool)
ActionIdFromAction returns the action ID of the given action.
func (ActionSchemas) ActionIdFromName ¶
func (a ActionSchemas) ActionIdFromName(name string) (ValidActionId, bool)
ActionIdFromName returns the action ID of the action with the given name.
func (*ActionSchemas) ActionToCalldata ¶
func (a *ActionSchemas) ActionToCalldata(action Action) ([]byte, error)
ActionToCalldata converts an action to calldata. The same encoding is used for log data.
func (*ActionSchemas) ActionToLog ¶
func (a *ActionSchemas) ActionToLog(action Action) (types.Log, error)
ActionToLog converts an action to a log.
func (*ActionSchemas) CalldataToAction ¶
func (a *ActionSchemas) CalldataToAction(calldata []byte) (Action, error)
CalldataToAction converts calldata to an action.
func (*ActionSchemas) DecodeAction ¶
func (a *ActionSchemas) DecodeAction(actionId ValidActionId, data []byte) (Action, error)
DecodeAction decodes the given calldata into an action.
func (*ActionSchemas) EncodeAction ¶
func (a *ActionSchemas) EncodeAction(action Action) (ValidActionId, []byte, error)
EncodeAction encodes an action into a byte slice.
func (*ActionSchemas) ExecuteAction ¶
func (a *ActionSchemas) ExecuteAction(action Action, target Core) error
ExecuteAction executes the given action on the given target.
func (ActionSchemas) GetActionSchema ¶
func (a ActionSchemas) GetActionSchema(actionId ValidActionId) ActionSchema
GetActionSchema returns the schema of the action with the given ID.
func (*ActionSchemas) LogToAction ¶
func (a *ActionSchemas) LogToAction(log types.Log) (Action, error)
LogToAction converts a log to an action.
func (ActionSchemas) NewActionId ¶
func (a ActionSchemas) NewActionId(id RawIdType) (ValidActionId, bool)
NewActionId wraps a valid ID in a ValidActionId.
type ArchSchemas ¶
type ArchSchemas struct { Actions ActionSchemas Tables TableSchemas }
type BaseCore ¶
type BaseCore struct {
// contains filtered or unexported fields
}
func (*BaseCore) BlockNumber ¶
func (*BaseCore) ExpectTick ¶
func (*BaseCore) InBlockTickIndex ¶
func (*BaseCore) KV ¶
func (b *BaseCore) KV() lib.KeyValueStore
func (*BaseCore) SetBlockNumber ¶
func (*BaseCore) SetInBlockTickIndex ¶
func (*BaseCore) SetKV ¶
func (b *BaseCore) SetKV(kv lib.KeyValueStore)
func (*BaseCore) SetRebasing ¶
func (*BaseCore) TicksPerBlock ¶
type CanonicalTickAction ¶
type CanonicalTickAction struct{}
type Core ¶
type Core interface { SetKV(kv lib.KeyValueStore) // Set the key-value store KV() lib.KeyValueStore // Get the key-value store // ExecuteAction(Action) error // Execute the given action SetBlockNumber(uint64) // Set the block number BlockNumber() uint64 // Get the block number // RunSingleTick() // Run a single tick // RunBlockTicks() // Run all ticks in a block Tick() // Run a single tick TicksPerBlock() uint64 // Get the number of ticks per block ExpectTick() bool // Check if a tick is expected SetInBlockTickIndex(uint64) // Set the in-block tick index InBlockTickIndex() uint64 // Get the in-block tick index }
type ISetRebasing ¶
type ISetRebasing interface {
SetRebasing(bool)
}
type TableSchema ¶
type TableSchema struct {
// contains filtered or unexported fields
}
type TableSchemas ¶
type TableSchemas struct {
// contains filtered or unexported fields
}
func NewTableSchemas ¶
func NewTableSchemas( abi *abi.ABI, schemas []datamod.TableSchema, types map[string]reflect.Type, getters map[string]interface{}, ) (TableSchemas, error)
NewTableSchemas creates a new TableSchemas instance.
func NewTableSchemasFromRaw ¶
func NewTableSchemasFromRaw( abiJson string, schemasJson string, types map[string]reflect.Type, getters map[string]interface{}, ) (TableSchemas, error)
NewTableSchemasFromRaw creates a new TableSchemas instance from raw JSON strings.
func (TableSchemas) GetTableSchema ¶
func (t TableSchemas) GetTableSchema(tableId ValidTableId) TableSchema
GetTableSchema returns the schema of the table with the given ID.
func (TableSchemas) NewTableId ¶
func (t TableSchemas) NewTableId(id RawIdType) (ValidTableId, bool)
NewTableId wraps a valid ID in a ValidTableId.
func (TableSchemas) Read ¶
func (t TableSchemas) Read(datastore lib.Datastore, tableId ValidTableId, keys ...interface{}) (interface{}, error)
read reads a row from the datastore.
func (*TableSchemas) ReadPacked ¶
ReadPacked reads a row from the datastore and packs it into an ABI-encoded byte slice.
func (TableSchemas) TableIdFromName ¶
func (t TableSchemas) TableIdFromName(name string) (ValidTableId, bool)
TableIdFromName returns the table ID for the given name, if valid.
func (*TableSchemas) TargetTableId ¶
func (t *TableSchemas) TargetTableId(calldata []byte) (ValidTableId, bool)
TableIdFromCalldata returns the table ID of the table targeted by the given calldata. If the calldata does not encode a table read, the second return value is false.
type ValidActionId ¶
type ValidActionId struct {
// contains filtered or unexported fields
}
type ValidTableId ¶
type ValidTableId struct {
// contains filtered or unexported fields
}