pbft

package
v0.2.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2024 License: GPL-3.0 Imports: 37 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrInvalidTimestamp is returned if the timestamp of a block is lower than
	// the previous block's timestamp + the minimum block period.
	ErrInvalidTimestamp = errors.New("invalid timestamp")

	ErrAlreadyConfirmedBlock = errors.New("already confirmed block")

	ErrWaitSyncBlock = errors.New("has confirmed, wait sync block")

	ErrInvalidConfirm = errors.New("invalid confirm")

	ErrSignerNotOnduty = errors.New("singer is not on duty")

	ErrConsensusIsRunning = errors.New("current consensus is running")

	ErrWaitRecoverStatus = errors.New("wait for recoved states")
)

Functions

func DBlockSealHash

func DBlockSealHash(block dpos.DBlock) (hash ecom.Uint256, err error)

func SealHash

func SealHash(header *types.Header) (hash common.Hash)

SealHash returns the hash of a block prior to it being sealed.

Types

type API

type API struct {
	// contains filtered or unexported fields
}

API is a user facing RPC API to allow controlling the signer and voting mechanisms of the delegate-proof-of-stake scheme.

func (*API) AnnounceDAddr

func (a *API) AnnounceDAddr() uint64

func (*API) Dispatcher

func (a *API) Dispatcher() *dpos.Dispatcher

func (*API) GetAllPeersInfo added in v0.2.0

func (a *API) GetAllPeersInfo() []peerInfo

func (*API) GetAtbiterPeersInfo

func (a *API) GetAtbiterPeersInfo() []peerInfo

func (*API) Network

func (a *API) Network() *dpos.Network

type Pbft

type Pbft struct {

	// IsCurrent returns whether BlockChain synced to best height.
	IsCurrent          func() bool
	StartMine          func()
	OnDuty             func()
	OnInsertChainError func(id peer.PID, block *types.Block, err error)
	// contains filtered or unexported fields
}

Pbft is a consensus engine based on Byzantine fault-tolerant algorithm

func New

func New(chainConfig *params.ChainConfig, dataDir string) *Pbft

func (*Pbft) APIs

func (p *Pbft) APIs(chain consensus.ChainReader) []rpc.API

func (*Pbft) AccessFutureBlock

func (p *Pbft) AccessFutureBlock(parent *types.Block)

func (*Pbft) AddDirectLinkPeer

func (p *Pbft) AddDirectLinkPeer(pid peer.PID, addr string)

func (*Pbft) AnnounceDAddr

func (p *Pbft) AnnounceDAddr() bool

func (*Pbft) Author

func (p *Pbft) Author(header *types.Header) (common.Address, error)

func (*Pbft) BroadBlockMsg

func (p *Pbft) BroadBlockMsg(block *types.Block) error

func (*Pbft) BroadMessage added in v0.1.4

func (p *Pbft) BroadMessage(msg elap2p.Message)

func (*Pbft) BroadMessageExcept added in v0.2.5

func (p *Pbft) BroadMessageExcept(msg elap2p.Message, exceptPeer peer.PID)

func (*Pbft) BroadMessageToPeers added in v0.2.0

func (p *Pbft) BroadMessageToPeers(msg elap2p.Message, peers [][]byte)

func (*Pbft) CalcDifficulty

func (p *Pbft) CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Header) *big.Int

func (*Pbft) CleanFinalConfirmedBlock

func (p *Pbft) CleanFinalConfirmedBlock(height uint64)

func (*Pbft) Close

func (p *Pbft) Close() error

func (*Pbft) CurrentBlock added in v0.2.0

func (p *Pbft) CurrentBlock() *types.Block

func (*Pbft) DecryptArbiter added in v0.2.0

func (p *Pbft) DecryptArbiter(cipher []byte) (arbiter []byte, err error)

func (*Pbft) DoRecover

func (p *Pbft) DoRecover()

func (*Pbft) Finalize

func (p *Pbft) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction,
	uncles []*types.Header)

func (*Pbft) FinalizeAndAssemble

func (p *Pbft) FinalizeAndAssemble(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction,
	uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error)

func (*Pbft) GetActivePeersCount

func (p *Pbft) GetActivePeersCount() int

func (*Pbft) GetAllArbiterPeersInfo added in v0.2.0

func (p *Pbft) GetAllArbiterPeersInfo() []*p2p.PeerInfo

func (*Pbft) GetAtbiterPeersInfo

func (p *Pbft) GetAtbiterPeersInfo() []peerInfo

func (*Pbft) GetBlockByHeight added in v0.2.0

func (p *Pbft) GetBlockByHeight(height uint64) *types.Block

func (*Pbft) GetBlockChain added in v0.2.0

func (p *Pbft) GetBlockChain() *core.BlockChain

func (*Pbft) GetBridgeArbiters added in v0.2.0

func (p *Pbft) GetBridgeArbiters() crypto.Keypair

func (*Pbft) GetCurrentProducers added in v0.1.4

func (p *Pbft) GetCurrentProducers() [][]byte

func (*Pbft) GetDataDir

func (p *Pbft) GetDataDir() string

func (*Pbft) GetDposAccount added in v0.2.0

func (p *Pbft) GetDposAccount() daccount.Account

func (*Pbft) GetMainChainHeight added in v0.2.1

func (p *Pbft) GetMainChainHeight(pid peer.PID) uint64

func (*Pbft) GetPbftConfig

func (p *Pbft) GetPbftConfig() params.PbftConfig

func (*Pbft) GetProducer added in v0.2.0

func (p *Pbft) GetProducer() []byte

func (*Pbft) GetSelfDutyIndex added in v0.2.0

func (p *Pbft) GetSelfDutyIndex() int

func (*Pbft) GetTimeSource

func (p *Pbft) GetTimeSource() dtime.MedianTimeSource

func (*Pbft) GetTotalArbitersCount added in v0.2.0

func (p *Pbft) GetTotalArbitersCount() int

func (*Pbft) GetTotalProducerCount added in v0.2.0

func (p *Pbft) GetTotalProducerCount() int

func (*Pbft) HasProducerMajorityCount added in v0.2.0

func (p *Pbft) HasProducerMajorityCount(count int) bool

func (*Pbft) IsBadBlock

func (p *Pbft) IsBadBlock(height uint64) bool

func (*Pbft) IsCurrentProducers added in v0.1.4

func (p *Pbft) IsCurrentProducers(curProducers [][]byte) bool

func (*Pbft) IsInBlockPool

func (p *Pbft) IsInBlockPool(hash common.Hash) bool

func (*Pbft) IsOnDuty added in v0.2.0

func (p *Pbft) IsOnDuty() bool

func (*Pbft) IsOnduty

func (p *Pbft) IsOnduty() bool

func (*Pbft) IsProducer

func (p *Pbft) IsProducer() bool

func (*Pbft) IsProducerByAccount added in v0.2.0

func (p *Pbft) IsProducerByAccount(account []byte) bool

func (*Pbft) IsSameProducers added in v0.1.4

func (p *Pbft) IsSameProducers(curProducers [][]byte) bool

func (*Pbft) IsSyncFinished added in v0.2.0

func (p *Pbft) IsSyncFinished() bool

func (*Pbft) OnBadNetwork

func (p *Pbft) OnBadNetwork()

func (*Pbft) OnBlock

func (p *Pbft) OnBlock(id peer.PID, block *dmsg.BlockMsg)

func (*Pbft) OnBlockReceived

func (p *Pbft) OnBlockReceived(id peer.PID, b *dmsg.BlockMsg, confirmed bool)

func (*Pbft) OnChangeView

func (p *Pbft) OnChangeView()

func (*Pbft) OnConfirmReceived

func (p *Pbft) OnConfirmReceived(pid peer.PID, c *payload.Confirm, height uint64)

func (*Pbft) OnFailedWithdrawTxReceived added in v0.1.4

func (p *Pbft) OnFailedWithdrawTxReceived(id peer.PID, msg *dmsg.FailedWithdrawTx)

func (*Pbft) OnGetBlock

func (p *Pbft) OnGetBlock(id peer.PID, blockHash elacom.Uint256)

func (*Pbft) OnGetBlocks

func (p *Pbft) OnGetBlocks(id peer.PID, startBlockHeight, endBlockHeight uint32)

func (*Pbft) OnIllegalProposalReceived

func (p *Pbft) OnIllegalProposalReceived(id peer.PID, proposals *payload.DPOSIllegalProposals)

func (*Pbft) OnIllegalVotesReceived

func (p *Pbft) OnIllegalVotesReceived(id peer.PID, votes *payload.DPOSIllegalVotes)

func (*Pbft) OnInsertBlock added in v0.1.4

func (p *Pbft) OnInsertBlock(block *types.Block) bool

func (*Pbft) OnInv

func (p *Pbft) OnInv(id peer.PID, blockHash elacom.Uint256)

func (*Pbft) OnLayer2Msg added in v0.2.0

func (p *Pbft) OnLayer2Msg(id dpeer.PID, c elap2p.Message)

func (*Pbft) OnPing

func (p *Pbft) OnPing(id peer.PID, height uint32)

func (*Pbft) OnPong

func (p *Pbft) OnPong(id peer.PID, height uint32)

func (*Pbft) OnProposalReceived

func (p *Pbft) OnProposalReceived(id peer.PID, proposal *payload.DPOSProposal)

func (*Pbft) OnRecover

func (p *Pbft) OnRecover()

func (*Pbft) OnRecoverTimeout

func (p *Pbft) OnRecoverTimeout()

func (*Pbft) OnRequestConsensus

func (p *Pbft) OnRequestConsensus(id peer.PID, height uint64)

func (*Pbft) OnRequestProposal

func (p *Pbft) OnRequestProposal(id peer.PID, hash elacom.Uint256)

func (*Pbft) OnResponseBlocks

func (p *Pbft) OnResponseBlocks(id peer.PID, blockConfirms []*dmsg.BlockMsg)

func (*Pbft) OnResponseConsensus

func (p *Pbft) OnResponseConsensus(id peer.PID, status *dmsg.ConsensusStatus)

func (*Pbft) OnResponseResetViewReceived added in v0.2.1

func (p *Pbft) OnResponseResetViewReceived(msg *msg.ResetView)

func (*Pbft) OnSmallCroTxReceived added in v0.1.4

func (p *Pbft) OnSmallCroTxReceived(id peer.PID, msg *dmsg.SmallCroTx)

func (*Pbft) OnViewChanged

func (p *Pbft) OnViewChanged(isOnDuty bool, force bool)

func (*Pbft) OnVoteAccepted

func (p *Pbft) OnVoteAccepted(id peer.PID, vote *payload.DPOSProposalVote)

func (*Pbft) OnVoteRejected

func (p *Pbft) OnVoteRejected(id peer.PID, vote *payload.DPOSProposalVote)

func (*Pbft) Prepare

func (p *Pbft) Prepare(chain consensus.ChainReader, header *types.Header) error

func (*Pbft) Recover

func (p *Pbft) Recover()

func (*Pbft) RequestAbnormalRecovering

func (p *Pbft) RequestAbnormalRecovering()

func (*Pbft) Seal

func (p *Pbft) Seal(chain consensus.ChainReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error

func (*Pbft) SealHash

func (p *Pbft) SealHash(header *types.Header) common.Hash

func (*Pbft) SendMsgProposal added in v0.2.0

func (p *Pbft) SendMsgProposal(proposalMsg elap2p.Message)

func (*Pbft) SendMsgToPeer added in v0.2.0

func (p *Pbft) SendMsgToPeer(proposalMsg elap2p.Message, pid dpeer.PID)

func (*Pbft) SetBlockChain

func (p *Pbft) SetBlockChain(chain *core.BlockChain)

func (*Pbft) SignData added in v0.2.0

func (p *Pbft) SignData(data []byte) []byte

func (*Pbft) SignersCount

func (p *Pbft) SignersCount() int

func (*Pbft) Start

func (p *Pbft) Start(headerTime uint64)

func (*Pbft) StartProposal

func (p *Pbft) StartProposal(block *types.Block) (*payload.DPOSProposal, error)

func (*Pbft) StartServer

func (p *Pbft) StartServer()

func (*Pbft) StopServer

func (p *Pbft) StopServer()

func (*Pbft) UpdateCurrentProducers added in v0.1.4

func (p *Pbft) UpdateCurrentProducers(producers [][]byte, totalCount int, spvHeight uint64)

func (*Pbft) VerifyHeader

func (p *Pbft) VerifyHeader(chain consensus.ChainReader, header *types.Header, seal bool) error

func (*Pbft) VerifyHeaders

func (p *Pbft) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error)

func (*Pbft) VerifySeal

func (p *Pbft) VerifySeal(chain consensus.ChainReader, header *types.Header) error

func (*Pbft) VerifyUncles

func (p *Pbft) VerifyUncles(chain consensus.ChainReader, block *types.Block) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL