Documentation ¶
Index ¶
- Constants
- Variables
- func Handshake(p *p2p.Peer, rw p2p.MsgReadWriter, mac string, sig []byte, term uint64, ...) (address common.Address, err error)
- func IsCheckPoint(number uint64, termLen uint64, viewLen uint64) bool
- func IsDefaultValidator(nodeID string, defaultValidators []string) bool
- func IsDporMsg(msg p2p.Msg) bool
- func IsSyncMsg(msg p2p.Msg) bool
- func ReadSignerStatus(msg p2p.Msg, signerStatusData *SignerStatusData) (address common.Address, err error)
- func RecoverBlockFromMsg(msg p2p.Msg, p interface{}) (*types.Block, error)
- func RecoverHeaderFromMsg(msg p2p.Msg, p interface{}) (*types.Header, error)
- func TermOf(blockNum uint64) uint64
- func ValidMacSig(mac string, sig []byte) (valid bool, signer common.Address, err error)
- type Action
- type BlockIdentifier
- type BlockOrHeader
- type ChainBackend
- type ClientBackend
- type ConsensusStateMachine
- type ContractBackend
- type ContractCaller
- type DSMStatus
- type Dialer
- func (d *Dialer) AddPeer(version int, p *p2p.Peer, rw p2p.MsgReadWriter, mac string, sig []byte, ...) (string, bool, bool, error)
- func (d *Dialer) AllUselessProposers() map[common.Address]*RemoteProposer
- func (d *Dialer) EnoughImpeachValidatorsOfTerm(term uint64) (validators map[common.Address]*RemoteValidator, enough bool)
- func (d *Dialer) EnoughValidatorsOfTerm(term uint64) (validators map[common.Address]*RemoteValidator, enough bool)
- func (d *Dialer) KeepConnection()
- func (d *Dialer) ProposersOfTerm(term uint64) map[common.Address]*RemoteProposer
- func (d *Dialer) SetDporService(dpor DporService)
- func (d *Dialer) SetServer(server *p2p.Server)
- func (d *Dialer) Stop()
- func (d *Dialer) UpdateRemoteProposers(term uint64, proposers []common.Address) error
- func (d *Dialer) ValidatorsOfTerm(term uint64) map[common.Address]*RemoteValidator
- type DporService
- type HandleGeneratedImpeachBlock
- type Handler
- func (h *Handler) AddPeer(version int, p *p2p.Peer, rw p2p.MsgReadWriter) (string, bool, bool, error)
- func (h *Handler) Available() bool
- func (h *Handler) BroadcastCommitHeader(header *types.Header)
- func (h *Handler) BroadcastCommitImpeachHeader(header *types.Header)
- func (h *Handler) BroadcastPrepareHeader(header *types.Header)
- func (h *Handler) BroadcastPrepareImpeachHeader(header *types.Header)
- func (h *Handler) BroadcastPreprepareBlock(block *types.Block)
- func (h *Handler) BroadcastPreprepareImpeachBlock(block *types.Block)
- func (h *Handler) BroadcastValidateBlock(block *types.Block)
- func (h *Handler) BroadcastValidateImpeachBlock(block *types.Block)
- func (h *Handler) Coinbase() common.Address
- func (h *Handler) GetProtocol() consensus.Protocol
- func (h *Handler) HandleMsg(addr string, version int, p *p2p.Peer, rw p2p.MsgReadWriter, msg p2p.Msg) (string, error)
- func (h *Handler) Length() uint64
- func (h *Handler) Name() string
- func (h *Handler) NodeInfo() interface{}
- func (h *Handler) PendingBlockBroadcastLoop()
- func (h *Handler) PendingImpeachBlockBroadcastLoop()
- func (h *Handler) ProposerBroadcastPreprepareBlock(block *types.Block)
- func (vh *Handler) ReceiveImpeachPendingBlock(block *types.Block) error
- func (ph *Handler) ReceiveMinedPendingBlock(block *types.Block) error
- func (h *Handler) RemovePeer(addr string)
- func (h *Handler) SetAvailable()
- func (h *Handler) SetCoinbase(coinbase common.Address)
- func (h *Handler) SetDporService(dpor DporService)
- func (h *Handler) SetDporStateMachine(fsm ConsensusStateMachine)
- func (h *Handler) SetServer(server *p2p.Server)
- func (h *Handler) Start()
- func (h *Handler) Stop()
- func (h *Handler) Version() uint
- type HandlerMode
- type LBFT
- type LBFT2
- func (p *LBFT2) CommitHandler(input *BlockOrHeader, msgCode MsgCode, state consensus.State) ([]*BlockOrHeader, Action, MsgCode, consensus.State, error)
- func (p *LBFT2) FSM(input *BlockOrHeader, msgCode MsgCode) ([]*BlockOrHeader, Action, MsgCode, error)
- func (p *LBFT2) Faulty() uint64
- func (p *LBFT2) IdleHandler(input *BlockOrHeader, msgCode MsgCode, state consensus.State) ([]*BlockOrHeader, Action, MsgCode, consensus.State, error)
- func (p *LBFT2) ImpeachCommitHandler(input *BlockOrHeader, msgCode MsgCode, state consensus.State) ([]*BlockOrHeader, Action, MsgCode, consensus.State, error)
- func (p *LBFT2) ImpeachHandler(input *BlockOrHeader, msgCode MsgCode, state consensus.State) ([]*BlockOrHeader, Action, MsgCode, consensus.State, error)
- func (p *LBFT2) ImpeachPrepareHandler(input *BlockOrHeader, msgCode MsgCode, state consensus.State) ([]*BlockOrHeader, Action, MsgCode, consensus.State, error)
- func (p *LBFT2) Number() uint64
- func (p *LBFT2) PrepareHandler(input *BlockOrHeader, msgCode MsgCode, state consensus.State) ([]*BlockOrHeader, Action, MsgCode, consensus.State, error)
- func (p *LBFT2) SetNumber(number uint64)
- func (p *LBFT2) SetState(state consensus.State)
- func (p *LBFT2) State() consensus.State
- func (p *LBFT2) Status() DSMStatus
- func (p *LBFT2) ValidateHandler(input *BlockOrHeader, msgCode MsgCode, state consensus.State) ([]*BlockOrHeader, Action, MsgCode, consensus.State, error)
- type MsgCode
- type RecentBlocks
- type RemoteProposer
- type RemoteSigner
- type RemoteValidator
- func (s *RemoteValidator) AsyncSendCommitHeader(header *types.Header)
- func (s *RemoteValidator) AsyncSendCommitImpeachHeader(header *types.Header)
- func (s *RemoteValidator) AsyncSendImpeachValidateBlock(block *types.Block)
- func (s *RemoteValidator) AsyncSendPrepareHeader(header *types.Header)
- func (s *RemoteValidator) AsyncSendPrepareImpeachHeader(header *types.Header)
- func (s *RemoteValidator) AsyncSendPreprepareBlock(block *types.Block)
- func (s *RemoteValidator) AsyncSendPreprepareImpeachBlock(block *types.Block)
- func (s *RemoteValidator) AsyncSendValidateBlock(block *types.Block)
- func (s *RemoteValidator) SendCommitHeader(header *types.Header) error
- func (s *RemoteValidator) SendCommitImpeachHeader(header *types.Header) error
- func (s *RemoteValidator) SendImpeachValidateBlock(block *types.Block) error
- func (s *RemoteValidator) SendNewSignerMsg(eb common.Address) error
- func (s *RemoteValidator) SendPrepareHeader(header *types.Header) error
- func (s *RemoteValidator) SendPrepareImpeachHeader(header *types.Header) error
- func (s *RemoteValidator) SendPreprepareBlock(block *types.Block) error
- func (s *RemoteValidator) SendPreprepareImpeachBlock(block *types.Block) error
- func (s *RemoteValidator) SendValidateBlock(block *types.Block) error
- type SignFn
- type SignerStatusData
- type VerifyBlockFn
Constants ¶
const ( // ProtocolName protocol name ProtocolName = "dpor" // ProtocolVersion protocol version ProtocolVersion = 65 // ProtocolLength protocol length, max msg code ProtocolLength = 100 )
const ( // PbftMsgOutset is not a msg code, just used for msg code comparing PbftMsgOutset = 0x42 // NewSignerMsg is a msg code used for network building NewSignerMsg = 0x42 // those are messages for normal block verification PreprepareBlockMsg = 0x43 PrepareHeaderMsg = 0x44 CommitHeaderMsg = 0x45 ValidateBlockMsg = 0x46 // those are messages for abnormal(impeachment) block verification PreprepareImpeachBlockMsg = 0x47 PrepareImpeachHeaderMsg = 0x48 CommitImpeachHeaderMsg = 0x49 ValidateImpeachBlockMsg = 0x50 )
Protocol messages belonging to cpc/01
const ( // ErrMsgTooLarge is returned if msg if too large ErrMsgTooLarge = iota // ErrDecode is returned if decode failed ErrDecode // ErrInvalidMsgCode is returned if msg code is invalid ErrInvalidMsgCode // ErrProtocolVersionMismatch is returned if protocol version is not matched when handshaking ErrProtocolVersionMismatch // ErrNetworkIDMismatch is returned if networkid is not matched when handshaking ErrNetworkIDMismatch // ErrGenesisBlockMismatch is returned if genesis block is different from remote signer ErrGenesisBlockMismatch // ErrNoStatusMsg is returned if failed when reading status msg ErrNoStatusMsg // ErrExtraStatusMsg is returned if failed when extracting status msg ErrExtraStatusMsg // ErrSuspendedPeer is returned if remote signer is dead ErrSuspendedPeer )
const ProtocolMaxMsgSize = 10 * 1024 * 1024
ProtocolMaxMsgSize Maximum cap on the size of a protocol message
Variables ¶
var ( // ErrUnknownHandlerMode is returned if in an unknown mode ErrUnknownHandlerMode = errors.New("unknown dpor handler mode") // ErrFailToAddPendingBlock is returned if failed to add block to pending ErrFailToAddPendingBlock = errors.New("fail to add pending block") // ErrNotSigner is returned if i am not a signer when handshaking // with remote signer ErrNotSigner = errors.New("local peer is not in the PV committees") )
var ( ErrBlockAlreadyInChain = errors.New("the block is already in local chain") ErrMsgTooOld = errors.New("the msg is outdated") ErrInvalidBlockFormat = errors.New("the block format is invalid") ErrInvalidHeaderFormat = errors.New("the header format is invalid") )
errors returned by fsm
Functions ¶
func Handshake ¶
func Handshake(p *p2p.Peer, rw p2p.MsgReadWriter, mac string, sig []byte, term uint64, futureTerm uint64) (address common.Address, err error)
Handshake tries to handshake with remote validator
func IsCheckPoint ¶ added in v0.3.1
IsCheckPoint returns if a given block number is in a checkpoint with given termLen and viewLen
func IsDefaultValidator ¶ added in v0.3.1
IsDefaultValidator checks if a validator is a default validator
func ReadSignerStatus ¶ added in v0.3.1
func ReadSignerStatus(msg p2p.Msg, signerStatusData *SignerStatusData) (address common.Address, err error)
ReadSignerStatus reads status of remote validator
func RecoverBlockFromMsg ¶
RecoverBlockFromMsg recovers a block from a p2p msg
func RecoverHeaderFromMsg ¶
RecoverHeaderFromMsg recovers a header from a p2p msg
Types ¶
type BlockIdentifier ¶ added in v0.3.1
type BlockIdentifier struct {
// contains filtered or unexported fields
}
BlockIdentifier is the identifier to a block
func NewBlockIdentifier ¶ added in v0.3.1
func NewBlockIdentifier(number uint64, hash common.Hash) BlockIdentifier
NewBlockIdentifier creates a block identifier with given block number and hash
type BlockOrHeader ¶ added in v0.3.1
type BlockOrHeader struct {
// contains filtered or unexported fields
}
BlockOrHeader represents a block or a header
func NewBOHFromBlock ¶ added in v0.3.1
func NewBOHFromBlock(block *types.Block) *BlockOrHeader
NewBOHFromBlock creates a new BlockOrHeader from a block
func NewBOHFromHeader ¶ added in v0.3.1
func NewBOHFromHeader(header *types.Header) *BlockOrHeader
NewBOHFromHeader creates a new BlockOrHeader from a header
func (*BlockOrHeader) Hash ¶ added in v0.3.1
func (bh *BlockOrHeader) Hash() common.Hash
Hash returns hash of the boh
func (*BlockOrHeader) IsBlock ¶ added in v0.3.1
func (bh *BlockOrHeader) IsBlock() bool
IsBlock checks if the boh is a block
func (*BlockOrHeader) IsHeader ¶ added in v0.3.1
func (bh *BlockOrHeader) IsHeader() bool
IsHeader checks if the boh is a header
func (*BlockOrHeader) Number ¶ added in v0.3.1
func (bh *BlockOrHeader) Number() uint64
Number returns number of the boh
type ChainBackend ¶
type ChainBackend interface { HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error) BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error) NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (uint64, error) }
ChainBackend is the chain client operation interface
type ClientBackend ¶
type ClientBackend interface { ChainBackend ContractBackend }
ClientBackend is the client operation interface
type ConsensusStateMachine ¶ added in v0.3.1
type ConsensusStateMachine interface { Status() DSMStatus Faulty() uint64 FSM(input *BlockOrHeader, msgCode MsgCode) ([]*BlockOrHeader, Action, MsgCode, error) }
ConsensusStateMachine is a state machine used for consensus protocol for validators msg processing
type ContractBackend ¶
type ContractBackend interface { bind.ContractBackend }
ContractBackend is the contract client operation interface
type ContractCaller ¶
type ContractCaller struct { Key *keystore.Key Client ClientBackend GasLimit uint64 }
ContractCaller is used to call the contract with given key and client. TODO: remove this later
func NewContractCaller ¶
func NewContractCaller(key *keystore.Key, client ClientBackend, gasLimit uint64) (*ContractCaller, error)
NewContractCaller returns a ContractCaller.
type Dialer ¶
type Dialer struct {
// contains filtered or unexported fields
}
Dialer dials a remote peer
func (*Dialer) AddPeer ¶
func (d *Dialer) AddPeer(version int, p *p2p.Peer, rw p2p.MsgReadWriter, mac string, sig []byte, term uint64, futureTerm uint64) (string, bool, bool, error)
AddPeer adds a peer to local dpor peer set: remote proposers or remote validators
func (*Dialer) AllUselessProposers ¶ added in v0.3.1
func (d *Dialer) AllUselessProposers() map[common.Address]*RemoteProposer
AllUselessProposers returns all useless proposers
func (*Dialer) EnoughImpeachValidatorsOfTerm ¶ added in v0.3.1
func (d *Dialer) EnoughImpeachValidatorsOfTerm(term uint64) (validators map[common.Address]*RemoteValidator, enough bool)
EnoughImpeachValidatorsOfTerm returns validator of given term and whether it is enough for impeach
func (*Dialer) EnoughValidatorsOfTerm ¶ added in v0.3.1
func (d *Dialer) EnoughValidatorsOfTerm(term uint64) (validators map[common.Address]*RemoteValidator, enough bool)
EnoughValidatorsOfTerm returns validator of given term and whether it is enough
func (*Dialer) KeepConnection ¶ added in v0.3.1
func (d *Dialer) KeepConnection()
KeepConnection tries to dial remote validators if local node is a current or future proposer and disconnect remote validators if it is not
func (*Dialer) ProposersOfTerm ¶
func (d *Dialer) ProposersOfTerm(term uint64) map[common.Address]*RemoteProposer
ProposersOfTerm returns all proposers of given term
func (*Dialer) SetDporService ¶
func (d *Dialer) SetDporService(dpor DporService)
SetDporService sets dpor service to dialer
func (*Dialer) UpdateRemoteProposers ¶
UpdateRemoteProposers updates dialer.remoteProposers.
func (*Dialer) ValidatorsOfTerm ¶
func (d *Dialer) ValidatorsOfTerm(term uint64) map[common.Address]*RemoteValidator
ValidatorsOfTerm returns all validators of given term
type DporService ¶
type DporService interface { // Coinbase returns current coinbase Coinbase() common.Address // TermLength returns term length TermLength() uint64 // Faulty returns the number of faulty nodes Faulty() uint64 // ViewLength returns view length ViewLength() uint64 // ValidatorsNum returns number of validators ValidatorsNum() uint64 // Period returns period of block generation Period() time.Duration // BlockDelay returns max delay of preprepare block propagation BlockDelay() time.Duration // TermOf returns the term number of given block number TermOf(number uint64) uint64 // FutureTermOf returns the future term number of given block number FutureTermOf(number uint64) uint64 // VerifyProposerOf verifies if an address is a proposer of given term VerifyProposerOf(signer common.Address, term uint64) (bool, error) // VerifyValidatorOf verifies if an address is a validator of given term VerifyValidatorOf(signer common.Address, term uint64) (bool, error) // ValidatorsOf returns the list of validators in committee for the specified block number ValidatorsOf(number uint64) ([]common.Address, error) // ProposersOf returns the list of proposers in committee for the specified block number ProposersOf(number uint64) ([]common.Address, error) // ProposerOf returns the proposer of the specified block number by rpt and election calculation ProposerOf(number uint64) (common.Address, error) // ValidatorsOfTerm returns the list of validators in committee for the specified term ValidatorsOfTerm(term uint64) ([]common.Address, error) // ProposersOfTerm returns the list of proposers in committee for the specified term ProposersOfTerm(term uint64) ([]common.Address, error) // VerifyHeaderWithState verifies the given header // if in preprepared state, verify basic fields // if in prepared state, verify if enough prepare sigs // if in committed state, verify if enough commit sigs VerifyHeaderWithState(header *types.Header, state consensus.State) error // ValidateBlock verifies a block ValidateBlock(block *types.Block, verifySigs bool, verifyProposers bool) error // SignHeader signs the block if not signed it yet SignHeader(header *types.Header, state consensus.State) error // BroadcastBlock broadcasts a block to normal peers(not pbft replicas) BroadcastBlock(block *types.Block, prop bool) // InsertChain inserts a block to chain InsertChain(block *types.Block) error // Status returns a pbft replica's status Status() *consensus.PbftStatus // StatusUpdate updates status of dpor StatusUpdate() error // CreateImpeachBlock returns an impeachment block CreateImpeachBlock() (*types.Block, error) // CreateFailbackImpeachBlocks creates impeachment blocks with failback timestamps CreateFailbackImpeachBlocks() (firstImpeachment *types.Block, secondImpeachment *types.Block, err error) // GetCurrentBlock returns current block GetCurrentBlock() *types.Block // HasBlockInChain returns if a block is in local chain HasBlockInChain(hash common.Hash, number uint64) bool // GetBlockFromChain returns a block from local chain with given hash and number GetBlockFromChain(hash common.Hash, number uint64) *types.Block // ImpeachTimeout returns the timeout for impeachment ImpeachTimeout() time.Duration // ECRecoverProposer recovers proposer's address from a seal of a header ECRecoverProposer(header *types.Header) (common.Address, error) // ECRecoverSigs recovers signer address and corresponding signature, it ignores empty signature and return empty // addresses if one of the sigs are illegal ECRecoverSigs(header *types.Header, state consensus.State) ([]common.Address, []types.DporSignature, error) // Update the signature to prepare signature cache(two kinds of sigs, one for prepared, another for final) UpdatePrepareSigsCache(validator common.Address, hash common.Hash, sig types.DporSignature) // Update the signature to final signature cache(two kinds of sigs, one for prepared, another for final) UpdateFinalSigsCache(validator common.Address, hash common.Hash, sig types.DporSignature) // GetMac signs a Mac GetMac() (string, []byte, error) // SyncFrom tries to sync block from given peer SyncFrom(p *p2p.Peer) // Synchronize tries to sync block from best peer Synchronize() }
DporService provides functions used by dpor handler
type HandleGeneratedImpeachBlock ¶ added in v0.3.1
HandleGeneratedImpeachBlock handles generated impeach block
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler implements PbftHandler
func NewHandler ¶
NewHandler creates a new Handler
func (*Handler) AddPeer ¶
func (h *Handler) AddPeer(version int, p *p2p.Peer, rw p2p.MsgReadWriter) (string, bool, bool, error)
AddPeer adds a p2p peer to local peer set
func (*Handler) BroadcastCommitHeader ¶
BroadcastCommitHeader broadcasts signed commit header to remote validators
func (*Handler) BroadcastCommitImpeachHeader ¶
BroadcastCommitImpeachHeader broadcasts signed impeach commit header to remote validators
func (*Handler) BroadcastPrepareHeader ¶
BroadcastPrepareHeader broadcasts signed prepare header to remote validators
func (*Handler) BroadcastPrepareImpeachHeader ¶
BroadcastPrepareImpeachHeader broadcasts signed impeach prepare header to remote validators
func (*Handler) BroadcastPreprepareBlock ¶
BroadcastPreprepareBlock broadcasts generated block to validators
func (*Handler) BroadcastPreprepareImpeachBlock ¶
BroadcastPreprepareImpeachBlock broadcasts generated impeach block to validators
func (*Handler) BroadcastValidateBlock ¶ added in v0.3.1
BroadcastValidateBlock broadcasts validate block to validators
func (*Handler) BroadcastValidateImpeachBlock ¶ added in v0.3.1
BroadcastValidateImpeachBlock broadcasts validate impeach block to validators
func (*Handler) GetProtocol ¶
GetProtocol returns handler protocol
func (*Handler) HandleMsg ¶
func (h *Handler) HandleMsg(addr string, version int, p *p2p.Peer, rw p2p.MsgReadWriter, msg p2p.Msg) (string, error)
HandleMsg handles a msg of peer with id "addr"
func (*Handler) PendingBlockBroadcastLoop ¶
func (h *Handler) PendingBlockBroadcastLoop()
PendingBlockBroadcastLoop loops to broadcast blocks
func (*Handler) PendingImpeachBlockBroadcastLoop ¶ added in v0.3.1
func (h *Handler) PendingImpeachBlockBroadcastLoop()
PendingImpeachBlockBroadcastLoop loops to broadcasts pending impeachment block
func (*Handler) ProposerBroadcastPreprepareBlock ¶ added in v0.3.1
ProposerBroadcastPreprepareBlock broadcasts generated block to validators
func (*Handler) ReceiveImpeachPendingBlock ¶
ReceiveImpeachPendingBlock receives a block to add to pending block channel
func (*Handler) ReceiveMinedPendingBlock ¶
ReceiveMinedPendingBlock receives a block to add to pending block channel
func (*Handler) RemovePeer ¶
RemovePeer removes a p2p peer with its addr
func (*Handler) SetCoinbase ¶
SetCoinbase sets coinbase of handler
func (*Handler) SetDporService ¶
func (h *Handler) SetDporService(dpor DporService)
SetDporService sets dpor service to handler
func (*Handler) SetDporStateMachine ¶
func (h *Handler) SetDporStateMachine(fsm ConsensusStateMachine)
SetDporStateMachine sets dpor state machine
type HandlerMode ¶
type HandlerMode int
HandlerMode indicates the run mode of handler
const ( LBFTMode HandlerMode = iota LBFT2Mode )
Those are handler mode
type LBFT ¶ added in v0.3.1
type LBFT struct {
// contains filtered or unexported fields
}
LBFT is the 1.0 version for lbft protocol within validator committee
type LBFT2 ¶ added in v0.3.1
type LBFT2 struct {
// contains filtered or unexported fields
}
LBFT2 is a state machine used for consensus protocol for validators msg processing
func NewLBFT2 ¶ added in v0.3.1
func NewLBFT2(faulty uint64, dpor DporService, handleImpeachBlock HandleGeneratedImpeachBlock, db database.Database) *LBFT2
NewLBFT2 create an LBFT2 instance
func (*LBFT2) CommitHandler ¶ added in v0.3.1
func (p *LBFT2) CommitHandler(input *BlockOrHeader, msgCode MsgCode, state consensus.State) ([]*BlockOrHeader, Action, MsgCode, consensus.State, error)
CommitHandler is the handler for Commit state
func (*LBFT2) FSM ¶ added in v0.3.1
func (p *LBFT2) FSM(input *BlockOrHeader, msgCode MsgCode) ([]*BlockOrHeader, Action, MsgCode, error)
FSM implements ConsensusStateMachine.FSM
func (*LBFT2) IdleHandler ¶ added in v0.3.1
func (p *LBFT2) IdleHandler(input *BlockOrHeader, msgCode MsgCode, state consensus.State) ([]*BlockOrHeader, Action, MsgCode, consensus.State, error)
IdleHandler is the handler for Idle state
func (*LBFT2) ImpeachCommitHandler ¶ added in v0.3.1
func (p *LBFT2) ImpeachCommitHandler(input *BlockOrHeader, msgCode MsgCode, state consensus.State) ([]*BlockOrHeader, Action, MsgCode, consensus.State, error)
ImpeachCommitHandler is the handler for ImpeachCommit state
func (*LBFT2) ImpeachHandler ¶ added in v0.3.1
func (p *LBFT2) ImpeachHandler(input *BlockOrHeader, msgCode MsgCode, state consensus.State) ([]*BlockOrHeader, Action, MsgCode, consensus.State, error)
ImpeachHandler is the handler for all impeachment related msg
func (*LBFT2) ImpeachPrepareHandler ¶ added in v0.3.1
func (p *LBFT2) ImpeachPrepareHandler(input *BlockOrHeader, msgCode MsgCode, state consensus.State) ([]*BlockOrHeader, Action, MsgCode, consensus.State, error)
ImpeachPrepareHandler is the handler for ImpeachPrepare state
func (*LBFT2) PrepareHandler ¶ added in v0.3.1
func (p *LBFT2) PrepareHandler(input *BlockOrHeader, msgCode MsgCode, state consensus.State) ([]*BlockOrHeader, Action, MsgCode, consensus.State, error)
PrepareHandler is the handler for Prepare state
func (*LBFT2) ValidateHandler ¶ added in v0.3.1
func (p *LBFT2) ValidateHandler(input *BlockOrHeader, msgCode MsgCode, state consensus.State) ([]*BlockOrHeader, Action, MsgCode, consensus.State, error)
ValidateHandler is the handler for bot Validate state and ImpeachValidate state
type MsgCode ¶
type MsgCode uint8
MsgCode is type enumerator for FSM message type
type RecentBlocks ¶
type RecentBlocks struct {
// contains filtered or unexported fields
}
RecentBlocks caches recent received blocks
func NewRecentBlocks ¶ added in v0.3.1
func NewRecentBlocks(db database.Database) *RecentBlocks
NewRecentBlocks creates a new block cache object
func (*RecentBlocks) AddBlock ¶
func (rb *RecentBlocks) AddBlock(block *types.Block) error
AddBlock adds a block to caches
func (*RecentBlocks) GetBlock ¶
func (rb *RecentBlocks) GetBlock(bi BlockIdentifier) (*types.Block, error)
GetBlock returns a block with given block identifier
func (*RecentBlocks) GetBlockIdentifiers ¶ added in v0.3.1
func (rb *RecentBlocks) GetBlockIdentifiers() []BlockIdentifier
GetBlockIdentifiers returns a slice of block identifiers in this cache
func (*RecentBlocks) RemoveBlock ¶ added in v0.3.1
func (rb *RecentBlocks) RemoveBlock(bi BlockIdentifier) error
RemoveBlock removes a block from caches
type RemoteProposer ¶
type RemoteProposer struct {
*RemoteSigner
}
RemoteProposer represents a remote proposer waiting to be connected.
func NewRemoteProposer ¶
func NewRemoteProposer(address common.Address) *RemoteProposer
NewRemoteProposer creates a new remote proposer
type RemoteSigner ¶
RemoteSigner represents a remote peer, ether proposer or validator
func NewRemoteSigner ¶
func NewRemoteSigner(address common.Address) *RemoteSigner
NewRemoteSigner creates a new remote signer
func (*RemoteSigner) AddStatic ¶
func (s *RemoteSigner) AddStatic(srv *p2p.Server) error
AddStatic adds remote validator as a static peer
func (*RemoteSigner) Coinbase ¶
func (s *RemoteSigner) Coinbase() common.Address
Coinbase returns remote peer's addr
func (*RemoteSigner) EnodeID ¶ added in v0.3.1
func (s *RemoteSigner) EnodeID() string
EnodeID returns remote signer's enode id
func (*RemoteSigner) SetPeer ¶
func (s *RemoteSigner) SetPeer(version int, p *p2p.Peer, rw p2p.MsgReadWriter)
SetPeer sets a p2p peer
type RemoteValidator ¶
type RemoteValidator struct { *RemoteSigner // contains filtered or unexported fields }
RemoteValidator represents a remote signer waiting to be connected and communicate with.
func NewRemoteValidator ¶
func NewRemoteValidator(address common.Address) *RemoteValidator
NewRemoteValidator creates a new NewRemoteValidator with given view idx and address.
func (*RemoteValidator) AsyncSendCommitHeader ¶
func (s *RemoteValidator) AsyncSendCommitHeader(header *types.Header)
AsyncSendCommitHeader sends new signed block header.
func (*RemoteValidator) AsyncSendCommitImpeachHeader ¶
func (s *RemoteValidator) AsyncSendCommitImpeachHeader(header *types.Header)
AsyncSendCommitImpeachHeader sends new signed block header.
func (*RemoteValidator) AsyncSendImpeachValidateBlock ¶ added in v0.3.1
func (s *RemoteValidator) AsyncSendImpeachValidateBlock(block *types.Block)
AsyncSendImpeachValidateBlock queues an entire block for propagation to a remote peer. If the peer's broadcast queue is full, the event is silently dropped.
func (*RemoteValidator) AsyncSendPrepareHeader ¶
func (s *RemoteValidator) AsyncSendPrepareHeader(header *types.Header)
AsyncSendPrepareHeader adds a msg to broadcast channel
func (*RemoteValidator) AsyncSendPrepareImpeachHeader ¶
func (s *RemoteValidator) AsyncSendPrepareImpeachHeader(header *types.Header)
AsyncSendPrepareImpeachHeader adds a msg to broadcast channel
func (*RemoteValidator) AsyncSendPreprepareBlock ¶
func (s *RemoteValidator) AsyncSendPreprepareBlock(block *types.Block)
AsyncSendPreprepareBlock queues an entire block for propagation to a remote peer. If the peer's broadcast queue is full, the event is silently dropped.
func (*RemoteValidator) AsyncSendPreprepareImpeachBlock ¶
func (s *RemoteValidator) AsyncSendPreprepareImpeachBlock(block *types.Block)
AsyncSendPreprepareImpeachBlock queues an entire block for propagation to a remote peer. If the peer's broadcast queue is full, the event is silently dropped.
func (*RemoteValidator) AsyncSendValidateBlock ¶ added in v0.3.1
func (s *RemoteValidator) AsyncSendValidateBlock(block *types.Block)
AsyncSendValidateBlock queues an entire block for propagation to a remote peer. If the peer's broadcast queue is full, the event is silently dropped.
func (*RemoteValidator) SendCommitHeader ¶
func (s *RemoteValidator) SendCommitHeader(header *types.Header) error
SendCommitHeader sends new signed block header.
func (*RemoteValidator) SendCommitImpeachHeader ¶
func (s *RemoteValidator) SendCommitImpeachHeader(header *types.Header) error
SendCommitImpeachHeader sends new signed block header.
func (*RemoteValidator) SendImpeachValidateBlock ¶ added in v0.3.1
func (s *RemoteValidator) SendImpeachValidateBlock(block *types.Block) error
SendImpeachValidateBlock propagates an entire block to a remote peer.
func (*RemoteValidator) SendNewSignerMsg ¶
func (s *RemoteValidator) SendNewSignerMsg(eb common.Address) error
SendNewSignerMsg sends a
func (*RemoteValidator) SendPrepareHeader ¶
func (s *RemoteValidator) SendPrepareHeader(header *types.Header) error
SendPrepareHeader sends new signed block header.
func (*RemoteValidator) SendPrepareImpeachHeader ¶
func (s *RemoteValidator) SendPrepareImpeachHeader(header *types.Header) error
SendPrepareImpeachHeader sends new signed block header.
func (*RemoteValidator) SendPreprepareBlock ¶
func (s *RemoteValidator) SendPreprepareBlock(block *types.Block) error
SendPreprepareBlock propagates an entire block to a remote peer.
func (*RemoteValidator) SendPreprepareImpeachBlock ¶
func (s *RemoteValidator) SendPreprepareImpeachBlock(block *types.Block) error
SendPreprepareImpeachBlock propagates an entire block to a remote peer.
func (*RemoteValidator) SendValidateBlock ¶ added in v0.3.1
func (s *RemoteValidator) SendValidateBlock(block *types.Block) error
SendValidateBlock propagates an entire block to a remote peer.
type SignFn ¶
SignFn is a signer callback function to request a hash to be signed by a backing account.
type SignerStatusData ¶
SignerStatusData represents signer status when handshaking
type VerifyBlockFn ¶ added in v0.3.1
VerifyBlockFn verifies basic fields of a block