Documentation ¶
Index ¶
- Variables
- func ConvertToBlockID(data message.ProposedData) common.BlockID
- func ExtractBlockID(commit *message.Commit) common.BlockID
- type BFTCheckPoint
- func (cp *BFTCheckPoint) Add(commit *message.Commit) error
- func (cp *BFTCheckPoint) Close()
- func (cp *BFTCheckPoint) Flush(bid common.BlockID) error
- func (cp *BFTCheckPoint) GetIth(i uint64) (*message.Commit, error)
- func (cp *BFTCheckPoint) GetNext(blockNum uint64) (*message.Commit, error)
- func (cp *BFTCheckPoint) HasDanglingCheckPoint() bool
- func (cp *BFTCheckPoint) IsNextCheckPoint(commit *message.Commit) bool
- func (cp *BFTCheckPoint) MissingRange() (from, to uint64)
- func (cp *BFTCheckPoint) NextUncommitted() *message.Commit
- func (cp *BFTCheckPoint) Remove(commit *message.Commit)
- func (cp *BFTCheckPoint) RemoveNextUncommitted()
- func (cp *BFTCheckPoint) Validate(commit *message.Commit) bool
- type Dynasties
- func (ds *Dynasties) Back() *Dynasty
- func (ds *Dynasties) Clear()
- func (ds *Dynasties) Empty() bool
- func (ds *Dynasties) Front() *Dynasty
- func (ds *Dynasties) Len() int
- func (ds *Dynasties) PopAfter(seq uint64) *Dynasty
- func (ds *Dynasties) PopBack()
- func (ds *Dynasties) PopBefore(seq uint64) *Dynasty
- func (ds *Dynasties) PopFront()
- func (ds *Dynasties) Purge(seq uint64)
- func (ds *Dynasties) PushBack(d *Dynasty)
- func (ds *Dynasties) PushFront(d *Dynasty)
- type Dynasty
- type FakeTimer
- type Producer
- type SABFT
- func (sabft *SABFT) ActiveProducers() []string
- func (sabft *SABFT) ActiveValidators() []string
- func (sabft *SABFT) BroadCast(msg message.ConsensusMessage) error
- func (sabft *SABFT) CheckSyncFinished() bool
- func (sabft *SABFT) Commit(commitRecords *message.Commit) error
- func (sabft *SABFT) CurrentProducer() string
- func (sabft *SABFT) DecidesProposal() message.ProposedData
- func (sabft *SABFT) EnableMockSignal()
- func (sabft *SABFT) FetchBlock(id common.BlockID) (common.ISignedBlock, error)
- func (sabft *SABFT) FetchBlocks(from, to uint64) ([]common.ISignedBlock, error)
- func (sabft *SABFT) FetchBlocksSince(id common.BlockID) ([]common.ISignedBlock, error)
- func (sabft *SABFT) GetAppState() *message.AppState
- func (sabft *SABFT) GetBFTCommitInfo(num uint64) interface{}
- func (sabft *SABFT) GetCommitHistory(height int64) *message.Commit
- func (sabft *SABFT) GetCurrentProposer(round int) message.PubKey
- func (sabft *SABFT) GetHeadBlockId() common.BlockID
- func (sabft *SABFT) GetIDs(start, end common.BlockID) ([]common.BlockID, error)
- func (sabft *SABFT) GetLIB() common.BlockID
- func (sabft *SABFT) GetLastBFTCommit() interface{}
- func (sabft *SABFT) GetName() string
- func (sabft *SABFT) GetNextBFTCheckPoint(blockNum uint64) interface{}
- func (sabft *SABFT) GetValidator(key message.PubKey) custom.IPubValidator
- func (sabft *SABFT) GetValidatorList() []message.PubKey
- func (sabft *SABFT) GetValidatorNum() int
- func (sabft *SABFT) HasBlock(id common.BlockID) bool
- func (sabft *SABFT) IsCommitted(id common.BlockID) bool
- func (sabft *SABFT) IsOnMainBranch(id common.BlockID) (bool, error)
- func (sabft *SABFT) IsValidator(key message.PubKey) bool
- func (sabft *SABFT) MaybeProduceBlock()
- func (sabft *SABFT) MockMaliciousBehaviour(b bool)
- func (sabft *SABFT) Push(msg interface{}, p common.IPeer)
- func (sabft *SABFT) PushBlock(b common.ISignedBlock)
- func (sabft *SABFT) PushTransactionToPending(trx common.ISignedTransaction) error
- func (sabft *SABFT) ResetProdTimer(t time.Duration)
- func (sabft *SABFT) ResetTicker(ts time.Time)
- func (sabft *SABFT) Send(msg message.ConsensusMessage, p custom.IPeer) error
- func (sabft *SABFT) SetBootstrap(b bool)
- func (sabft *SABFT) SetHook(key string, f func(args ...interface{}))
- func (sabft *SABFT) Start(node *node.Node) error
- func (sabft *SABFT) Stop() error
- func (sabft *SABFT) TotalVotingPower() int64
- func (sabft *SABFT) ValidateProposal(data message.ProposedData) bool
- type Timer
- type TimerDriver
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidProducer = errors.New("invalid producer") ErrInvalidSig = errors.New("invalid signature") ErrInvalidBlockNum = errors.New("invalid block number") ErrBlockOutOfScope = errors.New("block number out of scope") ErrConsensusNotReady = errors.New("consensus not ready") ErrInternal = errors.New("internal error") ErrBlockNotExist = errors.New("block doesn't exist") ErrDupBlock = errors.New("duplicated block") ErrInvalidBlock = errors.New("invalid block") ErrEmptyForkDB = errors.New("ForkDB is empty") ErrForkDBChanged = errors.New("ForkDB changed, please try again") ErrCommittingNonExistBlock = errors.New("committing a non-existed block") ErrCommittingBlockOnFork = errors.New("committing a block on fork") ErrCommitted = errors.New("committed already") ErrSwitchFork = errors.New("switch fork error") ErrInvalidCheckPoint = errors.New("invalid checkpoint") ErrCheckPointOutOfRange = errors.New("checkpoint out of range") ErrCheckPointExists = errors.New("checkpoint exists") )
Functions ¶
func ConvertToBlockID ¶ added in v1.0.2
func ConvertToBlockID(data message.ProposedData) common.BlockID
Types ¶
type BFTCheckPoint ¶ added in v1.0.2
type BFTCheckPoint struct {
// contains filtered or unexported fields
}
BFTCheckPoint maintains the bft consensus evidence, the votes collected for the same checkpoint in different validators might differ. But all nodes including validators should have the same number of checkpoints with exact same order. all methods have time complexity of O(1)
func NewBFTCheckPoint ¶ added in v1.0.2
func NewBFTCheckPoint(dir string, sabft *SABFT) *BFTCheckPoint
func (*BFTCheckPoint) Add ¶ added in v1.0.2
func (cp *BFTCheckPoint) Add(commit *message.Commit) error
func (*BFTCheckPoint) Close ¶ added in v1.0.2
func (cp *BFTCheckPoint) Close()
func (*BFTCheckPoint) Flush ¶ added in v1.0.2
func (cp *BFTCheckPoint) Flush(bid common.BlockID) error
func (*BFTCheckPoint) GetIth ¶ added in v1.0.2
func (cp *BFTCheckPoint) GetIth(i uint64) (*message.Commit, error)
func (*BFTCheckPoint) GetNext ¶ added in v1.0.2
func (cp *BFTCheckPoint) GetNext(blockNum uint64) (*message.Commit, error)
func (*BFTCheckPoint) HasDanglingCheckPoint ¶ added in v1.0.2
func (cp *BFTCheckPoint) HasDanglingCheckPoint() bool
func (*BFTCheckPoint) IsNextCheckPoint ¶ added in v1.0.2
func (cp *BFTCheckPoint) IsNextCheckPoint(commit *message.Commit) bool
func (*BFTCheckPoint) MissingRange ¶ added in v1.0.2
func (cp *BFTCheckPoint) MissingRange() (from, to uint64)
(from, to) @from is the last committed checkpoint @to is any of the dangling uncommitted checkpoints Only call it if HasDanglingCheckPoint returns true
func (*BFTCheckPoint) NextUncommitted ¶ added in v1.0.2
func (cp *BFTCheckPoint) NextUncommitted() *message.Commit
func (*BFTCheckPoint) Remove ¶ added in v1.0.2
func (cp *BFTCheckPoint) Remove(commit *message.Commit)
func (*BFTCheckPoint) RemoveNextUncommitted ¶ added in v1.0.2
func (cp *BFTCheckPoint) RemoveNextUncommitted()
type Dynasties ¶ added in v1.0.2
type Dynasties struct {
// contains filtered or unexported fields
}
func NewDynasties ¶ added in v1.0.2
func NewDynasties() *Dynasties
type Dynasty ¶ added in v1.0.2
type Dynasty struct { Seq uint64 // contains filtered or unexported fields }
func NewDynasty ¶ added in v1.0.2
func (*Dynasty) GetValidatorByPubKey ¶ added in v1.0.2
func (*Dynasty) GetValidatorNum ¶ added in v1.0.2
type FakeTimer ¶ added in v1.0.2
type FakeTimer struct {
// contains filtered or unexported fields
}
type SABFT ¶ added in v1.0.2
type SABFT struct { ForkDB *forkdb.DB Name string Ticker TimerDriver deadlock.RWMutex // contains filtered or unexported fields }
SABFT: self-adaptive BFT It generates blocks in the same manner of DPoS and adopts bft to achieve fast block confirmation. It's self adaptive in a way that it can adjust the frequency of bft process based on the load of the blockchain and network traffic.
func (*SABFT) ActiveProducers ¶ added in v1.0.2
func (*SABFT) ActiveValidators ¶ added in v1.0.2
func (*SABFT) BroadCast ¶ added in v1.0.2
func (sabft *SABFT) BroadCast(msg message.ConsensusMessage) error
func (*SABFT) CheckSyncFinished ¶ added in v1.0.2
func (*SABFT) CurrentProducer ¶ added in v1.0.2
func (*SABFT) DecidesProposal ¶ added in v1.0.2
func (sabft *SABFT) DecidesProposal() message.ProposedData
DecidesProposal decides what will be proposed if this validator is the current proposer.
func (*SABFT) EnableMockSignal ¶ added in v1.0.2
func (sabft *SABFT) EnableMockSignal()
func (*SABFT) FetchBlock ¶ added in v1.0.2
func (*SABFT) FetchBlocks ¶ added in v1.0.2
func (sabft *SABFT) FetchBlocks(from, to uint64) ([]common.ISignedBlock, error)
func (*SABFT) FetchBlocksSince ¶ added in v1.0.2
return blocks in the range of (id, max(headID, id+1024))
func (*SABFT) GetAppState ¶ added in v1.0.2
func (*SABFT) GetBFTCommitInfo ¶ added in v1.0.2
func (*SABFT) GetCommitHistory ¶ added in v1.0.2
func (*SABFT) GetCurrentProposer ¶ added in v1.0.2
func (*SABFT) GetHeadBlockId ¶ added in v1.0.2
func (*SABFT) GetLastBFTCommit ¶ added in v1.0.2
func (sabft *SABFT) GetLastBFTCommit() interface{}
func (*SABFT) GetNextBFTCheckPoint ¶ added in v1.0.2
func (*SABFT) GetValidator ¶ added in v1.0.2
func (sabft *SABFT) GetValidator(key message.PubKey) custom.IPubValidator
GetValidator returns the validator correspond to the PubKey
func (*SABFT) GetValidatorList ¶ added in v1.0.2
func (*SABFT) GetValidatorNum ¶ added in v1.0.2
func (*SABFT) IsOnMainBranch ¶ added in v1.0.2
func (*SABFT) IsValidator ¶ added in v1.0.2
IsValidator returns true if key is a validator
func (*SABFT) MaybeProduceBlock ¶ added in v1.0.2
func (sabft *SABFT) MaybeProduceBlock()
func (*SABFT) MockMaliciousBehaviour ¶ added in v1.0.2
func (*SABFT) PushBlock ¶ added in v1.0.2
func (sabft *SABFT) PushBlock(b common.ISignedBlock)
func (*SABFT) PushTransactionToPending ¶ added in v1.0.2
func (sabft *SABFT) PushTransactionToPending(trx common.ISignedTransaction) error
func (*SABFT) ResetProdTimer ¶ added in v1.0.2
func (*SABFT) ResetTicker ¶ added in v1.0.2
func (*SABFT) SetBootstrap ¶ added in v1.0.2
func (*SABFT) TotalVotingPower ¶ added in v1.0.2
func (*SABFT) ValidateProposal ¶ added in v1.0.2
func (sabft *SABFT) ValidateProposal(data message.ProposedData) bool
ValidateProposed validates the proposed data