Documentation ¶
Index ¶
- Constants
- func BuildIsingPayload(msg IsingMessage, sender *crypto.PubKey) (*message.IsingPayload, error)
- func HeightHashToString(height uint32, blockHash Uint256) string
- func StartIsingConsensus(account *vault.Account, node protocol.Noder)
- func StringToHeightHash(str string) (uint32, Uint256)
- type BlockFlooding
- type BlockHistoryPayload
- type BlockInfo
- type BlockWithVotes
- type BuiltinMining
- type ConsensusService
- type IsingMessage
- type IsingMessageType
- type MindChanging
- type Mining
- type Notice
- type ProbeService
- func (ps *ProbeService) BuildNotice() *Notice
- func (ps *ProbeService) HandleStateResponseMsg(msg *StateResponse, sender *crypto.PubKey)
- func (ps *ProbeService) ReceiveConsensusMsg(v interface{})
- func (ps *ProbeService) Reset()
- func (ps *ProbeService) SendConsensusMsg(msg IsingMessage) error
- func (ps *ProbeService) Start() error
- type ProbeType
- type Proposal
- type ProposerCache
- type ProposerInfo
- type ProposerService
- func (ps *ProposerService) BlockPersistCompleted(v interface{})
- func (ps *ProposerService) BlockSyncingFinished(v interface{})
- func (ps *ProposerService) ChangeProposer()
- func (ps *ProposerService) ConsensusRoutine(vType voting.VotingContentType, isProposer bool)
- func (ps *ProposerService) CurrentVoting(vType voting.VotingContentType) voting.Voting
- func (ps *ProposerService) GetReceiverNode(nids []uint64) []protocol.Noder
- func (ps *ProposerService) HandleBlockFloodingMsg(bfMsg *BlockFlooding, sender *crypto.PubKey)
- func (ps *ProposerService) HandleMindChangingMsg(mindChanging *MindChanging, sender *crypto.PubKey)
- func (ps *ProposerService) HandleProposalMsg(proposal *Proposal, sender *crypto.PubKey)
- func (ps *ProposerService) HandleRequestMsg(req *Request, sender *crypto.PubKey)
- func (ps *ProposerService) HandleResponseMsg(resp *Response, sender *crypto.PubKey)
- func (ps *ProposerService) HandleStateProbeMsg(msg *StateProbe, sender *crypto.PubKey)
- func (ps *ProposerService) Initialize(vType voting.VotingContentType)
- func (ps *ProposerService) IsBlockProposer() bool
- func (ps *ProposerService) ProbeRoutine()
- func (ps *ProposerService) ProduceNewBlock()
- func (ps *ProposerService) ProposerRoutine()
- func (ps *ProposerService) ReceiveConsensusMsg(v interface{})
- func (ps *ProposerService) SendConsensusMsg(msg IsingMessage, to []protocol.Noder) error
- func (ps *ProposerService) SendNewProposal(votingHeight uint32, vType voting.VotingContentType, isProposer bool) error
- func (ps *ProposerService) SetOrChangeMind(votingType voting.VotingContentType, votingHeight uint32, ...)
- func (ps *ProposerService) Start() error
- func (ps *ProposerService) StartConsensus(isProposer bool)
- func (ps *ProposerService) SyncBlock(isProposer bool)
- func (ps *ProposerService) TimeoutRoutine()
- type Request
- type Response
- type StateProbe
- type StateResponse
- type SyncCache
- func (sc *SyncCache) AddBlockToSyncCache(block *ledger.Block) error
- func (sc *SyncCache) AddVoteForBlock(hash Uint256, height uint32, voter uint64) error
- func (sc *SyncCache) BlockInSyncCache(hash Uint256, height uint32) (*BlockInfo, bool)
- func (sc *SyncCache) CachedBlockHeight() int
- func (sc *SyncCache) ChangeVoteForBlock(hash Uint256, height uint32, voter uint64) error
- func (sc *SyncCache) GetBlockFromSyncCache(height uint32) (*ledger.VBlock, error)
- func (sc *SyncCache) RemoveBlockFromCache(height uint32) error
- func (sc *SyncCache) SetConsensusHeight(height uint32)
- type TimeLock
Constants ¶
const ( ProbeFactor = 1 ResultFactor = 3 ProbeDuration = config.ConsensusTime / ProbeFactor WaitForProbeResult = config.ConsensusTime / ResultFactor MsgChanCap = 1 // probe service will detect BlockNumDetected blocks of neighbor per time BlockNumDetected = 5 // block detecting starts from height (current height - BlockDepthDetected) BlockDepthDetected = 10 )
const ( TxnAmountToBePackaged = 1024 WaitingForFloodingFinished = time.Second * 1 WaitingForVotingFinished = time.Second * 8 TimeoutTolerance = time.Second * 2 )
const (
InitialBlockHeight = 5
)
Variables ¶
This section is empty.
Functions ¶
func BuildIsingPayload ¶
func BuildIsingPayload(msg IsingMessage, sender *crypto.PubKey) (*message.IsingPayload, error)
func HeightHashToString ¶
HeightHashToString uses block height and block hash to generate a uniq string
func StringToHeightHash ¶
StringToHeightHash recovers block height and block hash from string which generated by HeightHashToString
Types ¶
type BlockFlooding ¶
type BlockFlooding struct {
// contains filtered or unexported fields
}
func NewBlockFlooding ¶
func NewBlockFlooding(block *ledger.Block) *BlockFlooding
func (*BlockFlooding) Deserialize ¶
func (bf *BlockFlooding) Deserialize(r io.Reader) error
type BlockHistoryPayload ¶
Contains block history [StartHeight, StartHeight + BlockNum) to be detected
type BlockWithVotes ¶
type BlockWithVotes struct {
// contains filtered or unexported fields
}
BlockWithVotes describes cached block with votes got from neighbors.
type BuiltinMining ¶
type BuiltinMining struct {
// contains filtered or unexported fields
}
func NewBuiltinMining ¶
func NewBuiltinMining(account *vault.Account, txnCollector *transaction.TxnCollector) *BuiltinMining
func (*BuiltinMining) BuildBlock ¶
func (bm *BuiltinMining) BuildBlock(height uint32, winningHash Uint256, winningHashType ledger.WinningHashType) (*ledger.Block, error)
func (*BuiltinMining) CreateCoinbaseTransaction ¶
func (bm *BuiltinMining) CreateCoinbaseTransaction() *transaction.Transaction
type ConsensusService ¶
type ConsensusService struct {
// contains filtered or unexported fields
}
func NewConsensusService ¶
func NewConsensusService(account *vault.Account, node protocol.Noder) *ConsensusService
func (*ConsensusService) Start ¶
func (cs *ConsensusService) Start()
type IsingMessage ¶
type IsingMessage interface { serialization.SerializableData }
func RecoverFromIsingPayload ¶
func RecoverFromIsingPayload(payload *message.IsingPayload) (IsingMessage, error)
type IsingMessageType ¶
type IsingMessageType byte
const ( BlockFloodingMsg IsingMessageType = 0x00 BlockRequestMsg IsingMessageType = 0x01 BlockResponseMsg IsingMessageType = 0x02 BlockProposalMsg IsingMessageType = 0x03 MindChangingMsg IsingMessageType = 0x04 StateProbeMsg IsingMessageType = 0x05 StateResponseMsg IsingMessageType = 0x06 )
type MindChanging ¶
type MindChanging struct {
// contains filtered or unexported fields
}
func NewMindChanging ¶
func NewMindChanging(hash *Uint256, height uint32, ctype voting.VotingContentType) *MindChanging
func (*MindChanging) Deserialize ¶
func (mc *MindChanging) Deserialize(r io.Reader) error
type ProbeService ¶
func NewProbeService ¶
func NewProbeService(account *vault.Account, node protocol.Noder) *ProbeService
func (*ProbeService) BuildNotice ¶
func (ps *ProbeService) BuildNotice() *Notice
func (*ProbeService) HandleStateResponseMsg ¶
func (ps *ProbeService) HandleStateResponseMsg(msg *StateResponse, sender *crypto.PubKey)
func (*ProbeService) ReceiveConsensusMsg ¶
func (ps *ProbeService) ReceiveConsensusMsg(v interface{})
func (*ProbeService) Reset ¶
func (ps *ProbeService) Reset()
func (*ProbeService) SendConsensusMsg ¶
func (ps *ProbeService) SendConsensusMsg(msg IsingMessage) error
func (*ProbeService) Start ¶
func (ps *ProbeService) Start() error
type Proposal ¶
type Proposal struct {
// contains filtered or unexported fields
}
func NewProposal ¶
func NewProposal(hash *Uint256, height uint32, ctype voting.VotingContentType) *Proposal
type ProposerCache ¶
func NewProposerCache ¶
func NewProposerCache() *ProposerCache
func (*ProposerCache) Add ¶
func (pc *ProposerCache) Add(height uint32, votingContent voting.VotingContent)
func (*ProposerCache) Get ¶
func (pc *ProposerCache) Get(height uint32) (*ProposerInfo, error)
type ProposerInfo ¶
type ProposerInfo struct {
// contains filtered or unexported fields
}
type ProposerService ¶
func NewProposerService ¶
func NewProposerService(account *vault.Account, node protocol.Noder) *ProposerService
func (*ProposerService) BlockPersistCompleted ¶
func (ps *ProposerService) BlockPersistCompleted(v interface{})
func (*ProposerService) BlockSyncingFinished ¶
func (ps *ProposerService) BlockSyncingFinished(v interface{})
func (*ProposerService) ChangeProposer ¶
func (ps *ProposerService) ChangeProposer()
func (*ProposerService) ConsensusRoutine ¶
func (ps *ProposerService) ConsensusRoutine(vType voting.VotingContentType, isProposer bool)
func (*ProposerService) CurrentVoting ¶
func (ps *ProposerService) CurrentVoting(vType voting.VotingContentType) voting.Voting
func (*ProposerService) GetReceiverNode ¶
func (ps *ProposerService) GetReceiverNode(nids []uint64) []protocol.Noder
GetReceiverNode returns neighbors nodes according to neighbor node ID passed in. If 'nids' passed in is nil then returns all neighbor nodes.
func (*ProposerService) HandleBlockFloodingMsg ¶
func (ps *ProposerService) HandleBlockFloodingMsg(bfMsg *BlockFlooding, sender *crypto.PubKey)
func (*ProposerService) HandleMindChangingMsg ¶
func (ps *ProposerService) HandleMindChangingMsg(mindChanging *MindChanging, sender *crypto.PubKey)
func (*ProposerService) HandleProposalMsg ¶
func (ps *ProposerService) HandleProposalMsg(proposal *Proposal, sender *crypto.PubKey)
func (*ProposerService) HandleRequestMsg ¶
func (ps *ProposerService) HandleRequestMsg(req *Request, sender *crypto.PubKey)
func (*ProposerService) HandleResponseMsg ¶
func (ps *ProposerService) HandleResponseMsg(resp *Response, sender *crypto.PubKey)
func (*ProposerService) HandleStateProbeMsg ¶
func (ps *ProposerService) HandleStateProbeMsg(msg *StateProbe, sender *crypto.PubKey)
func (*ProposerService) Initialize ¶
func (ps *ProposerService) Initialize(vType voting.VotingContentType)
func (*ProposerService) IsBlockProposer ¶
func (ps *ProposerService) IsBlockProposer() bool
func (*ProposerService) ProbeRoutine ¶
func (ps *ProposerService) ProbeRoutine()
func (*ProposerService) ProduceNewBlock ¶
func (ps *ProposerService) ProduceNewBlock()
func (*ProposerService) ProposerRoutine ¶
func (ps *ProposerService) ProposerRoutine()
func (*ProposerService) ReceiveConsensusMsg ¶
func (ps *ProposerService) ReceiveConsensusMsg(v interface{})
func (*ProposerService) SendConsensusMsg ¶
func (ps *ProposerService) SendConsensusMsg(msg IsingMessage, to []protocol.Noder) error
func (*ProposerService) SendNewProposal ¶
func (ps *ProposerService) SendNewProposal(votingHeight uint32, vType voting.VotingContentType, isProposer bool) error
func (*ProposerService) SetOrChangeMind ¶
func (ps *ProposerService) SetOrChangeMind(votingType voting.VotingContentType, votingHeight uint32, maybeFinalHash *Uint256)
func (*ProposerService) Start ¶
func (ps *ProposerService) Start() error
func (*ProposerService) StartConsensus ¶
func (ps *ProposerService) StartConsensus(isProposer bool)
func (*ProposerService) SyncBlock ¶
func (ps *ProposerService) SyncBlock(isProposer bool)
func (*ProposerService) TimeoutRoutine ¶
func (ps *ProposerService) TimeoutRoutine()
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
func NewRequest ¶
func NewRequest(hash *Uint256, height uint32, ctype voting.VotingContentType) *Request
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
func NewResponse ¶
func NewResponse(hash *Uint256, height uint32, ctype voting.VotingContentType, content voting.VotingContent) *Response
type StateProbe ¶
type StateProbe struct { ProbeType ProbeType ProbePayload interface{} }
func (*StateProbe) Deserialize ¶
func (sp *StateProbe) Deserialize(r io.Reader) error
type StateResponse ¶
type StateResponse struct {
PersistedBlocks map[uint32]Uint256
}
func (*StateResponse) Deserialize ¶
func (sr *StateResponse) Deserialize(r io.Reader) error
type SyncCache ¶
SyncCache cached blocks sent by block proposer when wait for block syncing finished.
func NewSyncBlockCache ¶
func NewSyncBlockCache() *SyncCache
func (*SyncCache) AddBlockToSyncCache ¶
AddBlockToSyncCache caches received block and the voter count when receive block. Returns nil if block already existed.
func (*SyncCache) AddVoteForBlock ¶
AddVoteForBlock adds vote for block when receive valid proposal.
func (*SyncCache) BlockInSyncCache ¶
BlockInSyncCache returns block info and true is the block exists in cache.
func (*SyncCache) CachedBlockHeight ¶
CachedBlockHeight returns cached block height.
func (*SyncCache) ChangeVoteForBlock ¶
ChangeVoteForBlock change vote for block when receive valid mind changing.
func (*SyncCache) GetBlockFromSyncCache ¶
GetBlockFromSyncCache returns cached block by height.
func (*SyncCache) RemoveBlockFromCache ¶
RemoveBlockFromCache removes cached block which height is minimum.
func (*SyncCache) SetConsensusHeight ¶
type TimeLock ¶
func NewTimeLock ¶
func NewTimeLock() *TimeLock