AcceptRule always returns Accept as a result for Apply
var AcceptRule = Rule(acceptRule{})
EmptyRejectRule rejects empty messages
var EmptyRejectRule = Rule(emptyRejectRule{})
ErrChannelDoesNotExist is returned by the system channel for transactions which are not for the system channel ID and are not attempting to create a new channel
var ErrChannelDoesNotExist = errors.New("channel does not exist")
ErrEmptyMessage is returned by the empty message filter on rejection.
var ErrEmptyMessage = errors.New("Message was empty")
ErrMaintenanceMode is returned when transactions are rejected because the orderer is in "maintenance mode", as defined by ConsensusType.State != NORMAL. This typically happens during consensus-type migration.
var ErrMaintenanceMode = errors.New("maintenance mode")
ErrPermissionDenied is returned by errors which are caused by transactions which are not permitted due to an authorization failure.
var ErrPermissionDenied = errors.New("permission denied")
ChainCreator defines the methods necessary to simulate channel creation.
type ChainCreator interface { // NewChannelConfig returns a template config for a new channel. NewChannelConfig(envConfigUpdate *cb.Envelope) (channelconfig.Resources, error) // CreateBundle parses the config into resources CreateBundle(channelID string, config *cb.Config) (channelconfig.Resources, error) // ChannelsCount returns the count of channels which currently exist. ChannelsCount() int }
ChannelConfigTemplator can be used to generate config templates.
type ChannelConfigTemplator interface { // NewChannelConfig creates a new template configuration manager. NewChannelConfig(env *cb.Envelope) (channelconfig.Resources, error) }
Classification represents the possible message types for the system.
type Classification int
const ( // NormalMsg is the class of standard (endorser or otherwise non-config) messages. // Messages of this type should be processed by ProcessNormalMsg. NormalMsg Classification = iota // ConfigUpdateMsg indicates messages of type CONFIG_UPDATE. // Messages of this type should be processed by ProcessConfigUpdateMsg. ConfigUpdateMsg // ConfigMsg indicates message of type ORDERER_TRANSACTION or CONFIG. // Messages of this type should be processed by ProcessConfigMsg ConfigMsg )
DefaultTemplator implements the ChannelConfigTemplator interface and is the one used in production deployments.
type DefaultTemplator struct {
// contains filtered or unexported fields
}
func NewDefaultTemplator(support DefaultTemplatorSupport) *DefaultTemplator
NewDefaultTemplator returns an instance of the DefaultTemplator.
func (dt *DefaultTemplator) NewChannelConfig(envConfigUpdate *cb.Envelope) (channelconfig.Resources, error)
NewChannelConfig creates a new template channel configuration based on the current config in the ordering system channel.
DefaultTemplatorSupport is the subset of the channel config required by the DefaultTemplator.
type DefaultTemplatorSupport interface { // ConsortiumsConfig returns the ordering system channel's Consortiums config. ConsortiumsConfig() (channelconfig.Consortiums, bool) // OrdererConfig returns the ordering configuration and whether the configuration exists OrdererConfig() (channelconfig.Orderer, bool) // ConfigtxValidator returns the configtx manager corresponding to the system channel's current config. ConfigtxValidator() configtx.Validator // Signer returns the local signer suitable for signing forwarded messages. Signer() crypto.LocalSigner }
LimitedSupport defines the subset of the channel resources required by the systemchannel filter.
type LimitedSupport interface { OrdererConfig() (channelconfig.Orderer, bool) }
MaintenanceFilter checks whether the orderer config ConsensusType is in maintenance mode, and if it is, validates that the transaction is signed by the orderer org admin.
type MaintenanceFilter struct {
// contains filtered or unexported fields
}
func NewMaintenanceFilter(support MaintenanceFilterSupport) *MaintenanceFilter
NewMaintenanceFilter creates a new maintenance filter, at every evaluation, the policy manager and orderer config are called to retrieve the latest version of the policy and config.
func (mf *MaintenanceFilter) Apply(message *cb.Envelope) error
Apply applies the maintenance filter on a CONFIG tx.
MaintenanceFilterSupport provides the resources required for the maintenance filter.
type MaintenanceFilterSupport interface { // OrdererConfig returns the config.Orderer for the channel and whether the Orderer config exists OrdererConfig() (channelconfig.Orderer, bool) ChainID() string }
MaxBytesRule implements the Rule interface.
type MaxBytesRule struct {
// contains filtered or unexported fields
}
func NewSizeFilter(resources SizeFilterResources) *MaxBytesRule
NewSizeFilter creates a size filter which rejects messages larger than maxBytes
func (r *MaxBytesRule) Apply(message *common.Envelope) error
Apply returns an error if the message exceeds the configured absolute max batch size.
Processor provides the methods necessary to classify and process any message which arrives through the Broadcast interface.
type Processor interface { // ClassifyMsg inspects the message header to determine which type of processing is necessary ClassifyMsg(chdr *cb.ChannelHeader) Classification // ProcessNormalMsg will check the validity of a message based on the current configuration. It returns the current // configuration sequence number and nil on success, or an error if the message is not valid ProcessNormalMsg(env *cb.Envelope) (configSeq uint64, err error) // ProcessConfigUpdateMsg will attempt to apply the config update to the current configuration, and if successful // return the resulting config message and the configSeq the config was computed from. If the config update message // is invalid, an error is returned. ProcessConfigUpdateMsg(env *cb.Envelope) (config *cb.Envelope, configSeq uint64, err error) // ProcessConfigMsg takes message of type `ORDERER_TX` or `CONFIG`, unpack the ConfigUpdate envelope embedded // in it, and call `ProcessConfigUpdateMsg` to produce new Config message of the same type as original message. // This method is used to re-validate and reproduce config message, if it's deemed not to be valid anymore. ProcessConfigMsg(env *cb.Envelope) (*cb.Envelope, uint64, error) }
Rule defines a filter function which accepts, rejects, or forwards (to the next rule) an Envelope
type Rule interface { // Apply applies the rule to the given Envelope, either successfully or returns error Apply(message *ab.Envelope) error }
func NewExpirationRejectRule(filterSupport resources) Rule
NewExpirationRejectRule returns a rule that rejects messages signed by identities who's identities have expired, given the capability is active
RuleSet is used to apply a collection of rules
type RuleSet struct {
// contains filtered or unexported fields
}
func CreateStandardChannelFilters(filterSupport channelconfig.Resources, config localconfig.TopLevel) *RuleSet
CreateStandardChannelFilters creates the set of filters for a normal (non-system) chain.
In maintenance mode, require the signature of /Channel/Orderer/Writer. This will filter out configuration changes that are not related to consensus-type migration (e.g on /Channel/Application).
func CreateSystemChannelFilters(chainCreator ChainCreator, ledgerResources channelconfig.Resources, config localconfig.TopLevel) *RuleSet
CreateSystemChannelFilters creates the set of filters for the ordering system chain.
In maintenance mode, require the signature of /Channel/Orderer/Writers. This will filter out configuration changes that are not related to consensus-type migration (e.g on /Channel/Application).
func NewRuleSet(rules []Rule) *RuleSet
NewRuleSet creates a new RuleSet with the given ordered list of Rules
func (rs *RuleSet) Apply(message *ab.Envelope) error
Apply applies the rules given for this set in order, returning nil on valid or err on invalid
SigFilter stores the name of the policy to apply to deliver requests to determine whether a client is authorized
type SigFilter struct {
// contains filtered or unexported fields
}
func NewSigFilter(normalPolicyName, maintenancePolicyName string, support SigFilterSupport) *SigFilter
NewSigFilter creates a new signature filter, at every evaluation, the policy manager is called to retrieve the latest version of the policy.
normalPolicyName is applied when Orderer/ConsensusType.State = NORMAL maintenancePolicyName is applied when Orderer/ConsensusType.State = MAINTENANCE
func (sf *SigFilter) Apply(message *cb.Envelope) error
Apply applies the policy given, resulting in Reject or Forward, never Accept
SigFilterSupport provides the resources required for the signature filter
type SigFilterSupport interface { // PolicyManager returns a reference to the current policy manager PolicyManager() policies.Manager // OrdererConfig returns the config.Orderer for the channel and whether the Orderer config exists OrdererConfig() (channelconfig.Orderer, bool) }
SizeFilterResources defines the subset of the channel resources required to create this filter
type SizeFilterResources interface { // OrdererConfig returns the config.Orderer for the channel and whether the Orderer config exists OrdererConfig() (channelconfig.Orderer, bool) }
StandardChannel implements the Processor interface for standard extant channels
type StandardChannel struct {
// contains filtered or unexported fields
}
func NewStandardChannel(support StandardChannelSupport, filters *RuleSet) *StandardChannel
NewStandardChannel creates a new standard message processor
func (s *StandardChannel) ClassifyMsg(chdr *cb.ChannelHeader) Classification
ClassifyMsg inspects the message to determine which type of processing is necessary
func (s *StandardChannel) ProcessConfigMsg(env *cb.Envelope) (config *cb.Envelope, configSeq uint64, err error)
ProcessConfigMsg takes an envelope of type `HeaderType_CONFIG`, unpacks the `ConfigEnvelope` from it extracts the `ConfigUpdate` from `LastUpdate` field, and calls `ProcessConfigUpdateMsg` on it.
func (s *StandardChannel) ProcessConfigUpdateMsg(env *cb.Envelope) (config *cb.Envelope, configSeq uint64, err error)
ProcessConfigUpdateMsg will attempt to apply the config impetus msg to the current configuration, and if successful return the resulting config message and the configSeq the config was computed from. If the config impetus message is invalid, an error is returned.
func (s *StandardChannel) ProcessNormalMsg(env *cb.Envelope) (configSeq uint64, err error)
ProcessNormalMsg will check the validity of a message based on the current configuration. It returns the current configuration sequence number and nil on success, or an error if the message is not valid
StandardChannelSupport includes the resources needed for the StandardChannel processor.
type StandardChannelSupport interface { // Sequence should return the current configSeq Sequence() uint64 // ChainID returns the ChannelID ChainID() string // Signer returns the signer for this orderer Signer() crypto.LocalSigner // ProposeConfigUpdate takes in an Envelope of type CONFIG_UPDATE and produces a // ConfigEnvelope to be used as the Envelope Payload Data of a CONFIG message ProposeConfigUpdate(configtx *cb.Envelope) (*cb.ConfigEnvelope, error) OrdererConfig() (channelconfig.Orderer, bool) }
SystemChainFilter implements the filter.Rule interface.
type SystemChainFilter struct {
// contains filtered or unexported fields
}
func NewSystemChannelFilter(ls LimitedSupport, cc ChainCreator) *SystemChainFilter
NewSystemChannelFilter returns a new instance of a *SystemChainFilter.
func (scf *SystemChainFilter) Apply(env *cb.Envelope) error
Apply rejects bad messages with an error.
SystemChannel implements the Processor interface for the system channel.
type SystemChannel struct { *StandardChannel // contains filtered or unexported fields }
func NewSystemChannel(support StandardChannelSupport, templator ChannelConfigTemplator, filters *RuleSet) *SystemChannel
NewSystemChannel creates a new system channel message processor.
func (s *SystemChannel) ProcessConfigMsg(env *cb.Envelope) (*cb.Envelope, uint64, error)
ProcessConfigMsg takes envelope of following two types:
- `HeaderType_CONFIG`: system channel itself is the target of config, we simply unpack `ConfigUpdate` envelope from `LastUpdate` field and call `ProcessConfigUpdateMsg` on the underlying standard channel - `HeaderType_ORDERER_TRANSACTION`: it's a channel creation message, we unpack `ConfigUpdate` envelope and run `ProcessConfigUpdateMsg` on it
func (s *SystemChannel) ProcessConfigUpdateMsg(envConfigUpdate *cb.Envelope) (config *cb.Envelope, configSeq uint64, err error)
ProcessConfigUpdateMsg handles messages of type CONFIG_UPDATE either for the system channel itself or, for channel creation. In the channel creation case, the CONFIG_UPDATE is wrapped into a resulting ORDERER_TRANSACTION, and in the standard CONFIG_UPDATE case, a resulting CONFIG message
func (s *SystemChannel) ProcessNormalMsg(msg *cb.Envelope) (configSeq uint64, err error)
ProcessNormalMsg handles normal messages, rejecting them if they are not bound for the system channel ID with ErrChannelDoesNotExist.