Documentation ¶
Index ¶
- Constants
- Variables
- func DecodePatch(t string, bs []byte) (module.Patch, error)
- func IsCorruptedWAL(err error) bool
- func IsEOF(err error) bool
- func IsNotExist(err error) bool
- func IsUnexpectedEOF(err error) bool
- func New(c base.Chain, walDir string, wm WALManager, timestamper module.Timestamper, ...) *consensus
- func NewCommitVoteList(pcm module.BTPProofContextMap, msgs ...*VoteMessage) module.CommitVoteSet
- func NewCommitVoteSetFromBytes(bs []byte) module.CommitVoteSet
- func NewConsensus(c base.Chain, walDir string, timestamper module.Timestamper, ...) module.Consensus
- func NewEmptyCommitVoteList() module.CommitVoteSet
- func NewTestWAL() *testWAL
- func ResetWAL(height int64, dir string, voteListBytes []byte) error
- func StartConsensusWithLastVotes(cs module.Consensus, lastVoteData *LastVoteData) error
- func WALRecordBytesFromCommitVoteListBytes(bs []byte, h int64, bid []byte, result []byte, validators module.ValidatorList, ...) ([]byte, error)
- type BlockPartMessage
- type CommitVoteList
- func (bvl *CommitVoteList) BlockVoteSetBytes() []byte
- func (vl *CommitVoteList) Bytes() []byte
- func (vl *CommitVoteList) Hash() []byte
- func (vl *CommitVoteList) NTSDProofAt(i int) []byte
- func (vl *CommitVoteList) NTSDProofCount() int
- func (vl *CommitVoteList) RLPDecodeSelf(d codec.Decoder) error
- func (vl *CommitVoteList) RLPEncodeSelf(e codec.Encoder) error
- func (vl *CommitVoteList) String() string
- func (bvl *CommitVoteList) Timestamp() int64
- func (bvl *CommitVoteList) VerifyBlock(block module.BlockData, validators module.ValidatorList) ([]bool, error)
- func (bvl *CommitVoteList) VoteRound() int32
- type Engine
- type LastVoteData
- type Message
- type Part
- type PartSet
- type PartSetBuffer
- type PartSetID
- type PartSetIDAndAppData
- type ProposalMessage
- type RoundStateMessage
- type Syncer
- type VoteItem
- type VoteList
- type VoteListMessage
- type VoteMessage
- func (v *VoteMessage) Equal(v2 *voteBase) bool
- func (msg *VoteMessage) EqualExceptSigs(msg2 *VoteMessage) bool
- func (msg *VoteMessage) RLPDecodeSelf(d codec.Decoder) error
- func (msg *VoteMessage) RLPEncodeSelf(e codec.Encoder) error
- func (v *VoteMessage) RoundDecisionDigest() []byte
- func (v *VoteMessage) SetRoundDecision(bid []byte, bpsIDAndNTSVoteCount *PartSetIDAndAppData, ...)
- func (msg *VoteMessage) String() string
- func (msg *VoteMessage) Verify() error
- func (msg *VoteMessage) VerifyNTSDProofParts(pcm module.BTPProofContextMap, srcUID []byte, expValIndex int) error
- type VoteSet
- type VoteType
- type WALConfig
- type WALManager
- type WALReader
- type WALWriter
- type WalMessageWriter
Constants ¶
View Source
const ( ConfigEnginePriority = 2 ConfigSyncerPriority = 3 ConfigBlockPartSize = 1024 * 100 )
View Source
const ( ProtoProposal module.ProtocolInfo = iota << 8 ProtoBlockPart ProtoVote ProtoRoundState ProtoVoteList )
Variables ¶
View Source
var CsProtocols = []module.ProtocolInfo{ ProtoProposal, ProtoBlockPart, ProtoVote, ProtoVoteList, }
View Source
var SyncerProtocols = []module.ProtocolInfo{ ProtoBlockPart, ProtoRoundState, ProtoVoteList, }
Functions ¶
func IsCorruptedWAL ¶
func IsNotExist ¶
func IsUnexpectedEOF ¶
func New ¶ added in v0.9.10
func New( c base.Chain, walDir string, wm WALManager, timestamper module.Timestamper, bpp fastsync.BlockProofProvider, lastVoteData *LastVoteData, ) *consensus
func NewCommitVoteList ¶ added in v0.9.10
func NewCommitVoteList(pcm module.BTPProofContextMap, msgs ...*VoteMessage) module.CommitVoteSet
func NewCommitVoteSetFromBytes ¶
func NewCommitVoteSetFromBytes(bs []byte) module.CommitVoteSet
NewCommitVoteSetFromBytes returns VoteList from serialized bytes
func NewConsensus ¶
func NewConsensus( c base.Chain, walDir string, timestamper module.Timestamper, bpp fastsync.BlockProofProvider, ) module.Consensus
func NewEmptyCommitVoteList ¶ added in v0.9.10
func NewEmptyCommitVoteList() module.CommitVoteSet
func NewTestWAL ¶ added in v1.3.2
func NewTestWAL() *testWAL
func StartConsensusWithLastVotes ¶ added in v1.3.0
func StartConsensusWithLastVotes(cs module.Consensus, lastVoteData *LastVoteData) error
Types ¶
type BlockPartMessage ¶ added in v0.9.10
type BlockPartMessage struct { // V1 Fields // for debugging Height int64 Index uint16 BlockPart []byte // V2 Fields Nonce int32 }
func (*BlockPartMessage) String ¶ added in v0.9.10
func (msg *BlockPartMessage) String() string
func (*BlockPartMessage) Verify ¶ added in v0.9.10
func (msg *BlockPartMessage) Verify() error
type CommitVoteList ¶ added in v1.3.0
type CommitVoteList struct { NTSDProves [][]byte // contains filtered or unexported fields }
func (*CommitVoteList) BlockVoteSetBytes ¶ added in v1.3.0
func (bvl *CommitVoteList) BlockVoteSetBytes() []byte
func (*CommitVoteList) Bytes ¶ added in v1.3.0
func (vl *CommitVoteList) Bytes() []byte
func (*CommitVoteList) Hash ¶ added in v1.3.0
func (vl *CommitVoteList) Hash() []byte
func (*CommitVoteList) NTSDProofAt ¶ added in v1.3.0
func (vl *CommitVoteList) NTSDProofAt(i int) []byte
func (*CommitVoteList) NTSDProofCount ¶ added in v1.3.0
func (vl *CommitVoteList) NTSDProofCount() int
func (*CommitVoteList) RLPDecodeSelf ¶ added in v1.3.0
func (vl *CommitVoteList) RLPDecodeSelf(d codec.Decoder) error
func (*CommitVoteList) RLPEncodeSelf ¶ added in v1.3.0
func (vl *CommitVoteList) RLPEncodeSelf(e codec.Encoder) error
func (*CommitVoteList) String ¶ added in v1.3.0
func (vl *CommitVoteList) String() string
func (*CommitVoteList) VerifyBlock ¶ added in v1.3.0
type Engine ¶
type Engine interface { fastsync.BlockProofProvider GetCommitBlockParts(h int64) PartSet GetCommitPrecommits(h int64) *VoteList GetPrecommits(r int32) *VoteList // GetVotes returns union of a set of prevotes pv(i) where // pvMask.Get(i) == 0 and a set of precommits pc(i) where // pcMask.Get(i) == 0. For example, if the all bits for mask is 1, // no votes are returned. GetVotes(r int32, pvMask *bitArray, pcMask *bitArray) *VoteList GetRoundState() *peerRoundState Height() int64 Round() int32 Step() step ReceiveBlockPartMessage(msg *BlockPartMessage, unicast bool) (int, error) ReceiveVoteListMessage(msg *VoteListMessage, unicast bool) error ReceiveBlock(br fastsync.BlockResult) }
type LastVoteData ¶ added in v0.9.10
type Message ¶ added in v0.9.10
type Message interface { Verify() error // contains filtered or unexported methods }
type PartSet ¶
type PartSet interface { ID() *PartSetID Parts() int GetPart(int) Part IsComplete() bool NewReader() io.Reader AddPart(Part) error GetMask() *bitArray }
func NewPartSetFromID ¶ added in v0.9.10
type PartSetBuffer ¶
func NewPartSetBuffer ¶ added in v1.3.0
func NewPartSetBuffer(sz int) PartSetBuffer
type PartSetID ¶
func (*PartSetID) WithAppData ¶ added in v1.3.0
func (id *PartSetID) WithAppData(appData uint16) *PartSetIDAndAppData
type PartSetIDAndAppData ¶ added in v1.3.0
type PartSetIDAndAppData struct { // CountWord: MSB AppData(16) Count(16) // Use bitfield not to break existing message protocol CountWord uint32 Hash []byte }
func (*PartSetIDAndAppData) AppData ¶ added in v1.3.0
func (ida *PartSetIDAndAppData) AppData() uint16
func (*PartSetIDAndAppData) ID ¶ added in v1.3.0
func (ida *PartSetIDAndAppData) ID() *PartSetID
type ProposalMessage ¶ added in v0.9.10
type ProposalMessage struct {
// contains filtered or unexported fields
}
func NewProposalMessage ¶ added in v0.9.10
func NewProposalMessage() *ProposalMessage
func (*ProposalMessage) String ¶ added in v0.9.10
func (msg *ProposalMessage) String() string
func (*ProposalMessage) Verify ¶ added in v0.9.10
func (msg *ProposalMessage) Verify() error
type RoundStateMessage ¶ added in v0.9.10
type RoundStateMessage struct { Timestamp int64 // contains filtered or unexported fields }
func (RoundStateMessage) String ¶ added in v0.9.10
func (msg RoundStateMessage) String() string
func (*RoundStateMessage) Verify ¶ added in v0.9.10
func (msg *RoundStateMessage) Verify() error
type VoteList ¶ added in v1.3.2
type VoteList struct { Prototypes []voteBase VoteItems []VoteItem }
func NewVoteList ¶ added in v1.3.2
func NewVoteList() *VoteList
func (*VoteList) AddVote ¶ added in v1.3.2
func (vl *VoteList) AddVote(msg *VoteMessage)
func (*VoteList) Get ¶ added in v1.3.2
func (vl *VoteList) Get(i int) *VoteMessage
type VoteListMessage ¶ added in v1.3.2
type VoteListMessage struct {
VoteList *VoteList
}
func (VoteListMessage) String ¶ added in v1.3.2
func (msg VoteListMessage) String() string
func (*VoteListMessage) Verify ¶ added in v1.3.2
func (msg *VoteListMessage) Verify() error
type VoteMessage ¶ added in v1.3.0
type VoteMessage struct { Timestamp int64 NTSDProofParts [][]byte // contains filtered or unexported fields }
func NewVoteMessage ¶ added in v0.9.10
func NewVoteMessage( w module.Wallet, voteType VoteType, height int64, round int32, id []byte, partSetID *PartSetID, ts int64, ntsHashEntries []module.NTSHashEntryFormat, ntsdProofParts [][]byte, ntsVoteCount int, ) *VoteMessage
NewVoteMessage returns a new VoteMessage. Used only for test.
func NewVoteMessageFromBlock ¶ added in v1.3.0
func NewVoteMessageFromBlock( w module.Wallet, wp module.WalletProvider, blk module.BlockData, round int32, voteType VoteType, bpsIDAndNTSVoteCount *PartSetIDAndAppData, ts int64, nid int, pcm module.BTPProofContextMap, ) (*VoteMessage, error)
NewVoteMessageFromBlock creates a new VoteMessage from block data. pcm is blk.Height()-1's nextPCM. Used only for test
func (*VoteMessage) EqualExceptSigs ¶ added in v1.3.0
func (msg *VoteMessage) EqualExceptSigs(msg2 *VoteMessage) bool
func (*VoteMessage) RLPDecodeSelf ¶ added in v1.3.0
func (msg *VoteMessage) RLPDecodeSelf(d codec.Decoder) error
func (*VoteMessage) RLPEncodeSelf ¶ added in v1.3.0
func (msg *VoteMessage) RLPEncodeSelf(e codec.Encoder) error
func (*VoteMessage) RoundDecisionDigest ¶ added in v1.3.0
func (v *VoteMessage) RoundDecisionDigest() []byte
RoundDecisionDigest returns digest for a vote. The digest values of two votes are different if their BlockID, BlockPartSetIDAndNTSVoteCount, len(NTSVotes), NTSVotes[i].NetworkTypeID or NTSVotes[i].NetworkTypeSectionHash is different where 0 <= i < len(NTSVotes).
func (*VoteMessage) SetRoundDecision ¶ added in v1.3.0
func (v *VoteMessage) SetRoundDecision(bid []byte, bpsIDAndNTSVoteCount *PartSetIDAndAppData, ntsVoteBases []ntsVoteBase)
func (*VoteMessage) String ¶ added in v1.3.0
func (msg *VoteMessage) String() string
func (*VoteMessage) Verify ¶ added in v1.3.0
func (msg *VoteMessage) Verify() error
func (*VoteMessage) VerifyNTSDProofParts ¶ added in v1.3.0
func (msg *VoteMessage) VerifyNTSDProofParts( pcm module.BTPProofContextMap, srcUID []byte, expValIndex int, ) error
type VoteSet ¶ added in v0.9.10
type VoteSet interface { // CommitVoteSet converts VoteSet to CommitVoteSet. CommitVoteSet(pcm module.BTPProofContextMap) (module.CommitVoteSet, error) Add(idx int, vote interface{}) bool }
type WALManager ¶
type WALReader ¶
type WALReader interface { ReadBytes() ([]byte, error) // Close closes reader. Multiple call of Close is safe. Close() error // CloseAndRepair closes and repairs UnexpectedEOF or CorruptedWAL by // truncating. CloseAndRepair() error }
func OpenWALForRead ¶
type WalMessageWriter ¶ added in v1.3.2
type WalMessageWriter struct {
WALWriter
}
func (*WalMessageWriter) WriteMessage ¶ added in v1.3.2
func (w *WalMessageWriter) WriteMessage(msg Message) error
func (*WalMessageWriter) WriteMessageBytes ¶ added in v1.3.2
func (w *WalMessageWriter) WriteMessageBytes(sp uint16, msg []byte) error
Source Files ¶
Click to show internal directories.
Click to hide internal directories.