Documentation ¶
Index ¶
- Variables
- func ConfigFromBlock(block *common.Block) (*common.ConfigEnvelope, error)
- type BlockVerificationAssistant
- func NewBlockVerificationAssistant(configBlock *common.Block, lastBlock *common.Block, cryptoProvider bccsp.BCCSP, ...) (*BlockVerificationAssistant, error)
- func NewBlockVerificationAssistantFromConfig(config *common.Config, lastBlockNumber uint64, lastBlockHeaderHash []byte, ...) (*BlockVerificationAssistant, error)
- func (a *BlockVerificationAssistant) Clone() CloneableUpdatableBlockVerifier
- func (a *BlockVerificationAssistant) UpdateBlockHeader(block *common.Block)
- func (a *BlockVerificationAssistant) UpdateConfig(configBlock *common.Block) error
- func (a *BlockVerificationAssistant) VerifyBlock(block *common.Block) error
- func (a *BlockVerificationAssistant) VerifyBlockAttestation(block *common.Block) error
- type BlockVerifierAssembler
- type CloneableUpdatableBlockVerifier
Constants ¶
This section is empty.
Variables ¶
var ErrNotAConfig = errors.New("not a config block")
Functions ¶
func ConfigFromBlock ¶
func ConfigFromBlock(block *common.Block) (*common.ConfigEnvelope, error)
ConfigFromBlock returns a ConfigEnvelope if exists, or a *ErrNotAConfig error. It may also return some other error in case parsing failed.
Types ¶
type BlockVerificationAssistant ¶
type BlockVerificationAssistant struct {
// contains filtered or unexported fields
}
BlockVerificationAssistant verifies the integrity and signatures of a block stream, while keeping a copy of the latest configuration.
Every time a config block arrives, it must first be verified using VerifyBlock and then used as an argument to the UpdateConfig method. The block stream could be composed of either: - full blocks, which are verified using the VerifyBlock method, or - block attestations (a header+metadata, with nil data) which are verified using the VerifyBlockAttestation method. In both cases, config blocks must arrive in full.
func NewBlockVerificationAssistant ¶
func NewBlockVerificationAssistant(configBlock *common.Block, lastBlock *common.Block, cryptoProvider bccsp.BCCSP, lg *flogging.FabricLogger) (*BlockVerificationAssistant, error)
NewBlockVerificationAssistant creates a new BlockVerificationAssistant from a config block. This is used in the orderer, where we always have access to the last config block.
func NewBlockVerificationAssistantFromConfig ¶
func NewBlockVerificationAssistantFromConfig(config *common.Config, lastBlockNumber uint64, lastBlockHeaderHash []byte, channelID string, cryptoProvider bccsp.BCCSP, lg *flogging.FabricLogger) (*BlockVerificationAssistant, error)
NewBlockVerificationAssistantFromConfig creates a new BlockVerificationAssistant from a common.Config. This is used in the peer, since when the peer starts from a snapshot we may not have access to the last config-block, only to the config object.
func (*BlockVerificationAssistant) Clone ¶
func (a *BlockVerificationAssistant) Clone() CloneableUpdatableBlockVerifier
func (*BlockVerificationAssistant) UpdateBlockHeader ¶
func (a *BlockVerificationAssistant) UpdateBlockHeader(block *common.Block)
UpdateBlockHeader saves the last block header that was verified and handled successfully. This must be called after VerifyBlock and VerifyBlockAttestation and successfully handling the block.
func (*BlockVerificationAssistant) UpdateConfig ¶
func (a *BlockVerificationAssistant) UpdateConfig(configBlock *common.Block) error
UpdateConfig sets the config by which blocks are verified. It is assumed that this config block had already been verified using the VerifyBlock method immediately prior to calling this method.
func (*BlockVerificationAssistant) VerifyBlock ¶
func (a *BlockVerificationAssistant) VerifyBlock(block *common.Block) error
VerifyBlock checks block integrity and its relation to the chain, and verifies the signatures.
func (*BlockVerificationAssistant) VerifyBlockAttestation ¶
func (a *BlockVerificationAssistant) VerifyBlockAttestation(block *common.Block) error
VerifyBlockAttestation does the same as VerifyBlock, except it assumes block.Data = nil. It therefore does not compute the block.Data.Hash() and compare it to the block.Header.DataHash. This is used when the orderer delivers a block with header & metadata only, as an attestation of block existence.
type BlockVerifierAssembler ¶
type BlockVerifierAssembler struct { Logger *flogging.FabricLogger BCCSP bccsp.BCCSP }
BlockVerifierAssembler creates a BlockVerifier out of a config envelope
func (*BlockVerifierAssembler) VerifierFromConfig ¶
func (bva *BlockVerifierAssembler) VerifierFromConfig(configuration *common.ConfigEnvelope, channel string) (protoutil.BlockVerifierFunc, error)
VerifierFromConfig creates a BlockVerifier from the given configuration.
type CloneableUpdatableBlockVerifier ¶
type CloneableUpdatableBlockVerifier interface { // VerifyBlock checks block integrity and its relation to the chain, and verifies the signatures. VerifyBlock(block *common.Block) error // VerifyBlockAttestation does the same as VerifyBlock, except it assumes block.Data = nil. It therefore does not // compute the block.Data.Hash() and compares it to the block.Header.DataHash. This is used when the orderer // delivers a block with header & metadata only, as an attestation of block existence. VerifyBlockAttestation(block *common.Block) error // UpdateConfig sets the config by which blocks are verified. It is assumed that this config block had already been // verified using the VerifyBlock method immediately prior to calling this method. UpdateConfig(configBlock *common.Block) error // UpdateBlockHeader saves the last block header that was verified and handled successfully. // This must be called after VerifyBlock and VerifyBlockAttestation and successfully handling the block. UpdateBlockHeader(block *common.Block) // Clone makes a copy from the current verifier, a copy that can keep being updated independently. Clone() CloneableUpdatableBlockVerifier }