v1.0.6 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2018 License: Apache-2.0 Imports: 2 Imported by: 0




View Source
const (
	// Accept indicates that the message should be processed
	Accept = iota
	// Reject indicates that the message should not be processed
	// Forward indicates that the rule could not determine the correct course of action


View Source
var AcceptRule = Rule(acceptRule{})

AcceptRule always returns Accept as a result for Apply

View Source
var EmptyRejectRule = Rule(emptyRejectRule{})

EmptyRejectRule rejects empty messages

View Source
var NoopCommitter = Committer(noopCommitter{})

NoopCommitter does nothing on commit and is not isolated


This section is empty.


type Action

type Action int

Action is used to express the output of a rule

type Committer

type Committer interface {
	// Commit performs whatever action should be performed upon committing of a message

	// Isolated returns whether this transaction should have a block to itself or may be mixed with other transactions
	Isolated() bool

Committer is returned by postfiltering and should be invoked once the message has been written to the blockchain

type Rule

type Rule interface {
	// Apply applies the rule to the given Envelope, replying with the Action to take for the message
	// If the filter Accepts a message, it should provide a committer to use when writing the message to the chain
	Apply(message *ab.Envelope) (Action, Committer)

Rule defines a filter function which accepts, rejects, or forwards (to the next rule) an Envelope

type RuleSet

type RuleSet struct {
	// contains filtered or unexported fields

RuleSet is used to apply a collection of rules

func NewRuleSet

func NewRuleSet(rules []Rule) *RuleSet

NewRuleSet creates a new RuleSet with the given ordered list of Rules

func (*RuleSet) Apply

func (rs *RuleSet) Apply(message *ab.Envelope) (Committer, error)

Apply applies the rules given for this set in order, returning the committer, nil on valid, or nil, err on invalid

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL