Documentation
¶
Index ¶
- Constants
- func EncodeMsg(msg ConsensusMessage) ([]byte, error)
- func MajorityTwoThird(voterNum, committeeSize uint32) bool
- func Number(blockID types.Bytes32) uint32
- func QCEncodeBytes(qc *QuorumCert) []byte
- func RegisterConsensusMessages(cdc *amino.Codec)
- type Block
- func (b *Block) AppHash() cmtbytes.HexBytes
- func (b *Block) Body() *Body
- func (b *Block) CompactString() string
- func (b *Block) DecodeRLP(s *rlp.Stream) error
- func (b *Block) EncodeRLP(w io.Writer) error
- func (b *Block) Epoch() uint64
- func (b *Block) GetQC() *QuorumCert
- func (b *Block) Header() *Header
- func (b *Block) ID() types.Bytes32
- func (b *Block) IsKBlock() bool
- func (b *Block) LastKBlock() uint32
- func (b *Block) NextValidatorsHash() cmtbytes.HexBytes
- func (b *Block) Nonce() uint64
- func (b *Block) Number() uint32
- func (b *Block) Oneliner() string
- func (b *Block) ParentID() types.Bytes32
- func (b *Block) ProposerIndex() uint32
- func (b *Block) SetQC(qc *QuorumCert) *Block
- func (b *Block) Size() uint64
- func (b *Block) String() string
- func (b *Block) Timestamp() uint64
- func (b *Block) ToBytes() []byte
- func (b *Block) Transactions() types.Transactions
- func (b *Block) TxsRoot() cmtbytes.HexBytes
- func (b *Block) ValidatorsHash() cmtbytes.HexBytes
- func (b *Block) VerifyQC(escortQC *QuorumCert, blsMaster *types.BlsMaster, ...) (bool, error)
- type Body
- type Builder
- func (b *Builder) Build() *Block
- func (b *Builder) LastKBlock(height uint32) *Builder
- func (b *Builder) NextValidatorsHash(hash []byte) *Builder
- func (b *Builder) Nonce(nonce uint64) *Builder
- func (b *Builder) ParentID(id types.Bytes32) *Builder
- func (b *Builder) ProposerIndex(index uint32) *Builder
- func (b *Builder) QC(qc *QuorumCert) *Builder
- func (b *Builder) Timestamp(ts uint64) *Builder
- func (b *Builder) Transaction(tx []byte) *Builder
- func (b *Builder) Tx(tx cmttypes.Tx) *Builder
- func (b *Builder) ValidatorsHash(hash []byte) *Builder
- type ConsensusMessage
- type DraftBlock
- type DraftQC
- type EscortedBlock
- type Header
- type PMProposalMessage
- func (m *PMProposalMessage) DecodeBlock() *Block
- func (m *PMProposalMessage) GetEpoch() uint64
- func (m *PMProposalMessage) GetMsgHash() types.Bytes32
- func (m *PMProposalMessage) GetRound() uint32
- func (m *PMProposalMessage) GetSignerIndex() uint32
- func (m *PMProposalMessage) GetType() string
- func (m *PMProposalMessage) SetMsgSignature(msgSignature []byte)
- func (m *PMProposalMessage) String() string
- func (m *PMProposalMessage) VerifyMsgSignature(cmtPubKey cmtcrypto.PubKey) bool
- type PMQueryMessage
- func (m *PMQueryMessage) GetEpoch() uint64
- func (m *PMQueryMessage) GetMsgHash() types.Bytes32
- func (m *PMQueryMessage) GetRound() uint32
- func (m *PMQueryMessage) GetSignerIndex() uint32
- func (m *PMQueryMessage) GetType() string
- func (m *PMQueryMessage) SetMsgSignature(msgSignature []byte)
- func (m *PMQueryMessage) String() string
- func (m *PMQueryMessage) VerifyMsgSignature(cmtPubKey cmtcrypto.PubKey) bool
- type PMTimeoutMessage
- func (m *PMTimeoutMessage) DecodeQCHigh() *QuorumCert
- func (m *PMTimeoutMessage) GetEpoch() uint64
- func (m *PMTimeoutMessage) GetMsgHash() types.Bytes32
- func (m *PMTimeoutMessage) GetRound() uint32
- func (m *PMTimeoutMessage) GetSignerIndex() uint32
- func (m *PMTimeoutMessage) GetType() string
- func (m *PMTimeoutMessage) SetMsgSignature(msgSignature []byte)
- func (m *PMTimeoutMessage) String() string
- func (m *PMTimeoutMessage) VerifyMsgSignature(cmtPubKey cmtcrypto.PubKey) bool
- type PMVoteMessage
- func (m *PMVoteMessage) GetEpoch() uint64
- func (m *PMVoteMessage) GetMsgHash() types.Bytes32
- func (m *PMVoteMessage) GetRound() uint32
- func (m *PMVoteMessage) GetSignerIndex() uint32
- func (m *PMVoteMessage) GetType() string
- func (m *PMVoteMessage) SetMsgSignature(msgSignature []byte)
- func (m *PMVoteMessage) String() string
- func (m *PMVoteMessage) VerifyMsgSignature(cmtPubKey cmtcrypto.PubKey) bool
- type QuorumCert
- type Raw
Constants ¶
const (
DoubleSign = int(1)
)
Variables ¶
This section is empty.
Functions ¶
func EncodeMsg ¶
func EncodeMsg(msg ConsensusMessage) ([]byte, error)
func MajorityTwoThird ¶
Types ¶
type Block ¶
type Block struct {
BlockHeader *Header
Txs types.Transactions
QC *QuorumCert
// contains filtered or unexported fields
}
Block is an immutable block type.
func BlockDecodeFromBytes ¶
func Compose ¶
func Compose(header *Header, txs types.Transactions) *Block
Create new committee Info Compose compose a block with all needed components Note: This method is usually to recover a block by its portions, and the TxsRoot is not verified. To build up a block, use a Builder.
func (*Block) CompactString ¶
func (*Block) Epoch ¶
if the block is the first mblock, get epoch from committee otherwise get epoch from QC
func (*Block) GetQC ¶
func (b *Block) GetQC() *QuorumCert
func (*Block) LastKBlock ¶
LastBlocID returns id of parent block.
func (*Block) NextValidatorsHash ¶
func (*Block) ProposerIndex ¶
func (*Block) Size ¶
Size returns the true RLP encoded storage size of the block, either by encoding and returning it, or returning a previously cached value.
func (*Block) Transactions ¶
func (b *Block) Transactions() types.Transactions
Transactions returns a copy of transactions.
func (*Block) ValidatorsHash ¶
func (*Block) VerifyQC ¶
func (b *Block) VerifyQC(escortQC *QuorumCert, blsMaster *types.BlsMaster, committee *cmttypes.ValidatorSet) (bool, error)
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder only build header and txs. committee info and kblock data built by app. Builder to make it easy to build a block object.
func (*Builder) LastKBlock ¶
func (*Builder) NextValidatorsHash ¶
func (*Builder) ProposerIndex ¶
func (*Builder) QC ¶
func (b *Builder) QC(qc *QuorumCert) *Builder
func (*Builder) Transaction ¶
Transaction add a transaction.
func (*Builder) ValidatorsHash ¶
type ConsensusMessage ¶
type ConsensusMessage interface {
GetSignerIndex() uint32
GetEpoch() uint64
GetType() string
GetRound() uint32
String() string
GetMsgHash() types.Bytes32
SetMsgSignature(signature []byte)
VerifyMsgSignature(cmtPubKey cmtcrypto.PubKey) bool
}
ConsensusMessage is a message that can be sent and received on the Reactor
func DecodeMsg ¶
func DecodeMsg(raw []byte) (ConsensusMessage, error)
type DraftBlock ¶
type DraftBlock struct {
Msg ConsensusMessage
Height uint32
Round uint32
Parent *DraftBlock
Justify *DraftQC
Committed bool // used for DraftBlock created from database
ProposedBlock *Block
SuccessProcessed bool
ProcessError error
}
definition for DraftBlock
func (*DraftBlock) ToString ¶
func (pb *DraftBlock) ToString() string
type DraftQC ¶
type DraftQC struct {
//Height/QCround must be the same with QCNode.Height/QCnode.Round
QCNode *DraftBlock // this is the QCed block
QC *QuorumCert // this is the actual QC that goes into the next block
}
definition for DraftQC
func NewDraftQC ¶
func NewDraftQC(qc *QuorumCert, qcNode *DraftBlock) *DraftQC
type EscortedBlock ¶
type EscortedBlock struct {
Block *Block
EscortQC *QuorumCert
}
type Header ¶
type Header struct {
ParentID types.Bytes32
Timestamp uint64
ProposerIndex uint32
TxsRoot cmtbytes.HexBytes
LastKBlock uint32
Nonce uint64 //
QCHash cmtbytes.HexBytes // hash of QC
ValidatorsHash cmtbytes.HexBytes // hash of validator set
NextValidatorsHash cmtbytes.HexBytes // hash of next validator set
AppHash cmtbytes.HexBytes //
// contains filtered or unexported fields
}
Header contains almost all information about a block, except block body. It's immutable.
func (*Header) ID ¶
ID computes id of block. The block ID is defined as: blockNumber + hash(signingHash, proposerIndex)[4:].
func (*Header) SigningHash ¶
SigningHash computes hash of all header fields excluding signature.
type PMProposalMessage ¶
type PMProposalMessage struct {
Timestamp time.Time
Epoch uint64
Round uint32
RawBlock []byte
TimeoutCert *types.TimeoutCert
MsgSignature []byte
// contains filtered or unexported fields
}
PMProposalMessage is sent when a new block is proposed
func (*PMProposalMessage) DecodeBlock ¶
func (m *PMProposalMessage) DecodeBlock() *Block
func (*PMProposalMessage) GetEpoch ¶
func (m *PMProposalMessage) GetEpoch() uint64
func (*PMProposalMessage) GetMsgHash ¶
func (m *PMProposalMessage) GetMsgHash() types.Bytes32
GetMsgHash computes hash of all header fields excluding signature.
func (*PMProposalMessage) GetRound ¶
func (m *PMProposalMessage) GetRound() uint32
func (*PMProposalMessage) GetSignerIndex ¶
func (m *PMProposalMessage) GetSignerIndex() uint32
func (*PMProposalMessage) GetType ¶
func (m *PMProposalMessage) GetType() string
func (*PMProposalMessage) SetMsgSignature ¶
func (m *PMProposalMessage) SetMsgSignature(msgSignature []byte)
func (*PMProposalMessage) String ¶
func (m *PMProposalMessage) String() string
String returns a string representation.
func (*PMProposalMessage) VerifyMsgSignature ¶
func (m *PMProposalMessage) VerifyMsgSignature(cmtPubKey cmtcrypto.PubKey) bool
type PMQueryMessage ¶
type PMQueryMessage struct {
Timestamp time.Time
Epoch uint64
SignerIndex uint32
LastCommitted types.Bytes32
MsgSignature []byte
}
func (*PMQueryMessage) GetEpoch ¶
func (m *PMQueryMessage) GetEpoch() uint64
func (*PMQueryMessage) GetMsgHash ¶
func (m *PMQueryMessage) GetMsgHash() types.Bytes32
GetMsgHash computes hash of all header fields excluding signature.
func (*PMQueryMessage) GetRound ¶
func (m *PMQueryMessage) GetRound() uint32
func (*PMQueryMessage) GetSignerIndex ¶
func (m *PMQueryMessage) GetSignerIndex() uint32
func (*PMQueryMessage) GetType ¶
func (m *PMQueryMessage) GetType() string
func (*PMQueryMessage) SetMsgSignature ¶
func (m *PMQueryMessage) SetMsgSignature(msgSignature []byte)
func (*PMQueryMessage) String ¶
func (m *PMQueryMessage) String() string
String returns a string representation.
func (*PMQueryMessage) VerifyMsgSignature ¶
func (m *PMQueryMessage) VerifyMsgSignature(cmtPubKey cmtcrypto.PubKey) bool
type PMTimeoutMessage ¶
type PMTimeoutMessage struct {
Timestamp time.Time
Epoch uint64
SignerIndex uint32
WishRound uint32
// local QCHigh
QCHigh []byte
// timeout vote
WishVoteHash [32]byte
WishVoteSig []byte // signature
// last vote for proposal
LastVoteRound uint32
LastVoteBlockID types.Bytes32
LastVoteSignature []byte
MsgSignature []byte
// contains filtered or unexported fields
}
PMTimeoutMessage is sent to the next leader in these two senarios
func (*PMTimeoutMessage) DecodeQCHigh ¶
func (m *PMTimeoutMessage) DecodeQCHigh() *QuorumCert
func (*PMTimeoutMessage) GetEpoch ¶
func (m *PMTimeoutMessage) GetEpoch() uint64
func (*PMTimeoutMessage) GetMsgHash ¶
func (m *PMTimeoutMessage) GetMsgHash() types.Bytes32
GetMsgHash computes hash of all header fields excluding signature.
func (*PMTimeoutMessage) GetRound ¶
func (m *PMTimeoutMessage) GetRound() uint32
func (*PMTimeoutMessage) GetSignerIndex ¶
func (m *PMTimeoutMessage) GetSignerIndex() uint32
func (*PMTimeoutMessage) GetType ¶
func (m *PMTimeoutMessage) GetType() string
func (*PMTimeoutMessage) SetMsgSignature ¶
func (m *PMTimeoutMessage) SetMsgSignature(msgSignature []byte)
func (*PMTimeoutMessage) String ¶
func (m *PMTimeoutMessage) String() string
String returns a string representation.
func (*PMTimeoutMessage) VerifyMsgSignature ¶
func (m *PMTimeoutMessage) VerifyMsgSignature(cmtPubKey cmtcrypto.PubKey) bool
type PMVoteMessage ¶
type PMVoteMessage struct {
Timestamp time.Time
Epoch uint64
SignerIndex uint32
VoteRound uint32
VoteBlockID types.Bytes32
VoteSignature []byte //bls.Signature
MsgSignature []byte
}
PMVoteMessage is sent when voting for a proposal (or lack thereof).
func (*PMVoteMessage) GetEpoch ¶
func (m *PMVoteMessage) GetEpoch() uint64
func (*PMVoteMessage) GetMsgHash ¶
func (m *PMVoteMessage) GetMsgHash() types.Bytes32
GetMsgHash computes hash of all header fields excluding signature.
func (*PMVoteMessage) GetRound ¶
func (m *PMVoteMessage) GetRound() uint32
func (*PMVoteMessage) GetSignerIndex ¶
func (m *PMVoteMessage) GetSignerIndex() uint32
func (*PMVoteMessage) GetType ¶
func (m *PMVoteMessage) GetType() string
func (*PMVoteMessage) SetMsgSignature ¶
func (m *PMVoteMessage) SetMsgSignature(msgSignature []byte)
func (*PMVoteMessage) String ¶
func (m *PMVoteMessage) String() string
String returns a string representation.
func (*PMVoteMessage) VerifyMsgSignature ¶
func (m *PMVoteMessage) VerifyMsgSignature(cmtPubKey cmtcrypto.PubKey) bool
type QuorumCert ¶
type QuorumCert struct {
Epoch uint64
Round uint32
BlockID types.Bytes32
AggSig []byte
BitArray *cmn.BitArray
}
func GenesisEscortQC ¶
func GenesisEscortQC(b *Block, vsetCount int) *QuorumCert
func QCDecodeFromBytes ¶
func QCDecodeFromBytes(bytes []byte) (*QuorumCert, error)
func (*QuorumCert) CompactString ¶
func (qc *QuorumCert) CompactString() string
func (*QuorumCert) DecodeRLP ¶
func (qc *QuorumCert) DecodeRLP(s *rlp.Stream) error
DecodeRLP implements rlp.Decoder.
func (*QuorumCert) EncodeRLP ¶
func (qc *QuorumCert) EncodeRLP(w io.Writer) error
EncodeRLP implements rlp.Encoder.
func (*QuorumCert) Hash ¶
func (qc *QuorumCert) Hash() []byte
func (*QuorumCert) Number ¶
func (qc *QuorumCert) Number() uint32
func (*QuorumCert) String ¶
func (qc *QuorumCert) String() string
func (*QuorumCert) ToBytes ¶
func (qc *QuorumCert) ToBytes() []byte
type Raw ¶
type Raw []byte
Raw allows to partially decode components of a block.
func (Raw) DecodeBlockBody ¶
DecodeBlockBody decode block header & tx part.
func (Raw) DecodeHeader ¶
DecodeHeader decode only the header.