Documentation ¶
Index ¶
- Constants
- func ConfigEnvelopeFromBlock(block *common.Block) (*common.Envelope, error)
- func ConsensusMetadataFromConfigBlock(block *common.Block) (*etcdraft.Metadata, error)
- func ConsentersToMap(consenters []*etcdraft.Consenter) map[string]struct{}
- func EndpointconfigFromFromSupport(support consensus.ConsenterSupport) (*cluster.EndpointConfig, error)
- func IsMembershipUpdate(block *common.Block, currentMetadata *etcdraft.RaftMetadata) (bool, error)
- func LastConfigBlock(block *common.Block, support consensus.ConsenterSupport) (*common.Block, error)
- func MembershipByCert(consenters map[uint64]*etcdraft.Consenter) map[string]struct{}
- func MetadataFromConfigUpdate(update *common.ConfigUpdate) (*etcdraft.Metadata, error)
- func MetadataFromConfigValue(configValue *common.ConfigValue) (*etcdraft.Metadata, error)
- func RaftPeers(consenters map[uint64]*etcdraft.Consenter) []raft.Peer
- type BlockPuller
- type Chain
- func (c *Chain) Configure(env *common.Envelope, configSeq uint64) error
- func (c *Chain) Errored() <-chan struct{}
- func (c *Chain) Halt()
- func (c *Chain) Order(env *common.Envelope, configSeq uint64) error
- func (c *Chain) Start()
- func (c *Chain) Step(req *orderer.StepRequest, sender uint64) error
- func (c *Chain) Submit(req *orderer.SubmitRequest, sender uint64) error
- func (c *Chain) WaitReady() error
- type ChainGetter
- type Config
- type Configurator
- type Consenter
- type ConsenterCertificate
- type Dispatcher
- type MembershipChanges
- type MemoryStorage
- type MessageReceiver
- type Options
- type RPC
- type RaftStorage
- func (rs *RaftStorage) ApplySnapshot(snap raftpb.Snapshot)
- func (rs *RaftStorage) Close() error
- func (rs *RaftStorage) Snapshot() raftpb.Snapshot
- func (rs *RaftStorage) Store(entries []raftpb.Entry, hardstate raftpb.HardState, snapshot raftpb.Snapshot) error
- func (rs *RaftStorage) TakeSnapshot(i uint64, cs *raftpb.ConfState, data []byte) error
- type ReceiverGetter
Constants ¶
const DefaultSnapshotCatchUpEntries = uint64(500)
DefaultSnapshotCatchUpEntries is the default number of entries to preserve in memory when a snapshot is taken. This is for slow followers to catch up.
Variables ¶
This section is empty.
Functions ¶
func ConfigEnvelopeFromBlock ¶ added in v1.4.0
ConfigEnvelopeFromBlock extracts configuration envelop from the block based on the config type, i.e. HeaderType_ORDERER_TRANSACTION or HeaderType_CONFIG
func ConsensusMetadataFromConfigBlock ¶ added in v1.4.0
ConsensusMetadataFromConfigBlock reads consensus metadata updates from the configuration block
func ConsentersToMap ¶ added in v1.4.0
ConsentersToMap maps consenters into set where key is client TLS certificate
func EndpointconfigFromFromSupport ¶ added in v1.4.0
func EndpointconfigFromFromSupport(support consensus.ConsenterSupport) (*cluster.EndpointConfig, error)
EndpointconfigFromFromSupport extracts TLS CA certificates and endpoints from the ConsenterSupport
func IsMembershipUpdate ¶ added in v1.4.0
IsMembershipUpdate checks whenever block is config block and carries raft cluster membership updates
func LastConfigBlock ¶ added in v1.4.0
func LastConfigBlock(block *common.Block, support consensus.ConsenterSupport) (*common.Block, error)
LastConfigBlock returns the last config block relative to the given block.
func MembershipByCert ¶ added in v1.4.0
MembershipByCert convert consenters map into set encapsulated by map where key is client TLS certificate
func MetadataFromConfigUpdate ¶ added in v1.4.0
func MetadataFromConfigUpdate(update *common.ConfigUpdate) (*etcdraft.Metadata, error)
MetadataFromConfigUpdate extracts consensus metadata from config update
func MetadataFromConfigValue ¶ added in v1.4.0
func MetadataFromConfigValue(configValue *common.ConfigValue) (*etcdraft.Metadata, error)
MetadataFromConfigValue reads and translates configuration updates from config value into raft metadata
Types ¶
type BlockPuller ¶ added in v1.4.0
BlockPuller is used to pull blocks from other OSN
type Chain ¶
type Chain struct { BlockCreator *blockCreator // contains filtered or unexported fields }
Chain implements consensus.Chain interface.
func NewChain ¶
func NewChain( support consensus.ConsenterSupport, opts Options, conf Configurator, rpc RPC, puller BlockPuller, observeC chan<- uint64) (*Chain, error)
NewChain constructs a chain object.
func (*Chain) Errored ¶
func (c *Chain) Errored() <-chan struct{}
Errored returns a channel that closes when the chain stops.
func (*Chain) Start ¶
func (c *Chain) Start()
Start instructs the orderer to begin serving the chain and keep it current.
func (*Chain) Step ¶ added in v1.4.0
func (c *Chain) Step(req *orderer.StepRequest, sender uint64) error
Step passes the given StepRequest message to the raft.Node instance
type ChainGetter ¶ added in v1.4.0
type ChainGetter interface { // GetChain obtains the ChainSupport for the given channel. // Returns nil, false when the ChainSupport for the given channel // isn't found. GetChain(chainID string) *multichannel.ChainSupport }
ChainGetter obtains instances of ChainSupport for the given channel
type Config ¶ added in v1.4.0
type Config struct { WALDir string // WAL data of <my-channel> is stored in WALDir/<my-channel> SnapDir string // Snapshots of <my-channel> are stored in SnapDir/<my-channel> }
Config contains etcdraft configurations
type Configurator ¶ added in v1.4.0
type Configurator interface {
Configure(channel string, newNodes []cluster.RemoteNode)
}
Configurator is used to configure the communication layer when the chain starts.
type Consenter ¶ added in v1.4.0
type Consenter struct { Dialer *cluster.PredicateDialer Communication cluster.Communicator *Dispatcher Chains ChainGetter Logger *flogging.FabricLogger EtcdRaftConfig Config OrdererConfig localconfig.TopLevel Cert []byte }
Consenter implements etddraft consenter
func New ¶ added in v1.4.0
func New(clusterDialer *cluster.PredicateDialer, conf *localconfig.TopLevel, srvConf comm.ServerConfig, srv *comm.GRPCServer, r *multichannel.Registrar) *Consenter
New creates a etcdraft Consenter
func (*Consenter) HandleChain ¶ added in v1.4.0
func (c *Consenter) HandleChain(support consensus.ConsenterSupport, metadata *common.Metadata) (consensus.Chain, error)
HandleChain returns a new Chain instance or an error upon failure
func (*Consenter) ReceiverByChain ¶ added in v1.4.0
func (c *Consenter) ReceiverByChain(channelID string) MessageReceiver
ReceiverByChain returns the MessageReceiver for the given channelID or nil if not found.
type ConsenterCertificate ¶ added in v1.4.0
type ConsenterCertificate []byte
ConsenterCertificate denotes a TLS certificate of a consenter
func (ConsenterCertificate) IsConsenterOfChannel ¶ added in v1.4.0
func (conCert ConsenterCertificate) IsConsenterOfChannel(configBlock *common.Block) error
IsConsenterOfChannel returns whether the caller is a consenter of a channel by inspecting the given configuration block. It returns nil if true, else returns an error.
type Dispatcher ¶
type Dispatcher struct { Logger *flogging.FabricLogger ChainSelector ReceiverGetter }
Dispatcher dispatches Submit and Step requests to the designated per chain instances
func (*Dispatcher) OnStep ¶
func (d *Dispatcher) OnStep(channel string, sender uint64, request *orderer.StepRequest) (*orderer.StepResponse, error)
OnStep notifies the Dispatcher for a reception of a StepRequest from a given sender on a given channel
func (*Dispatcher) OnSubmit ¶
func (d *Dispatcher) OnSubmit(channel string, sender uint64, request *orderer.SubmitRequest) (*orderer.SubmitResponse, error)
OnSubmit notifies the Dispatcher for a reception of a SubmitRequest from a given sender on a given channel
type MembershipChanges ¶ added in v1.4.0
type MembershipChanges struct { AddedNodes []*etcdraft.Consenter RemovedNodes []*etcdraft.Consenter TotalChanges uint32 }
MembershipChanges keeps information about membership changes introduced during configuration update
func ComputeMembershipChanges ¶ added in v1.4.0
func ComputeMembershipChanges(oldConsenters map[uint64]*etcdraft.Consenter, newConsenters []*etcdraft.Consenter) *MembershipChanges
ComputeMembershipChanges computes membership update based on information about new conseters, returns two slices: a slice of added consenters and a slice of consenters to be removed
func (*MembershipChanges) UpdateRaftMetadataAndConfChange ¶ added in v1.4.0
func (mc *MembershipChanges) UpdateRaftMetadataAndConfChange(raftMetadata *etcdraft.RaftMetadata) *raftpb.ConfChange
UpdateRaftMetadataAndConfChange given the membership changes and RaftMetadata method calculates updates to be applied to the raft cluster configuration in addition updates mapping between consenter and its id within metadata
type MemoryStorage ¶ added in v1.4.0
type MemoryStorage interface { raft.Storage Append(entries []raftpb.Entry) error SetHardState(st raftpb.HardState) error CreateSnapshot(i uint64, cs *raftpb.ConfState, data []byte) (raftpb.Snapshot, error) Compact(compactIndex uint64) error ApplySnapshot(snap raftpb.Snapshot) error }
MemoryStorage is currently backed by etcd/raft.MemoryStorage. This interface is defined to expose dependencies of fsm so that it may be swapped in the future. TODO(jay) Add other necessary methods to this interface once we need them in implementation, e.g. ApplySnapshot.
type MessageReceiver ¶
type MessageReceiver interface { // Step passes the given StepRequest message to the MessageReceiver Step(req *orderer.StepRequest, sender uint64) error // Submit passes the given SubmitRequest message to the MessageReceiver Submit(req *orderer.SubmitRequest, sender uint64) error }
MessageReceiver receives messages
type Options ¶
type Options struct { RaftID uint64 Clock clock.Clock WALDir string SnapDir string SnapInterval uint64 // This is configurable mainly for testing purpose. Users are not // expected to alter this. Instead, DefaultSnapshotCatchUpEntries is used. SnapshotCatchUpEntries uint64 MemoryStorage MemoryStorage Logger *flogging.FabricLogger TickInterval time.Duration ElectionTick int HeartbeatTick int MaxSizePerMsg uint64 MaxInflightMsgs int RaftMetadata *etcdraft.RaftMetadata }
Options contains all the configurations relevant to the chain.
type RPC ¶ added in v1.4.0
type RPC interface { Step(dest uint64, msg *orderer.StepRequest) (*orderer.StepResponse, error) SendSubmit(dest uint64, request *orderer.SubmitRequest) error }
RPC is used to mock the transport layer in tests.
type RaftStorage ¶ added in v1.4.0
type RaftStorage struct { SnapshotCatchUpEntries uint64 // contains filtered or unexported fields }
RaftStorage encapsulates storages needed for etcd/raft data, i.e. memory, wal
func CreateStorage ¶ added in v1.4.0
func CreateStorage( lg *flogging.FabricLogger, applied uint64, walDir string, snapDir string, ram MemoryStorage, ) (*RaftStorage, error)
CreateStorage attempts to create a storage to persist etcd/raft data. If data presents in specified disk, they are loaded to reconstruct storage state.
func (*RaftStorage) ApplySnapshot ¶ added in v1.4.0
func (rs *RaftStorage) ApplySnapshot(snap raftpb.Snapshot)
ApplySnapshot applies snapshot to local memory storage
func (*RaftStorage) Close ¶ added in v1.4.0
func (rs *RaftStorage) Close() error
Close closes storage
func (*RaftStorage) Snapshot ¶ added in v1.4.0
func (rs *RaftStorage) Snapshot() raftpb.Snapshot
Snapshot returns the latest snapshot stored in memory
func (*RaftStorage) Store ¶ added in v1.4.0
func (rs *RaftStorage) Store(entries []raftpb.Entry, hardstate raftpb.HardState, snapshot raftpb.Snapshot) error
Store persists etcd/raft data
func (*RaftStorage) TakeSnapshot ¶ added in v1.4.0
TakeSnapshot takes a snapshot at index i from MemoryStorage, and persists it to wal and disk.
type ReceiverGetter ¶
type ReceiverGetter interface { // ReceiverByChain returns the MessageReceiver if it exists, or nil if it doesn't ReceiverByChain(channelID string) MessageReceiver }
ReceiverGetter obtains instances of MessageReceiver given a channel ID