Documentation ¶
Overview ¶
Package msgprocessor provides the implementations for processing of the assorted message types which may arrive in the system through Broadcast.
Index ¶
- Variables
- type ChainCreator
- type ChannelConfigTemplator
- type Classification
- type DefaultTemplator
- type DefaultTemplatorSupport
- type LimitedSupport
- type MaxBytesRule
- type Processor
- type Rule
- type RuleSet
- type StandardChannel
- type StandardChannelSupport
- type Support
- type SystemChainFilter
- type SystemChannel
Constants ¶
This section is empty.
Variables ¶
var AcceptRule = Rule(acceptRule{})
AcceptRule always returns Accept as a result for Apply
var EmptyRejectRule = Rule(emptyRejectRule{})
EmptyRejectRule rejects empty messages
var ErrChannelDoesNotExist = errors.New("channel does not exist")
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 ErrEmptyMessage = errors.New("Message was empty")
ErrEmptyMessage is returned by the empty message filter on rejection.
var ErrPermissionDenied = errors.New("permission denied")
ErrPermissionDenied is returned by errors which are caused by transactions which are not permitted due to an authorization failure.
Functions ¶
This section is empty.
Types ¶
type ChainCreator ¶
type ChainCreator interface { // NewChannelConfig returns a template config for a new channel. NewChannelConfig(envConfigUpdate *cb.Envelope) (configtxapi.Manager, error) // ChannelsCount returns the count of channels which currently exist. ChannelsCount() int }
ChainCreator defines the methods necessary to simulate channel creation.
type ChannelConfigTemplator ¶
type ChannelConfigTemplator interface { // NewChannelConfig creates a new template configuration manager. NewChannelConfig(env *cb.Envelope) (configtxapi.Manager, error) }
ChannelConfigTemplator can be used to generate config templates.
type Classification ¶
type Classification int
Classification represents the possible message types for the system.
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 is the class of configuration related messages. // Messages of this type should be processed by ProcessConfigUpdateMsg. ConfigUpdateMsg )
type DefaultTemplator ¶
type DefaultTemplator struct {
// contains filtered or unexported fields
}
DefaultTemplator implements the ChannelConfigTemplator interface and is the one used in production deployments.
func NewDefaultTemplator ¶
func NewDefaultTemplator(support DefaultTemplatorSupport) *DefaultTemplator
NewDefaultTemplator returns an instance of the DefaultTemplator.
func (*DefaultTemplator) NewChannelConfig ¶
func (dt *DefaultTemplator) NewChannelConfig(envConfigUpdate *cb.Envelope) (configtxapi.Manager, error)
NewChannelConfig creates a new template channel configuration based on the current config in the ordering system channel.
type DefaultTemplatorSupport ¶
type DefaultTemplatorSupport interface { // ConsortiumsConfig returns the ordering system channel's Consortiums config. ConsortiumsConfig() (config.Consortiums, bool) // ConfigEnvelope returns the config envelope corresponding to the system channel's current config. ConfigEnvelope() *cb.ConfigEnvelope // Signer returns the local signer suitable for signing forwarded messages. Signer() crypto.LocalSigner }
DefaultTemplatorSupport is the subset of the channel config required by the DefaultTemplator.
type LimitedSupport ¶
LimitedSupport defines the subset of the channel resources required by the systemchannel filter.
type MaxBytesRule ¶
type MaxBytesRule struct {
// contains filtered or unexported fields
}
MaxBytesRule implements the Rule interface.
func NewSizeFilter ¶
func NewSizeFilter(support Support) *MaxBytesRule
New creates a size filter which rejects messages larger than maxBytes
type Processor ¶
type Processor interface { // ClassifyMsg inspects the message header to determine which type of processing is necessary ClassifyMsg(chdr *cb.ChannelHeader) (Classification, 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 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) }
Processor provides the methods necessary to classify and process any message which arrives through the Broadcast interface.
type Rule ¶
type Rule interface { // Apply applies the rule to the given Envelope, either successfully or returns error Apply(message *ab.Envelope) error }
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 CreateStandardChannelFilters ¶
func CreateStandardChannelFilters(filterSupport configtxapi.Manager) *RuleSet
CreateStandardChannelFilters creates the set of filters for a normal (non-system) chain
func CreateSystemChannelFilters ¶
func CreateSystemChannelFilters(chainCreator ChainCreator, ledgerResources configtxapi.Manager) *RuleSet
CreateSystemChannelFilters creates the set of filters for the ordering system chain.
func NewRuleSet ¶
NewRuleSet creates a new RuleSet with the given ordered list of Rules
type StandardChannel ¶
type StandardChannel struct {
// contains filtered or unexported fields
}
StandardChannel implements the Processor interface for standard extant channels
func NewStandardChannel ¶
func NewStandardChannel(support StandardChannelSupport, filters *RuleSet) *StandardChannel
NewStandardChannel creates a new standard message processor
func (*StandardChannel) ClassifyMsg ¶
func (s *StandardChannel) ClassifyMsg(chdr *cb.ChannelHeader) (Classification, error)
ClassifyMsg inspects the message to determine which type of processing is necessary
func (*StandardChannel) ProcessConfigUpdateMsg ¶
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 (*StandardChannel) ProcessNormalMsg ¶
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
type StandardChannelSupport ¶
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) }
StandardChannelSupport includes the resources needed for the StandardChannel processor.
type SystemChainFilter ¶
type SystemChainFilter struct {
// contains filtered or unexported fields
}
SystemChainFilter implements the filter.Rule interface.
func NewSystemChannelFilter ¶
func NewSystemChannelFilter(ls LimitedSupport, cc ChainCreator) *SystemChainFilter
NewSystemChannelFilter returns a new instance of a *SystemChainFilter.
type SystemChannel ¶
type SystemChannel struct { *StandardChannel // contains filtered or unexported fields }
SystemChannel implements the Processor interface for the system channel.
func NewSystemChannel ¶
func NewSystemChannel(support StandardChannelSupport, templator ChannelConfigTemplator, filters *RuleSet) *SystemChannel
NewSystemChannel creates a new system channel message processor.
func (*SystemChannel) ProcessConfigUpdateMsg ¶
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 (*SystemChannel) ProcessNormalMsg ¶
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.