Documentation
¶
Index ¶
- Constants
- func CheckValidatorSignature(data []byte, sig []byte) (common.Address, error)
- func GetSignatureAddress(data []byte, sig []byte) (common.Address, error)
- func RLPHash(v interface{}) (h common.Hash)
- type Backend
- type DPOS
- type Message
- func (m *Message) CheckSignature() error
- func (m *Message) Decode(val interface{}) error
- func (m *Message) DecodeRLP(s *rlp.Stream) error
- func (m *Message) EncodeRLP(w io.Writer) error
- func (m *Message) FromPayload(b []byte) error
- func (m *Message) Payload() ([]byte, error)
- func (m *Message) PayloadNoSig() ([]byte, error)
- func (m *Message) String() string
- type PBFT
- type Preprepare
- type Proposal
- type Snapshot
- type Subject
- type Validators
- type View
Constants ¶
View Source
const ( MsgPreprepare uint64 = iota MsgPrepare MsgCommit )
Variables ¶
This section is empty.
Functions ¶
func CheckValidatorSignature ¶
func GetSignatureAddress ¶
GetSignatureAddress gets the signer address from the signature
Types ¶
type Backend ¶
type Backend interface {
// Verify verifies the proposal.
Verify(Proposal) error
// Validators returns the validator set
Validators(proposal Proposal) Validators
// Sign signs input data with the backend's private key
Sign([]byte) ([]byte, error)
// CheckSignature verifies the signature by checking if it's signed by
// the given validator
CheckSignature(data []byte, addr common.Address, sig []byte) error
// Commit delivers an approved proposal to backend.
// The delivered proposal will be put into blockchain.
Commit(proposal Proposal, seals [][]byte) error
}
type DPOS ¶
type DPOS interface {
// snapshot retrieves the dpos snapshot at a given point in time.
Snapshot(chain consensus.ChainReader, number uint64, hash common.Hash, parents []*types.Header) (Snapshot, error)
// AccumulateRewards credits the coinbase of the given block with the mining reward.
AccumulateRewards(state *state.StateDB, header *types.Header, snap Snapshot)
}
type Message ¶
type Message struct {
Code uint64 // code type contains MsgPreprepare,MsgPrepare,MsgCommit
Msg []byte // content of the Message
Address common.Address // address of the proposer
Signature []byte // signed hash of the Msg by proposer
CommittedSeal []byte //
}
Message defines message format of the pbft engine
func (*Message) CheckSignature ¶
func (*Message) DecodeRLP ¶
DecodeRLP implements rlp.Decoder, and load the consensus fields from a RLP stream.
func (*Message) FromPayload ¶
FromPayload decode the payload from the p2p peer and check signature
func (*Message) PayloadNoSig ¶
type PBFT ¶
type PBFT interface {
Start() error
Stop() error
StartConsensus(validators Validators, proposal Proposal) error
PrePrepare(msg *Message) error
Prepare(msg *Message) error
Commit(msg *Message) error
SubscribeNewMsgEvent(chan<- consensus.PbftMsg) event.Subscription
DispatchMsg(address common.Address, msg p2p.Msg) (bool, error)
}
type Preprepare ¶
type Proposal ¶
type Proposal interface {
// Number retrieves the sequence number of this proposal.
Number() *big.Int
Time() *big.Int
// Hash retrieves the hash of this proposal.
Hash() common.Hash
EncodeRLP(w io.Writer) error
DecodeRLP(s *rlp.Stream) error
}
Proposal supports retrieving height and serialized block to be used during dbft consensus.
type Snapshot ¶
type Snapshot interface {
Validators() Validators
// Inturn returns if a signer at a given block height is in-turn or not.
Inturn(validator common.Address, headerTime, number *big.Int) bool
// Intrun returns next timestamp when validator can sign a block
NextTimeSlot(validator common.Address) *big.Int
}
type Subject ¶
func (*Subject) DecodeRLP ¶
DecodeRLP implements rlp.Decoder, and load the consensus fields from a RLP stream.
type Validators ¶
func (Validators) Addresses ¶
func (v Validators) Addresses() []common.Address
func (Validators) IsValidator ¶
func (v Validators) IsValidator(validator common.Address) bool
type View ¶
View includes proposer address and a sequence number. Sequence is the block number we'd like to commit.
func (*View) DecodeRLP ¶
DecodeRLP implements rlp.Decoder, and load the consensus fields from a RLP stream.
Click to show internal directories.
Click to hide internal directories.