...

Package smartbft

import "github.com/hyperledger/fabric/orderer/consensus/smartbft"
Overview
Index
Subdirectories

Overview ▾

Index ▾

func ConfigurationEnvelop(configBlock *common.Block) (*common.ConfigEnvelope, error)
func LastBlockFromLedgerOrPanic(ledger Ledger, logger PanicLogger) *common.Block
func LastConfigBlockFromLedgerOrPanic(ledger Ledger, logger PanicLogger) *common.Block
func New(pmr PolicyManagerRetriever, signerSerializer signerSerializer, clusterDialer *cluster.PredicateDialer, conf *localconfig.TopLevel, srvConf comm.ServerConfig, srv *comm.GRPCServer, r *multichannel.Registrar, metricsProvider metrics.Provider) consensus.Consenter
func PreviousConfigBlockFromLedgerOrPanic(ledger Ledger, logger PanicLogger) *common.Block
func ProposalToBlock(proposal types.Proposal) (*common.Block, error)
type AccessController
type Assembler
    func (a *Assembler) AssembleProposal(metadata []byte, requests [][]byte) (nextProp types.Proposal)
type BFTChain
    func NewChain(config smartbft.Configuration, walDir string, blockPuller BlockPuller, comm cluster.Communicator, signerSerializer signerSerializer, policyManager policies.Manager, remoteNodes []cluster.RemoteNode, id2Identities NodeIdentitiesByID, support consensus.ConsenterSupport, metrics *Metrics) (*BFTChain, error)
    func (c *BFTChain) Configure(config *common.Envelope, configSeq uint64) error
    func (c *BFTChain) Deliver(proposal types.Proposal, signatures []types.Signature)
    func (c *BFTChain) Errored() <-chan struct{}
    func (c *BFTChain) Halt()
    func (c *BFTChain) HandleMessage(sender uint64, m *smartbftprotos.Message)
    func (c *BFTChain) HandleRequest(sender uint64, req []byte)
    func (c *BFTChain) Order(env *common.Envelope, configSeq uint64) error
    func (c *BFTChain) Start()
    func (c *BFTChain) WaitReady() error
type BlockPuller
type ByteBufferTuple
    func (bbt *ByteBufferTuple) FromBytes(bytes []byte) error
    func (bbt *ByteBufferTuple) ToBytes() []byte
type ChainGetter
type Consenter
    func (c *Consenter) HandleChain(support consensus.ConsenterSupport, metadata *common.Metadata) (consensus.Chain, error)
    func (c *Consenter) ReceiverByChain(channelID string) MessageReceiver
    func (c *Consenter) TargetChannel(message proto2.Message) string
type ConsenterCertificate
    func (conCert ConsenterCertificate) IsConsenterOfChannel(configBlock *common.Block) error
type ConsenterVerifier
type Egress
    func (e *Egress) Nodes() []uint64
    func (e *Egress) SendConsensus(targetID uint64, m *protos.Message)
    func (e *Egress) SendTransaction(targetID uint64, request []byte)
type Ingreess
    func (in *Ingreess) OnConsensus(channel string, sender uint64, request *orderer.ConsensusRequest) error
    func (in *Ingreess) OnSubmit(channel string, sender uint64, request *orderer.SubmitRequest) error
type Ledger
type MessageReceiver
type Metrics
    func NewMetrics(p metrics.Provider) *Metrics
type NodeIdentitiesByID
    func (nibd NodeIdentitiesByID) IdentityToID(identity []byte) (uint64, bool)
type PanicLogger
type PolicyManagerRetriever
type RPC
type ReceiverGetter
type RequestInspector
    func (ri *RequestInspector) RequestID(rawReq []byte) types.RequestInfo
type Sequencer
type Signature
    func (sig Signature) AsBytes() []byte
    func (sig *Signature) Marshal() []byte
    func (sig *Signature) Unmarshal(bytes []byte) error
type Signer
    func (s *Signer) Sign(msg []byte) []byte
    func (s *Signer) SignProposal(proposal types.Proposal) *types.Signature
type SignerSerializer
type Synchronizer
    func (s *Synchronizer) Close()
    func (s *Synchronizer) Sync() types.Decision
type Verifier
    func (v *Verifier) VerificationSequence() uint64
    func (v *Verifier) VerifyConsenterSig(signature types.Signature, prop types.Proposal) error
    func (v *Verifier) VerifyProposal(proposal types.Proposal) ([]types.RequestInfo, error)
    func (v *Verifier) VerifyRequest(rawRequest []byte) (types.RequestInfo, error)
    func (v *Verifier) VerifySignature(signature types.Signature) error
type WALConfig
type WarningLogger

Package files

assembler.go chain.go consenter.go egress.go ingress.go metrics.go signature.go signer.go synchronizer.go util.go verifier.go

func ConfigurationEnvelop

func ConfigurationEnvelop(configBlock *common.Block) (*common.ConfigEnvelope, error)

ConfigurationEnvelop extract configuration envelop

func LastBlockFromLedgerOrPanic

func LastBlockFromLedgerOrPanic(ledger Ledger, logger PanicLogger) *common.Block

func LastConfigBlockFromLedgerOrPanic

func LastConfigBlockFromLedgerOrPanic(ledger Ledger, logger PanicLogger) *common.Block

func New

func New(
    pmr PolicyManagerRetriever,
    signerSerializer signerSerializer,
    clusterDialer *cluster.PredicateDialer,
    conf *localconfig.TopLevel,
    srvConf comm.ServerConfig,
    srv *comm.GRPCServer,
    r *multichannel.Registrar,
    metricsProvider metrics.Provider,
) consensus.Consenter

New creates Consenter of type smart bft

func PreviousConfigBlockFromLedgerOrPanic

func PreviousConfigBlockFromLedgerOrPanic(ledger Ledger, logger PanicLogger) *common.Block

func ProposalToBlock

func ProposalToBlock(proposal types.Proposal) (*common.Block, error)

type AccessController

AccessController is used to determine if a signature of a certain client is valid

type AccessController interface {
    // Evaluate takes a set of SignedData and evaluates whether this set of signatures satisfies the policy
    Evaluate(signatureSet []*common.SignedData) error
}

type Assembler

type Assembler struct {
    Logger          *flogging.FabricLogger
    VerificationSeq func() uint64
    sync.RWMutex
    LastConfigBlockNum uint64
    LastBlock          *common.Block
}

func (*Assembler) AssembleProposal

func (a *Assembler) AssembleProposal(metadata []byte, requests [][]byte) (nextProp types.Proposal)

type BFTChain

BFTChain implements Chain interface to wire with BFT smart library

type BFTChain struct {
    Config           smartbft.Configuration
    BlockPuller      BlockPuller
    Comm             cluster.Communicator
    SignerSerializer signerSerializer
    PolicyManager    policies.Manager
    RemoteNodes      []cluster.RemoteNode
    ID2Identities    NodeIdentitiesByID
    Logger           *flogging.FabricLogger
    WALDir           string

    Metrics *Metrics
    // contains filtered or unexported fields
}

func NewChain

func NewChain(
    config smartbft.Configuration,
    walDir string,
    blockPuller BlockPuller,
    comm cluster.Communicator,
    signerSerializer signerSerializer,
    policyManager policies.Manager,
    remoteNodes []cluster.RemoteNode,
    id2Identities NodeIdentitiesByID,
    support consensus.ConsenterSupport,
    metrics *Metrics,
) (*BFTChain, error)

NewChain creates new BFT Smart chain

func (*BFTChain) Configure

func (c *BFTChain) Configure(config *common.Envelope, configSeq uint64) error

func (*BFTChain) Deliver

func (c *BFTChain) Deliver(proposal types.Proposal, signatures []types.Signature)

func (*BFTChain) Errored

func (c *BFTChain) Errored() <-chan struct{}

func (*BFTChain) Halt

func (c *BFTChain) Halt()

func (*BFTChain) HandleMessage

func (c *BFTChain) HandleMessage(sender uint64, m *smartbftprotos.Message)

func (*BFTChain) HandleRequest

func (c *BFTChain) HandleRequest(sender uint64, req []byte)

func (*BFTChain) Order

func (c *BFTChain) Order(env *common.Envelope, configSeq uint64) error

func (*BFTChain) Start

func (c *BFTChain) Start()

func (*BFTChain) WaitReady

func (c *BFTChain) WaitReady() error

type BlockPuller

BlockPuller is used to pull blocks from other OSN

type BlockPuller interface {
    PullBlock(seq uint64) *common.Block
    HeightsByEndpoints() (map[string]uint64, error)
    Close()
}

type ByteBufferTuple

type ByteBufferTuple struct {
    A []byte
    B []byte
}

func (*ByteBufferTuple) FromBytes

func (bbt *ByteBufferTuple) FromBytes(bytes []byte) error

func (*ByteBufferTuple) ToBytes

func (bbt *ByteBufferTuple) ToBytes() []byte

type ChainGetter

ChainGetter obtains instances of ChainSupport for the given channel

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
}

type Consenter

Consenter implementation of the BFT smart based consenter

type Consenter struct {
    GetPolicyManager PolicyManagerRetriever
    Logger           *flogging.FabricLogger
    Cert             []byte
    Comm             *cluster.Comm
    Chains           ChainGetter
    SignerSerializer signerSerializer
    Registrar        *multichannel.Registrar
    WALBaseDir       string
    ClusterDialer    *cluster.PredicateDialer
    Conf             *localconfig.TopLevel
    Metrics          *Metrics
}

func (*Consenter) HandleChain

func (c *Consenter) HandleChain(support consensus.ConsenterSupport, metadata *common.Metadata) (consensus.Chain, error)

func (*Consenter) ReceiverByChain

func (c *Consenter) ReceiverByChain(channelID string) MessageReceiver

ReceiverByChain returns the MessageReceiver for the given channelID or nil if not found.

func (*Consenter) TargetChannel

func (c *Consenter) TargetChannel(message proto2.Message) string

TargetChannel extracts the channel from the given proto.Message. Returns an empty string on failure.

type ConsenterCertificate

ConsenterCertificate denotes a TLS certificate of a consenter

type ConsenterCertificate []byte

func (ConsenterCertificate) IsConsenterOfChannel

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 ConsenterVerifier

ConsenterVerifier is used to determine whether a signature from one of the consenters is valid

type ConsenterVerifier interface {
    // Evaluate takes a set of SignedData and evaluates whether this set of signatures satisfies the policy
    Evaluate(signatureSet []*common.SignedData) error
}

type Egress

type Egress struct {
    Channel string
    RPC     RPC
    Logger  PanicLogger
    // contains filtered or unexported fields
}

func (*Egress) Nodes

func (e *Egress) Nodes() []uint64

func (*Egress) SendConsensus

func (e *Egress) SendConsensus(targetID uint64, m *protos.Message)

func (*Egress) SendTransaction

func (e *Egress) SendTransaction(targetID uint64, request []byte)

type Ingreess

Ingreess dispatches Submit and Step requests to the designated per chain instances

type Ingreess struct {
    Logger        WarningLogger
    ChainSelector ReceiverGetter
}

func (*Ingreess) OnConsensus

func (in *Ingreess) OnConsensus(channel string, sender uint64, request *orderer.ConsensusRequest) error

OnConsensus notifies the Ingreess for a reception of a StepRequest from a given sender on a given channel

func (*Ingreess) OnSubmit

func (in *Ingreess) OnSubmit(channel string, sender uint64, request *orderer.SubmitRequest) error

OnSubmit notifies the Ingreess for a reception of a SubmitRequest from a given sender on a given channel

type Ledger

type Ledger interface {
    // Height returns the number of blocks in the ledger this channel is associated with.
    Height() uint64

    // Block returns a block with the given number,
    // or nil if such a block doesn't exist.
    Block(number uint64) *common.Block
}

type MessageReceiver

MessageReceiver receives messages

type MessageReceiver interface {
    HandleMessage(sender uint64, m *protos.Message)
    HandleRequest(sender uint64, req []byte)
}

type Metrics

type Metrics struct {
    ClusterSize          metrics.Gauge
    CommittedBlockNumber metrics.Gauge
    IsLeader             metrics.Gauge
    LeaderID             metrics.Gauge
}

func NewMetrics

func NewMetrics(p metrics.Provider) *Metrics

type NodeIdentitiesByID

type NodeIdentitiesByID map[uint64][]byte

func (NodeIdentitiesByID) IdentityToID

func (nibd NodeIdentitiesByID) IdentityToID(identity []byte) (uint64, bool)

type PanicLogger

type PanicLogger interface {
    Panicf(template string, args ...interface{})
}

type PolicyManagerRetriever

type PolicyManagerRetriever func(channel string) policies.Manager

type RPC

type RPC interface {
    SendConsensus(dest uint64, msg *orderer.ConsensusRequest) error
    SendSubmit(dest uint64, request *orderer.SubmitRequest) error
}

type ReceiverGetter

ReceiverGetter obtains instances of MessageReceiver given a channel ID

type ReceiverGetter interface {
    // ReceiverByChain returns the MessageReceiver if it exists, or nil if it doesn't
    ReceiverByChain(channelID string) MessageReceiver
}

type RequestInspector

RequestInspector inspects incomming requests and validates serialized identity

type RequestInspector struct {
    ValidateIdentityStructure func(identity *msp.SerializedIdentity) error
}

func (*RequestInspector) RequestID

func (ri *RequestInspector) RequestID(rawReq []byte) types.RequestInfo

type Sequencer

Sequencer returns sequences

type Sequencer interface {
    Sequence() uint64
}

type Signature

type Signature struct {
    SignatureHeader      []byte
    BlockHeader          []byte
    OrdererBlockMetadata []byte
}

func (Signature) AsBytes

func (sig Signature) AsBytes() []byte

func (*Signature) Marshal

func (sig *Signature) Marshal() []byte

func (*Signature) Unmarshal

func (sig *Signature) Unmarshal(bytes []byte) error

type Signer

type Signer struct {
    ID                 uint64
    SignerSerializer   SignerSerializer
    Logger             PanicLogger
    LastConfigBlockNum func() uint64
}

func (*Signer) Sign

func (s *Signer) Sign(msg []byte) []byte

func (*Signer) SignProposal

func (s *Signer) SignProposal(proposal types.Proposal) *types.Signature

type SignerSerializer

type SignerSerializer interface {
    crypto.Signer
    crypto.IdentitySerializer
}

type Synchronizer

type Synchronizer struct {
    BlockToDecision func(block *common.Block) *types.Decision
    UpdateLastHash  func(block *common.Block)
    Support         consensus.ConsenterSupport
    BlockPuller     BlockPuller
    ClusterSize     uint64
    Logger          *flogging.FabricLogger
}

func (*Synchronizer) Close

func (s *Synchronizer) Close()

func (*Synchronizer) Sync

func (s *Synchronizer) Sync() types.Decision

type Verifier

type Verifier struct {
    ReqInspector           *RequestInspector
    Id2Identity            NodeIdentitiesByID
    ConsenterVerifier      ConsenterVerifier
    AccessController       AccessController
    VerificationSequencer  Sequencer
    Ledger                 Ledger
    LastCommittedBlockHash string
    LastConfigBlockNum     uint64
    Logger                 *flogging.FabricLogger
    // contains filtered or unexported fields
}

func (*Verifier) VerificationSequence

func (v *Verifier) VerificationSequence() uint64

func (*Verifier) VerifyConsenterSig

func (v *Verifier) VerifyConsenterSig(signature types.Signature, prop types.Proposal) error

func (*Verifier) VerifyProposal

func (v *Verifier) VerifyProposal(proposal types.Proposal) ([]types.RequestInfo, error)

func (*Verifier) VerifyRequest

func (v *Verifier) VerifyRequest(rawRequest []byte) (types.RequestInfo, error)

func (*Verifier) VerifySignature

func (v *Verifier) VerifySignature(signature types.Signature) error

type WALConfig

WALConfig consensus specific configuration parameters from orderer.yaml; for SmartBFT only WALDir is relevant.

type WALConfig 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>
    EvictionSuspicion string // Duration threshold that the node samples in order to suspect its eviction from the channel.
}

type WarningLogger

type WarningLogger interface {
    Warningf(template string, args ...interface{})
}

Subdirectories

Name Synopsis
..
mocks Code generated by counterfeiter.