Documentation ¶
Overview ¶
package coreutil provides functions to describe interface of the core contract in a compact way
Index ¶
- Constants
- Variables
- func CoreHname(name string) iscp.Hname
- type ChainStateSync
- type ChainStateSyncImpl
- type ContractInfo
- type ContractProcessor
- func (p *ContractProcessor) GetDefaultEntryPoint() iscp.VMProcessorEntryPoint
- func (p *ContractProcessor) GetDescription() string
- func (p *ContractProcessor) GetEntryPoint(code iscp.Hname) (iscp.VMProcessorEntryPoint, bool)
- func (p *ContractProcessor) GetStateReadOnly(chainState kv.KVStoreReader) kv.KVStoreReader
- type EntryPointHandler
- type EntryPointInfo
- type Handler
- type ProcessorEntryPoint
- type StateBaseline
- type ViewEntryPointHandler
- type ViewEntryPointInfo
- type ViewHandler
Constants ¶
const ( CoreContractDefault = "_default" CoreContractRoot = "root" CoreContractAccounts = "accounts" CoreContractBlob = "blob" CoreContractEventlog = "eventlog" CoreContractBlocklog = "blocklog" CoreContractGovernance = "governance" CoreEPRotateStateController = "rotateStateController" )
names of core contracts
const ( StateVarTimestamp = "T" StateVarBlockIndex = "I" StateVarPrevStateHash = "H" ParamStateControllerAddress = "S" )
the global names used in 'blocklog' contract and in 'state' package
Variables ¶
var ( FuncFallback = Func("fallbackHandler") FuncDefaultInitializer = Func("initializer") )
var ( CoreContractDefaultHname = iscp.Hname(0) CoreContractRootHname = iscp.Hn(CoreContractRoot) CoreContractAccountsHname = iscp.Hn(CoreContractAccounts) CoreContractBlobHname = iscp.Hn(CoreContractBlob) CoreContractEventlogHname = iscp.Hn(CoreContractEventlog) CoreContractBlocklogHname = iscp.Hn(CoreContractBlocklog) CoreContractGovernanceHname = iscp.Hn(CoreContractGovernance) CoreEPRotateStateControllerHname = iscp.Hn(CoreEPRotateStateController) )
var ( StatePrefixTimestamp = string(CoreContractBlocklogHname.Bytes()) + StateVarTimestamp StatePrefixBlockIndex = string(CoreContractBlocklogHname.Bytes()) + StateVarBlockIndex StatePrefixPrevStateHash = string(CoreContractBlocklogHname.Bytes()) + StateVarPrevStateHash )
used in 'state' package as key for timestamp and block index
var ErrorStateInvalidated = xerrors.New("virtual state has been invalidated")
Functions ¶
Types ¶
type ChainStateSync ¶
type ChainStateSync interface { GetSolidIndexBaseline() StateBaseline SetSolidIndex(idx uint32) ChainStateSync // for use in state manager InvalidateSolidIndex() ChainStateSync // only for state manager }
type ChainStateSyncImpl ¶
type ChainStateSyncImpl struct {
// contains filtered or unexported fields
}
func NewChainStateSync ¶
func NewChainStateSync() *ChainStateSyncImpl
func (*ChainStateSyncImpl) GetSolidIndexBaseline ¶
func (g *ChainStateSyncImpl) GetSolidIndexBaseline() StateBaseline
GetSolidIndexBaseline creates an instance of the state baseline linked to the global sync
func (*ChainStateSyncImpl) InvalidateSolidIndex ¶
func (g *ChainStateSyncImpl) InvalidateSolidIndex() ChainStateSync
InvalidateSolidIndex invalidates state index and, globally, all baselines .All vaselines remain invalid until SetSolidIndex is called globally and Set for each baseline individually
func (*ChainStateSyncImpl) SetSolidIndex ¶
func (g *ChainStateSyncImpl) SetSolidIndex(idx uint32) ChainStateSync
SetSolidIndex sets solid index to the global sync and makes it valid To validate baselines, method Set should be called for each
type ContractInfo ¶
ContractInfo holds basic information about a native smart contract
func NewContract ¶
func NewContract(name, description string) *ContractInfo
func (*ContractInfo) Hname ¶
func (i *ContractInfo) Hname() iscp.Hname
func (*ContractInfo) Processor ¶
func (i *ContractInfo) Processor(init Handler, eps ...ProcessorEntryPoint) *ContractProcessor
Processor creates a ContractProcessor with the provided handlers
type ContractProcessor ¶
type ContractProcessor struct { Contract *ContractInfo Handlers map[iscp.Hname]ProcessorEntryPoint }
func (*ContractProcessor) GetDefaultEntryPoint ¶
func (p *ContractProcessor) GetDefaultEntryPoint() iscp.VMProcessorEntryPoint
func (*ContractProcessor) GetDescription ¶
func (p *ContractProcessor) GetDescription() string
func (*ContractProcessor) GetEntryPoint ¶
func (p *ContractProcessor) GetEntryPoint(code iscp.Hname) (iscp.VMProcessorEntryPoint, bool)
func (*ContractProcessor) GetStateReadOnly ¶
func (p *ContractProcessor) GetStateReadOnly(chainState kv.KVStoreReader) kv.KVStoreReader
type EntryPointHandler ¶
type EntryPointHandler struct { Info *EntryPointInfo Handler Handler }
func (*EntryPointHandler) Call ¶
func (h *EntryPointHandler) Call(ctx interface{}) (dict.Dict, error)
func (*EntryPointHandler) Hname ¶
func (h *EntryPointHandler) Hname() iscp.Hname
func (*EntryPointHandler) IsView ¶
func (h *EntryPointHandler) IsView() bool
func (*EntryPointHandler) Name ¶
func (h *EntryPointHandler) Name() string
type EntryPointInfo ¶
type EntryPointInfo struct{ Name string }
EntryPointInfo holds basic information about a full entry point
func (*EntryPointInfo) Hname ¶
func (ep *EntryPointInfo) Hname() iscp.Hname
func (*EntryPointInfo) WithHandler ¶
func (ep *EntryPointInfo) WithHandler(fn Handler) *EntryPointHandler
WithHandler specifies the handler function for the entry point
type ProcessorEntryPoint ¶
type ProcessorEntryPoint interface { iscp.VMProcessorEntryPoint Name() string Hname() iscp.Hname }
type StateBaseline ¶
type StateBaseline interface { Set() IsValid() bool MustValidate() }
type ViewEntryPointHandler ¶
type ViewEntryPointHandler struct { Info *ViewEntryPointInfo Handler ViewHandler }
func (*ViewEntryPointHandler) Call ¶
func (h *ViewEntryPointHandler) Call(ctx interface{}) (dict.Dict, error)
func (*ViewEntryPointHandler) Hname ¶
func (h *ViewEntryPointHandler) Hname() iscp.Hname
func (*ViewEntryPointHandler) IsView ¶
func (h *ViewEntryPointHandler) IsView() bool
func (*ViewEntryPointHandler) Name ¶
func (h *ViewEntryPointHandler) Name() string
type ViewEntryPointInfo ¶
type ViewEntryPointInfo struct {
Name string
}
ViewEntryPointInfo holds basic information about a view entry point
func (*ViewEntryPointInfo) Hname ¶
func (ep *ViewEntryPointInfo) Hname() iscp.Hname
func (*ViewEntryPointInfo) WithHandler ¶
func (ep *ViewEntryPointInfo) WithHandler(fn ViewHandler) *ViewEntryPointHandler
WithHandler specifies the handler function for the entry point
type ViewHandler ¶
type ViewHandler func(ctx iscp.SandboxView) (dict.Dict, error)