Documentation
¶
Index ¶
Constants ¶
View Source
const MaxPredicateBinSize = 65536
Variables ¶
This section is empty.
Functions ¶
func ExtractPredicate ¶
func ExtractPredicate(predicateBytes []byte) (*predicates.Predicate, error)
func ExtractPubKey ¶
Types ¶
type PredicateEngine ¶ added in v0.4.0
type PredicateEngine interface {
// ID unique ID of the engine, this is used to dispatch predicates (predicate.Tag == engine.ID)
// to the engine which is supposed to evaluate it.
ID() uint64
// Execute executes given predicate
Execute(ctx context.Context, predicate *predicates.Predicate, args []byte, txo *types.TransactionOrder, env TxContext) (bool, error)
}
type PredicateEngines ¶ added in v0.4.0
type PredicateEngines map[uint64]func(ctx context.Context, predicate *predicates.Predicate, args []byte, txo *types.TransactionOrder, env TxContext) (bool, error)
func Dispatcher ¶ added in v0.4.0
func Dispatcher(engines ...PredicateEngine) (PredicateEngines, error)
Dispatcher creates collection of predicate engines
func (PredicateEngines) Add ¶ added in v0.4.0
func (pe PredicateEngines) Add(engine PredicateEngine) error
func (PredicateEngines) Execute ¶ added in v0.4.0
func (pe PredicateEngines) Execute(ctx context.Context, predicate types.PredicateBytes, args []byte, txo *types.TransactionOrder, env TxContext) (bool, error)
Execute decodes predicate from binary representation and dispatches it to appropriate predicate executor.
type PredicateExecutor ¶ added in v1.0.0
type PredicateExecutor func(ctx context.Context, predicate types.PredicateBytes, args []byte, txo *types.TransactionOrder, env TxContext) (bool, error)
type PredicateRunner ¶
type PredicateRunner func(predicate types.PredicateBytes, args []byte, txo *types.TransactionOrder, env TxContext) error
func NewPredicateRunner ¶ added in v1.0.0
func NewPredicateRunner( executor PredicateExecutor, ) PredicateRunner
NewPredicateRunner is a helper to refactor predicate support - provide implementation which is common for most tx systems and "translates" between two interfaces:
- currently tx handlers do not have context.Context to pass to the predicate engine so wrapper returned doesn't require it and passes context.Background() to the predicate engine;
- currently tx systems do not differentiate between predicate evaluating to "false" vs returning error (ie invalid predicate or arguments) so wrapper returns error in case the predicate evaluates to "false".
type TxContext ¶ added in v0.4.0
type TxContext interface {
GasMeter
GetUnit(id types.UnitID, committed bool) (state.Unit, error)
CommittedUC() *types.UnicityCertificate
CurrentRound() uint64
TrustBase(epoch uint64) (types.RootTrustBase, error)
ExtraArgument() ([]byte, error)
}
TxContext environment where predicate runs (AKA transaction execution context) This is meant to provide the predicate engine with access to the tx system which processes the transaction.
Click to show internal directories.
Click to hide internal directories.