Documentation ¶
Index ¶
- type ChangeView
- type ChangeViewReason
- type Commit
- type ConsensusPayload
- type MessageType
- type Payload
- func (p *Payload) DecodeBinary(r *io.BinReader)
- func (p Payload) EncodeBinary(w *io.BinWriter)
- func (m Payload) GetChangeView() ChangeView
- func (m Payload) GetCommit() Commit
- func (m Payload) GetPrepareRequest() PrepareRequest
- func (m Payload) GetPrepareResponse() PrepareResponse
- func (m Payload) GetRecoveryMessage() RecoveryMessage
- func (m Payload) GetRecoveryRequest() RecoveryRequest
- func (p *Payload) Hash() common.Hash
- func (p Payload) Height() uint32
- func (p Payload) MarshalUnsigned() []byte
- func (m Payload) Payload() interface{}
- func (p Payload) PrevHash() common.Hash
- func (p *Payload) SetHeight(h uint32)
- func (m *Payload) SetPayload(p interface{})
- func (p *Payload) SetPrevHash(h common.Hash)
- func (m *Payload) SetType(t MessageType)
- func (p *Payload) SetValidatorIndex(i uint16)
- func (p *Payload) SetVersion(v uint32)
- func (m *Payload) SetViewNumber(view byte)
- func (m Payload) Type() MessageType
- func (p *Payload) UnmarshalUnsigned(data []byte) error
- func (p Payload) ValidatorIndex() uint16
- func (p Payload) Version() uint32
- func (m Payload) ViewNumber() byte
- type PrepareRequest
- type PrepareResponse
- type RecoveryMessage
- type RecoveryRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChangeView ¶
type ChangeView interface { // NewViewNumber returns proposed view number. NewViewNumber() byte // SetNewViewNumber sets the proposed view number. SetNewViewNumber(view byte) // Timestamp returns message's timestamp. Timestamp() uint64 // SetTimestamp sets message's timestamp. SetTimestamp(ts uint64) // Reason returns change view reason. Reason() ChangeViewReason // SetReason sets change view reason. SetReason(reason ChangeViewReason) }
ChangeView represents dBFT ChangeView message.
func NewChangeView ¶
func NewChangeView() ChangeView
NewChangeView returns minimal ChangeView implementation.
type ChangeViewReason ¶
type ChangeViewReason byte
ChangeViewReason represents a view change reason code.
const ( CVTimeout ChangeViewReason = 0x0 // Timeout CVChangeAgreement ChangeViewReason = 0x1 // ChangeAgreement CVTxNotFound ChangeViewReason = 0x2 // TxNotFound CVTxRejectedByPolicy ChangeViewReason = 0x3 // TxRejectedByPolicy CVTxInvalid ChangeViewReason = 0x4 // TxInvalid CVBlockRejectedByPolicy ChangeViewReason = 0x5 // BlockRejectedByPolicy CVUnknown ChangeViewReason = 0xff // Unknown )
func (ChangeViewReason) String ¶
func (i ChangeViewReason) String() string
type Commit ¶
type Commit interface { // Signature returns commit's signature field // which is a block signature for the current epoch. Signature() []byte // SetSignature sets commit's signature. SetSignature(signature []byte) }
Commit is an interface for dBFT Commit message.
type ConsensusPayload ¶
type ConsensusPayload interface { // ValidatorIndex returns index of validator from which // payload was originated from. ValidatorIndex() uint16 // SetValidator index sets validator index. SetValidatorIndex(i uint16) Height() uint32 SetHeight(h uint32) // Hash returns 32-byte checksum of the payload. Hash() common.Hash // contains filtered or unexported methods }
ConsensusPayload is a generic payload type which is exchanged between the nodes.
func NewConsensusPayload ¶
func NewConsensusPayload() ConsensusPayload
NewConsensusPayload returns minimal ConsensusPayload implementation.
type MessageType ¶
type MessageType byte
MessageType is a type for dBFT consensus messages.
const ( ChangeViewType MessageType = 0x00 PrepareRequestType MessageType = 0x20 PrepareResponseType MessageType = 0x21 CommitType MessageType = 0x30 RecoveryRequestType MessageType = 0x40 RecoveryMessageType MessageType = 0x41 )
6 following constants enumerate all possible type of consensus message.
func (MessageType) String ¶
func (m MessageType) String() string
String implements fmt.Stringer interface.
type Payload ¶
type Payload struct {
// contains filtered or unexported fields
}
Payload represents minimal payload containing all necessary fields.
func (*Payload) DecodeBinary ¶
DecodeBinary implements io.Serializable interface.
func (Payload) EncodeBinary ¶
EncodeBinary implements io.Serializable interface.
func (Payload) GetChangeView ¶
func (m Payload) GetChangeView() ChangeView
func (Payload) GetPrepareRequest ¶
func (m Payload) GetPrepareRequest() PrepareRequest
func (Payload) GetPrepareResponse ¶
func (m Payload) GetPrepareResponse() PrepareResponse
func (Payload) GetRecoveryMessage ¶
func (m Payload) GetRecoveryMessage() RecoveryMessage
func (Payload) GetRecoveryRequest ¶
func (m Payload) GetRecoveryRequest() RecoveryRequest
func (Payload) MarshalUnsigned ¶
MarshalUnsigned implements ConsensusPayload interface.
func (Payload) Payload ¶
func (m Payload) Payload() interface{}
Payload implements ConsensusMessage interface.
func (*Payload) SetPayload ¶
func (m *Payload) SetPayload(p interface{})
SetPayload implements ConsensusMessage interface.
func (*Payload) SetPrevHash ¶
SetPrevHash implements ConsensusPayload interface.
func (*Payload) SetType ¶
func (m *Payload) SetType(t MessageType)
SetType implements ConsensusMessage interface.
func (*Payload) SetValidatorIndex ¶
SetValidatorIndex implements ConsensusPayload interface.
func (*Payload) SetVersion ¶
SetVersion implements ConsensusPayload interface.
func (*Payload) SetViewNumber ¶
func (m *Payload) SetViewNumber(view byte)
SetViewNumber implements ConsensusMessage interface.
func (Payload) Type ¶
func (m Payload) Type() MessageType
Type implements ConsensusMessage interface.
func (*Payload) UnmarshalUnsigned ¶
UnmarshalUnsigned implements ConsensusPayload interface.
func (Payload) ValidatorIndex ¶
ValidatorIndex implements ConsensusPayload interface.
func (Payload) ViewNumber ¶
func (m Payload) ViewNumber() byte
ViewNumber implements ConsensusMessage interface.
type PrepareRequest ¶
type PrepareRequest interface { // Timestamp returns this message's timestamp. Timestamp() uint64 // SetTimestamp sets timestamp of this message. SetTimestamp(ts uint64) // Nonce is a random nonce. Nonce() uint64 // SetNonce sets Nonce. SetNonce(nonce uint64) // TransactionHashes returns hashes of all transaction in a proposed block. TransactionHashes() []common.Hash // SetTransactionHashes sets transaction's hashes. SetTransactionHashes(hs []common.Hash) // NextConsensus returns hash which is based on which validators will // try to agree on a block in the current epoch. NextConsensus() common.Address // SetNextConsensus sets next consensus field. SetNextConsensus(nc common.Address) }
PrepareRequest represents dBFT PrepareRequest message.
func NewPrepareRequest ¶
func NewPrepareRequest() PrepareRequest
NewPrepareRequest returns minimal prepareRequest implementation.
type PrepareResponse ¶
type PrepareResponse interface { // PreparationHash returns the hash of PrepareRequest payload // for this epoch. PreparationHash() common.Hash // SetPreparationHash sets preparations hash. SetPreparationHash(h common.Hash) }
PrepareResponse represents dBFT PrepareResponse message.
func NewPrepareResponse ¶
func NewPrepareResponse() PrepareResponse
NewPrepareResponse returns minimal PrepareResponse implementation.
type RecoveryMessage ¶
type RecoveryMessage interface { // AddPayload adds payload from this epoch to be recovered. AddPayload(p ConsensusPayload) // GetPrepareRequest returns PrepareRequest to be processed. GetPrepareRequest(p ConsensusPayload, validators []*keys.PublicKey, primary uint16) ConsensusPayload // GetPrepareResponses returns a slice of PrepareResponse in any order. GetPrepareResponses(p ConsensusPayload, validators []*keys.PublicKey) []ConsensusPayload // GetChangeView returns a slice of ChangeView in any order. GetChangeViews(p ConsensusPayload, validators []*keys.PublicKey) []ConsensusPayload // GetCommits returns a slice of Commit in any order. GetCommits(p ConsensusPayload, validators []*keys.PublicKey) []ConsensusPayload // PreparationHash returns has of PrepareRequest payload for this epoch. // It can be useful in case only PrepareResponse payloads were received. PreparationHash() *common.Hash // SetPreparationHash sets preparation hash. SetPreparationHash(h *common.Hash) }
RecoveryMessage represents dBFT Recovery message.
func NewRecoveryMessage ¶
func NewRecoveryMessage() RecoveryMessage
NewRecoveryMessage returns minimal RecoveryMessage implementation.
type RecoveryRequest ¶
type RecoveryRequest interface { // Timestamp returns this message's timestamp. Timestamp() uint64 // SetTimestamp sets this message's timestamp. SetTimestamp(ts uint64) }
RecoveryRequest represents dBFT RecoveryRequest message.
func NewRecoveryRequest ¶
func NewRecoveryRequest() RecoveryRequest
NewRecoveryRequest returns minimal RecoveryRequest implementation.