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 ¶
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 ¶
type PredicateEngines map[uint64]func(ctx context.Context, predicate *predicates.Predicate, args []byte, txo *types.TransactionOrder, env TxContext) (bool, error)
func Dispatcher ¶
func Dispatcher(engines ...PredicateEngine) (PredicateEngines, error)
Dispatcher creates collection of predicate engines
func (PredicateEngines) Add ¶
func (pe PredicateEngines) Add(engine PredicateEngine) error
func (PredicateEngines) Execute ¶
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 ¶
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 ¶
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 ¶
type TxContext interface {
GasMeter
GetUnit(id types.UnitID, committed bool) (state.Unit, error)
CommittedUC() *types.UnicityCertificate
CurrentRound() uint64
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.