fabric: github.com/hyperledger/fabric/gossip/state Index | Files | Directories

package state

import "github.com/hyperledger/fabric/gossip/state"


Package Files

config.go payloads_buffer.go state.go


const (
    DefStateCheckInterval   = 10 * time.Second
    DefStateResponseTimeout = 3 * time.Second
    DefStateBatchSize       = 10
    DefStateMaxRetries      = 3
    DefStateBlockBufferSize = 100
    DefStateChannelSize     = 100
    DefStateEnabled         = true

type Configuration Uses

type Configuration struct {
    AntiEntropyInterval             time.Duration
    AntiEntropyStateResponseTimeout time.Duration
    AntiEntropyBatchSize            uint64
    MaxBlockDistance                int
    AntiEntropyMaxRetries           int
    ChannelBufferSize               int
    EnableStateTransfer             bool

Configuration keeps state transfer configuration parameters

type GossipAdapter Uses

type GossipAdapter interface {
    // Send sends a message to remote peers
    Send(msg *proto.GossipMessage, peers ...*comm.RemotePeer)

    // Accept returns a dedicated read-only channel for messages sent by other nodes that match a certain predicate.
    // If passThrough is false, the messages are processed by the gossip layer beforehand.
    // If passThrough is true, the gossip layer doesn't intervene and the messages
    // can be used to send a reply back to the sender
    Accept(acceptor common2.MessageAcceptor, passThrough bool) (<-chan *proto.GossipMessage, <-chan protoext.ReceivedMessage)

    // UpdateLedgerHeight updates the ledger height the peer
    // publishes to other peers in the channel
    UpdateLedgerHeight(height uint64, channelID common2.ChannelID)

    // PeersOfChannel returns the NetworkMembers considered alive
    // and also subscribed to the channel given
    PeersOfChannel(common2.ChannelID) []discovery.NetworkMember

GossipAdapter defines gossip/communication required interface for state provider

type GossipStateProvider Uses

type GossipStateProvider interface {
    AddPayload(payload *proto.Payload) error

    // Stop terminates state transfer object

GossipStateProvider is the interface to acquire sequences of the ledger blocks capable to full fill missing blocks by running state replication and sending request to get missing block to other nodes

func NewGossipStateProvider Uses

func NewGossipStateProvider(
    chainID string,
    services *ServicesMediator,
    ledger ledgerResources,
    stateMetrics *metrics.StateMetrics,
    blockingMode bool,
    config *StateConfig,
) GossipStateProvider

NewGossipStateProvider creates state provider with coordinator instance to orchestrate arrival of private rwsets and blocks before committing them into the ledger.

type GossipStateProviderImpl Uses

type GossipStateProviderImpl struct {
    // contains filtered or unexported fields

GossipStateProviderImpl the implementation of the GossipStateProvider interface the struct to handle in memory sliding window of new ledger block to be acquired by hyper ledger

func (*GossipStateProviderImpl) AddPayload Uses

func (s *GossipStateProviderImpl) AddPayload(payload *proto.Payload) error

AddPayload adds new payload into state.

func (*GossipStateProviderImpl) Stop Uses

func (s *GossipStateProviderImpl) Stop()

Stop function sends halting signal to all go routines

type MCSAdapter Uses

type MCSAdapter interface {
    // VerifyBlock returns nil if the block is properly signed, and the claimed seqNum is the
    // sequence number that the block's header contains.
    // else returns error
    VerifyBlock(channelID common2.ChannelID, seqNum uint64, signedBlock *common.Block) error

    // VerifyByChannel checks that signature is a valid signature of message
    // under a peer's verification key, but also in the context of a specific channel.
    // If the verification succeeded, Verify returns nil meaning no error occurred.
    // If peerIdentity is nil, then the verification fails.
    VerifyByChannel(channelID common2.ChannelID, peerIdentity api.PeerIdentityType, signature, message []byte) error

MCSAdapter adapter of message crypto service interface to bound specific APIs required by state transfer service

type PayloadsBuffer Uses

type PayloadsBuffer interface {
    // Adds new block into the buffer
    Push(payload *proto.Payload)

    // Returns next expected sequence number
    Next() uint64

    // Remove and return payload with given sequence number
    Pop() *proto.Payload

    // Get current buffer size
    Size() int

    // Channel to indicate event when new payload pushed with sequence
    // number equal to the next expected value.
    Ready() chan struct{}


PayloadsBuffer is used to store payloads into which used to support payloads with blocks reordering according to the sequence numbers. It also will provide the capability to signal whenever expected block has arrived.

func NewPayloadsBuffer Uses

func NewPayloadsBuffer(next uint64) PayloadsBuffer

NewPayloadsBuffer is factory function to create new payloads buffer

type PayloadsBufferImpl Uses

type PayloadsBufferImpl struct {
    // contains filtered or unexported fields

PayloadsBufferImpl structure to implement PayloadsBuffer interface store inner state of available payloads and sequence numbers

func (*PayloadsBufferImpl) Close Uses

func (b *PayloadsBufferImpl) Close()

Close cleanups resources and channels in maintained

func (*PayloadsBufferImpl) Next Uses

func (b *PayloadsBufferImpl) Next() uint64

Next function provides the number of the next expected block

func (*PayloadsBufferImpl) Pop Uses

func (b *PayloadsBufferImpl) Pop() *proto.Payload

Pop function extracts the payload according to the next expected block number, if no next block arrived yet, function returns nil.

func (*PayloadsBufferImpl) Push Uses

func (b *PayloadsBufferImpl) Push(payload *proto.Payload)

Push new payload into the buffer structure in case new arrived payload sequence number is below the expected next block number payload will be thrown away. TODO return bool to indicate if payload was added or not, so that caller can log result.

func (*PayloadsBufferImpl) Ready Uses

func (b *PayloadsBufferImpl) Ready() chan struct{}

Ready function returns the channel which indicates whenever expected next block has arrived and one could safely pop out next sequence of blocks

func (*PayloadsBufferImpl) Size Uses

func (b *PayloadsBufferImpl) Size() int

Size returns current number of payloads stored within buffer

type ServicesMediator Uses

type ServicesMediator struct {

ServicesMediator aggregated adapter to compound all mediator required by state transfer into single struct

type StateConfig Uses

type StateConfig struct {
    StateCheckInterval   time.Duration
    StateResponseTimeout time.Duration
    StateBatchSize       uint64
    StateMaxRetries      int
    StateBlockBufferSize int
    StateChannelSize     int
    StateEnabled         bool

func GlobalConfig Uses

func GlobalConfig() *StateConfig



Package state imports 22 packages (graph) and is imported by 8 packages. Updated 2020-02-19. Refresh now. Tools for package owners.