Documentation ¶
Index ¶
- Constants
- func EncodeExtra(cbftVersion byte, qc *QuorumCert) ([]byte, error)
- func ErrResp(code ErrCode, format string, v ...interface{}) error
- type BlockTree
- func (b *BlockTree) FindBlockAndQC(hash common.Hash, number uint64) (*types.Block, *QuorumCert)
- func (b *BlockTree) FindBlockByHash(hash common.Hash) *types.Block
- func (b *BlockTree) FindBlocksAndQCs(number uint64) ([]*types.Block, []*QuorumCert)
- func (b *BlockTree) FindForkedBlocksAndQCs(hash common.Hash, number uint64) ([]*types.Block, []*QuorumCert)
- func (b *BlockTree) InsertQCBlock(block *types.Block, qc *QuorumCert) (*types.Block, *types.Block)
- func (b *BlockTree) IsForked(hash common.Hash, number uint64) (common.Hash, uint64, bool)
- func (b *BlockTree) MarshalJSON() ([]byte, error)
- func (b *BlockTree) NewRoot(block *types.Block)
- func (b *BlockTree) PruneBlock(hash common.Hash, number uint64, clearFn func(*types.Block))
- func (b *BlockTree) Reset(root *types.Block, qc *QuorumCert)
- func (b *BlockTree) UnmarshalJSON(input []byte) error
- type CSMsgPool
- func (cs *CSMsgPool) AddPrepareBlock(blockIndex uint32, msg *MsgInfo)
- func (cs *CSMsgPool) AddPrepareQC(epoch, view uint64, blockIndex uint32, msg *MsgInfo)
- func (cs *CSMsgPool) AddPrepareVote(blockIndex uint32, validatorIndex uint32, msg *MsgInfo)
- func (cs *CSMsgPool) GetPrepareBlock(epoch, view uint64, index uint32) *MsgInfo
- func (cs *CSMsgPool) GetPrepareQC(epoch, view uint64, index uint32) *MsgInfo
- func (cs *CSMsgPool) GetPrepareVote(epoch, view uint64, blockIndex uint32, validatorIndex uint32) *MsgInfo
- func (cs *CSMsgPool) Purge(epoch, view uint64)
- type Config
- type ConsensusMsg
- type ErrCode
- type Message
- type MsgInfo
- type MsgPackage
- type OptionsConfig
- type QuorumCert
- type Signature
- type SyncCache
- type ViewChangeQC
- func (v *ViewChangeQC) AppendQuorumCert(viewChangeQC *ViewChangeQuorumCert)
- func (v ViewChangeQC) EqualAll(epoch uint64, viewNumber uint64) error
- func (v ViewChangeQC) ExistViewChange(epoch, viewNumber uint64, blockHash common.Hash) bool
- func (v ViewChangeQC) Len() int
- func (v ViewChangeQC) MaxBlock() (uint64, uint64, uint64, uint64, common.Hash, uint64)
- func (v ViewChangeQC) String() string
- type ViewChangeQuorumCert
- func (q ViewChangeQuorumCert) CannibalizeBytes() ([]byte, error)
- func (q *ViewChangeQuorumCert) Copy() *ViewChangeQuorumCert
- func (q *ViewChangeQuorumCert) HigherBlockView(blockEpoch, blockView uint64) bool
- func (q *ViewChangeQuorumCert) HigherQuorumCert(c *ViewChangeQuorumCert) bool
- func (q ViewChangeQuorumCert) Len() int
- func (q ViewChangeQuorumCert) String() string
Constants ¶
const ( NoneMode = iota // none consensus node PartMode // partial node FullMode // all node )
const ( ErrMsgTooLarge = iota ErrExtraStatusMsg ErrDecode ErrInvalidMsgCode ErrCbftProtocolVersionMismatch ErrNoStatusMsg ErrForkedBlock )
Define error enumeration values related to messages.
const (
SignatureLength = 64
)
Variables ¶
This section is empty.
Functions ¶
func EncodeExtra ¶
func EncodeExtra(cbftVersion byte, qc *QuorumCert) ([]byte, error)
EncodeExtra encode cbft version and `QuorumCert` as extra data.
Types ¶
type BlockTree ¶
type BlockTree struct {
// contains filtered or unexported fields
}
BlockTree used to store blocks that are not currently written to disk, Block of QC, LockQC. Every time you submit to blockTree, it is possible to start QC changes.
func NewBlockTree ¶
func NewBlockTree(root *types.Block, qc *QuorumCert) *BlockTree
func (*BlockTree) FindBlockAndQC ¶
FindBlockAndQC find the specified Block and its QC.
func (*BlockTree) FindBlockByHash ¶
FindBlockByHash find the specified Block by hash.
func (*BlockTree) FindBlocksAndQCs ¶ added in v1.0.0
func (b *BlockTree) FindBlocksAndQCs(number uint64) ([]*types.Block, []*QuorumCert)
FindBlocksAndQCs find the specified Block and its QC by blockNumber.
func (*BlockTree) FindForkedBlocksAndQCs ¶ added in v0.7.3
func (b *BlockTree) FindForkedBlocksAndQCs(hash common.Hash, number uint64) ([]*types.Block, []*QuorumCert)
FindForkedBlockAndQC find the specified Block and its QC.
func (*BlockTree) InsertQCBlock ¶
Insert a Block that has reached the QC state, returns the LockQC, Commit Block based on the height of the inserted Block
func (*BlockTree) MarshalJSON ¶
func (*BlockTree) PruneBlock ¶
Delete invalid branch Block
func (*BlockTree) UnmarshalJSON ¶ added in v1.0.0
type CSMsgPool ¶ added in v0.7.3
type CSMsgPool struct {
// contains filtered or unexported fields
}
func NewCSMsgPool ¶ added in v0.7.3
func NewCSMsgPool() *CSMsgPool
func (*CSMsgPool) AddPrepareBlock ¶ added in v0.7.3
Add prepare block to cache.
func (*CSMsgPool) AddPrepareQC ¶ added in v0.7.3
Add prepare block to cache.
func (*CSMsgPool) AddPrepareVote ¶ added in v0.7.3
Add prepare votes to cache.
func (*CSMsgPool) GetPrepareBlock ¶ added in v0.7.3
Get prepare block and clear it from the cache
func (*CSMsgPool) GetPrepareQC ¶ added in v0.7.3
Get prepare QC and clear it from the cache
type Config ¶
type Config struct { Sys *params.CbftConfig `json:"sys"` Option *OptionsConfig `json:"option"` }
type ConsensusMsg ¶
type ConsensusMsg interface { EpochNum() uint64 ViewNum() uint64 BlockNum() uint64 NodeIndex() uint32 CannibalizeBytes() ([]byte, error) Sign() []byte SetSign([]byte) }
Consensus message interface, all consensus message types must implement this interface.
type MsgInfo ¶
func NewInnerMsgInfo ¶ added in v0.7.3
type MsgPackage ¶
type MsgPackage struct {
// contains filtered or unexported fields
}
MsgPackage represents a specific message package. It contains the node ID, the message body, and the forwarding mode from the sender.
func NewMsgPackage ¶
func NewMsgPackage(pid string, msg Message, mode uint64) *MsgPackage
Create a new MsgPackage based on params.
func (*MsgPackage) Message ¶
func (m *MsgPackage) Message() Message
func (*MsgPackage) Mode ¶
func (m *MsgPackage) Mode() uint64
func (*MsgPackage) PeerID ¶
func (m *MsgPackage) PeerID() string
type OptionsConfig ¶
type OptionsConfig struct { NodePriKey *ecdsa.PrivateKey `json:"-"` NodeID discover.NodeID `json:"nodeID"` BlsPriKey *bls.SecretKey `json:"-"` WalMode bool `json:"walMode"` PeerMsgQueueSize uint64 `json:"peerMsgQueueSize"` EvidenceDir string `json:"evidenceDir"` MaxPingLatency int64 `json:"maxPingLatency"` // maxPingLatency is the time in milliseconds between Ping and Pong MaxQueuesLimit int64 `json:"maxQueuesLimit"` // The maximum value that a single node can send a message. BlacklistDeadline int64 `json:"blacklistDeadline"` // Blacklist expiration time. unit: minute. Period uint64 `json:"period"` Amount uint32 `json:"amount"` }
type QuorumCert ¶
type QuorumCert struct { Epoch uint64 `json:"epoch"` ViewNumber uint64 `json:"viewNumber"` BlockHash common.Hash `json:"blockHash"` BlockNumber uint64 `json:"blockNumber"` BlockIndex uint32 `json:"blockIndex"` Signature Signature `json:"signature"` ValidatorSet *utils.BitArray `json:"validatorSet"` }
func DecodeExtra ¶
func DecodeExtra(extra []byte) (byte, *QuorumCert, error)
DecodeExtra decode extra data as cbft version and `QuorumCert`.
func (QuorumCert) CannibalizeBytes ¶
func (q QuorumCert) CannibalizeBytes() ([]byte, error)
func (*QuorumCert) HigherBlockView ¶
func (q *QuorumCert) HigherBlockView(blockEpoch, blockView uint64) bool
if the two quorumCert have the same blockNumber
func (*QuorumCert) HigherQuorumCert ¶
func (q *QuorumCert) HigherQuorumCert(blockNumber uint64, blockEpoch, blockView uint64) bool
func (QuorumCert) Len ¶
func (q QuorumCert) Len() int
func (*QuorumCert) String ¶
func (q *QuorumCert) String() string
type Signature ¶
type Signature [SignatureLength]byte
func BytesToSignature ¶
func (Signature) MarshalText ¶
MarshalText returns the hex representation of a.
func (*Signature) UnmarshalJSON ¶
UnmarshalJSON parses a hash in hex syntax.
func (*Signature) UnmarshalText ¶
UnmarshalText parses a hash in hex syntax.
type SyncCache ¶
type SyncCache struct {
// contains filtered or unexported fields
}
func NewSyncCache ¶
func (*SyncCache) AddOrReplace ¶
type ViewChangeQC ¶
type ViewChangeQC struct {
QCs []*ViewChangeQuorumCert `json:"qcs"`
}
func (*ViewChangeQC) AppendQuorumCert ¶
func (v *ViewChangeQC) AppendQuorumCert(viewChangeQC *ViewChangeQuorumCert)
func (ViewChangeQC) EqualAll ¶
func (v ViewChangeQC) EqualAll(epoch uint64, viewNumber uint64) error
func (ViewChangeQC) ExistViewChange ¶
func (v ViewChangeQC) ExistViewChange(epoch, viewNumber uint64, blockHash common.Hash) bool
func (ViewChangeQC) Len ¶
func (v ViewChangeQC) Len() int
func (ViewChangeQC) String ¶
func (v ViewChangeQC) String() string
type ViewChangeQuorumCert ¶
type ViewChangeQuorumCert struct { Epoch uint64 `json:"epoch"` ViewNumber uint64 `json:"viewNumber"` BlockHash common.Hash `json:"blockHash"` BlockNumber uint64 `json:"blockNumber"` BlockEpoch uint64 `json:"blockEpoch"` BlockViewNumber uint64 `json:"blockViewNumber"` Signature Signature `json:"signature"` ValidatorSet *utils.BitArray `json:"validatorSet"` }
func (ViewChangeQuorumCert) CannibalizeBytes ¶
func (q ViewChangeQuorumCert) CannibalizeBytes() ([]byte, error)
func (*ViewChangeQuorumCert) Copy ¶
func (q *ViewChangeQuorumCert) Copy() *ViewChangeQuorumCert
func (*ViewChangeQuorumCert) HigherBlockView ¶
func (q *ViewChangeQuorumCert) HigherBlockView(blockEpoch, blockView uint64) bool
if the two quorumCert have the same blockNumber
func (*ViewChangeQuorumCert) HigherQuorumCert ¶
func (q *ViewChangeQuorumCert) HigherQuorumCert(c *ViewChangeQuorumCert) bool
func (ViewChangeQuorumCert) Len ¶
func (q ViewChangeQuorumCert) Len() int
func (ViewChangeQuorumCert) String ¶
func (q ViewChangeQuorumCert) String() string