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 Classification
- type MaintenanceFilter
- type MaintenanceFilterSupport
- type MaxBytesRule
- type Processor
- type Rule
- type RuleSet
- type SigFilter
- type SigFilterSupport
- type SizeFilterResources
- type StandardChannel
- func (s *StandardChannel) ClassifyMsg(chdr *cb.ChannelHeader) Classification
- func (s *StandardChannel) ProcessConfigMsg(env *cb.Envelope) (config *cb.Envelope, configSeq uint64, err error)
- func (s *StandardChannel) ProcessConfigUpdateMsg(env *cb.Envelope) (config *cb.Envelope, configSeq uint64, err error)
- func (s *StandardChannel) ProcessNormalMsg(env *cb.Envelope) (configSeq uint64, err error)
- type StandardChannelSupport
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 ErrMaintenanceMode = errors.New("maintenance mode")
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 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 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 indicates messages of type CONFIG_UPDATE. // Messages of this type should be processed by ProcessConfigUpdateMsg. ConfigUpdateMsg // ConfigMsg indicates message of type CONFIG. // Messages of this type should be processed by ProcessConfigMsg ConfigMsg // UnsupportedMsg indicates a message of type ORDERER_TRANSACTION, which is no longer supported, since support for // the system channel was removed. UnsupportedMsg )
type MaintenanceFilter ¶
type MaintenanceFilter struct {
// contains filtered or unexported fields
}
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.
func NewMaintenanceFilter ¶
func NewMaintenanceFilter(support MaintenanceFilterSupport, bccsp bccsp.BCCSP) *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.
type MaintenanceFilterSupport ¶
type MaintenanceFilterSupport interface { // OrdererConfig returns the config.Orderer for the channel and whether the Orderer config exists OrdererConfig() (channelconfig.Orderer, bool) // ChannelID returns the ChannelID ChannelID() string }
MaintenanceFilterSupport provides the resources required for the maintenance filter.
type MaxBytesRule ¶
type MaxBytesRule struct {
// contains filtered or unexported fields
}
MaxBytesRule implements the Rule interface.
func NewSizeFilter ¶
func NewSizeFilter(resources SizeFilterResources) *MaxBytesRule
NewSizeFilter 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 // 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) }
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
func NewExpirationRejectRule ¶
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
type RuleSet ¶
type RuleSet struct {
// contains filtered or unexported fields
}
RuleSet is used to apply a collection of rules
func CreateStandardChannelFilters ¶
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 NewRuleSet ¶
NewRuleSet creates a new RuleSet with the given ordered list of Rules
type SigFilter ¶
type SigFilter struct {
// contains filtered or unexported fields
}
SigFilter stores the name of the policy to apply to deliver requests to determine whether a client is authorized
func NewSigFilter ¶
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
type SigFilterSupport ¶
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) }
SigFilterSupport provides the resources required for the signature filter
type SizeFilterResources ¶
type SizeFilterResources interface { // 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 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, bccsp bccsp.BCCSP) *StandardChannel
NewStandardChannel creates a new standard message processor
func (*StandardChannel) ClassifyMsg ¶
func (s *StandardChannel) ClassifyMsg(chdr *cb.ChannelHeader) Classification
ClassifyMsg inspects the message to determine which type of processing is necessary
func (*StandardChannel) ProcessConfigMsg ¶
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 (*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 // ChannelID returns the ChannelID ChannelID() string // Signer returns the signer for this orderer Signer() identity.SignerSerializer // 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) }
StandardChannelSupport includes the resources needed for the StandardChannel processor.