deliverclient

package
v0.0.0-...-579b097 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 15, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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 (*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
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL