consensus_interface

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const HotStuffMessageTypeRoot = 100

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	Round    int64  // the round that generated this proposal
	Payload  string // proposed transactions
	ParentQC *QC    // qc for parent block
	Id       string // unique digest of round, payload and parent_qc.id
}

msgp Block

func (*Block) DecodeMsg

func (z *Block) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*Block) EncodeMsg

func (z *Block) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*Block) MarshalMsg

func (z *Block) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*Block) Msgsize

func (z *Block) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (Block) String

func (b Block) String() string

func (*Block) UnmarshalMsg

func (z *Block) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type Committee

type Committee struct {
	Peers   []*CommitteeMember
	Version int
}

type CommitteeMember

type CommitteeMember struct {
	PeerIndex        int              // order of peer in the committee
	MemberId         string           // peer identifier. current use address
	TransportPeerId  string           // for transport only. In the future this should not be revealed.
	ConsensusAccount ConsensusAccount // account public key to verify messages
}

type CommitteeProvider

type CommitteeProvider interface {
	InitCommittee(version int, peers []CommitteeMember, myAccount ConsensusAccount)
	GetVersion() int
	GetAllMemberTransportIds() []string
	GetAllMemberPeedIds() []string
	GetAllMembers() []CommitteeMember
	GetMyPeerId() string
	GetMyPeerIndex() int
	GetLeader(round int64) CommitteeMember
	GetPeerIndex(id string) (index int, err error)
	GetThreshold() int
	AmILeader(round int64) bool
	AmIIn() bool
	IsIn(id string) bool
}

type ConsensusAccount

type ConsensusAccount interface {
	Id() string
}

OgLedgerAccount represents a full account of a user.

type ConsensusAccountProvider

type ConsensusAccountProvider interface {
	ProvideAccount() (ConsensusAccount, error)
	Generate() (account ConsensusAccount, err error)
	Load() (account ConsensusAccount, err error)
	Save() (err error)
}

type ConsensusSigner

type ConsensusSigner interface {
	Sign(msg []byte, account ConsensusAccount) Signature
}

type ConsensusState

type ConsensusState struct {
	LastVoteRound  int64
	PreferredRound int64
	HighQC         *QC
	LastTC         *TC
}

func (ConsensusState) String

func (c ConsensusState) String() string

type ContentProposal

type ContentProposal struct {
	Proposal Block
	TC       *TC
}

msgp ContentProposal

func (*ContentProposal) DecodeMsg

func (z *ContentProposal) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*ContentProposal) EncodeMsg

func (z *ContentProposal) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*ContentProposal) FromBytes

func (z *ContentProposal) FromBytes(bts []byte) error

func (*ContentProposal) MarshalMsg

func (z *ContentProposal) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*ContentProposal) Msgsize

func (z *ContentProposal) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*ContentProposal) SignatureTarget

func (z *ContentProposal) SignatureTarget() []byte

func (*ContentProposal) String

func (z *ContentProposal) String() string

func (*ContentProposal) ToBytes

func (z *ContentProposal) ToBytes() []byte

func (*ContentProposal) UnmarshalMsg

func (z *ContentProposal) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type ContentString

type ContentString struct {
	Content string
}

msgp ContentString it is a dummy content type for debugging

func (*ContentString) DecodeMsg

func (z *ContentString) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (ContentString) EncodeMsg

func (z ContentString) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*ContentString) FromBytes

func (z *ContentString) FromBytes(bts []byte) error

func (ContentString) MarshalMsg

func (z ContentString) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (ContentString) Msgsize

func (z ContentString) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*ContentString) SignatureTarget

func (z *ContentString) SignatureTarget() []byte

func (*ContentString) String

func (z *ContentString) String() string

func (*ContentString) ToBytes

func (z *ContentString) ToBytes() []byte

func (*ContentString) UnmarshalMsg

func (z *ContentString) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type ContentTimeout

type ContentTimeout struct {
	Round  int64
	HighQC *QC
	TC     *TC
}

msgp ContentTimeout

func (*ContentTimeout) DecodeMsg

func (z *ContentTimeout) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*ContentTimeout) EncodeMsg

func (z *ContentTimeout) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*ContentTimeout) FromBytes

func (z *ContentTimeout) FromBytes(bts []byte) error

func (*ContentTimeout) MarshalMsg

func (z *ContentTimeout) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*ContentTimeout) Msgsize

func (z *ContentTimeout) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*ContentTimeout) SignatureTarget

func (z *ContentTimeout) SignatureTarget() []byte

func (*ContentTimeout) String

func (z *ContentTimeout) String() string

func (*ContentTimeout) ToBytes

func (z *ContentTimeout) ToBytes() []byte

func (*ContentTimeout) UnmarshalMsg

func (z *ContentTimeout) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type ContentVote

type ContentVote struct {
	VoteInfo         VoteInfo
	LedgerCommitInfo LedgerCommitInfo
	QC               *QC
	TC               *TC
}

msgp ContentVote

func (*ContentVote) DecodeMsg

func (z *ContentVote) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*ContentVote) EncodeMsg

func (z *ContentVote) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*ContentVote) FromBytes

func (z *ContentVote) FromBytes(bts []byte) error

func (*ContentVote) MarshalMsg

func (z *ContentVote) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*ContentVote) Msgsize

func (z *ContentVote) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*ContentVote) SignatureTarget

func (z *ContentVote) SignatureTarget() []byte

func (*ContentVote) String

func (z *ContentVote) String() string

func (*ContentVote) ToBytes

func (z *ContentVote) ToBytes() []byte

func (*ContentVote) UnmarshalMsg

func (z *ContentVote) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type ExecutionResult

type ExecutionResult struct {
	BlockId        string
	ExecuteStateId string
	Err            error
}

func (*ExecutionResult) String

func (e *ExecutionResult) String() string

type Hasher

type Hasher interface {
	Hash(s string) string
}

type HotStuffMessageType

type HotStuffMessageType int
const (
	HotStuffMessageTypeProposal HotStuffMessageType = iota + 100
	HotStuffMessageTypeVote
	HotStuffMessageTypeTimeout
	HotStuffMessageTypeString
)

func (*HotStuffMessageType) DecodeMsg

func (z *HotStuffMessageType) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (HotStuffMessageType) EncodeMsg

func (z HotStuffMessageType) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (HotStuffMessageType) MarshalMsg

func (z HotStuffMessageType) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (HotStuffMessageType) Msgsize

func (z HotStuffMessageType) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (HotStuffMessageType) String

func (m HotStuffMessageType) String() string

func (*HotStuffMessageType) UnmarshalMsg

func (z *HotStuffMessageType) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type HotStuffSignedMessage

type HotStuffSignedMessage struct {
	HotStuffMessageType int    // what ContentByte is (one of HotStuffMessageType).
	ContentBytes        []byte // this Byte will be recovered to implementation of Content interface
	SenderMemberId      string // member id of the sender
	Signature           []byte
}

HotStuffSignedMessage is for transportation. msgp HotStuffSignedMessage

func (*HotStuffSignedMessage) DecodeMsg

func (z *HotStuffSignedMessage) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*HotStuffSignedMessage) EncodeMsg

func (z *HotStuffSignedMessage) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*HotStuffSignedMessage) FromBytes

func (z *HotStuffSignedMessage) FromBytes(bts []byte) error

func (*HotStuffSignedMessage) GetTypeValue

func (z *HotStuffSignedMessage) GetTypeValue() int

func (*HotStuffSignedMessage) MarshalMsg

func (z *HotStuffSignedMessage) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*HotStuffSignedMessage) Msgsize

func (z *HotStuffSignedMessage) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*HotStuffSignedMessage) String

func (z *HotStuffSignedMessage) String() string

func (*HotStuffSignedMessage) ToBytes

func (z *HotStuffSignedMessage) ToBytes() []byte

func (*HotStuffSignedMessage) UnmarshalMsg

func (z *HotStuffSignedMessage) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type JointSignature

type JointSignature []byte

msgp JointSignature

func (*JointSignature) DecodeMsg

func (z *JointSignature) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (JointSignature) EncodeMsg

func (z JointSignature) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (JointSignature) MarshalMsg

func (z JointSignature) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (JointSignature) Msgsize

func (z JointSignature) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*JointSignature) UnmarshalMsg

func (z *JointSignature) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type Ledger

type Ledger interface {
	// Speculate applies cmds speculatively
	Speculate(prevBlockId string, block *Block) (executionResult ExecutionResult)
	// GetState finds the pending state for the given BlockId or nil if not present
	GetState(blockId string) (stateId string)
	// Commit commits the pending prefix of the given BlockId and prune other branches
	Commit(blockId string)
	SaveConsensusState(*ConsensusState)
	GetConsensusState() *ConsensusState
	CurrentHeight() int64
	CurrentCommittee() *Committee
}

type LedgerCommitInfo

type LedgerCommitInfo struct {
	CommitStateId string // nil if no commit happens when this vote is aggregated to QC. Usually the merkle root
	VoteInfoHash  string // hash of VoteMsg.voteInfo
}

msgp LedgerCommitInfo

func (*LedgerCommitInfo) DecodeMsg

func (z *LedgerCommitInfo) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (LedgerCommitInfo) EncodeMsg

func (z LedgerCommitInfo) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (LedgerCommitInfo) GetHashContent

func (l LedgerCommitInfo) GetHashContent() string

func (LedgerCommitInfo) MarshalMsg

func (z LedgerCommitInfo) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (LedgerCommitInfo) Msgsize

func (z LedgerCommitInfo) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (LedgerCommitInfo) String

func (l LedgerCommitInfo) String() string

func (*LedgerCommitInfo) UnmarshalMsg

func (z *LedgerCommitInfo) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type ProposalContext

type ProposalContext struct {
	CurrentRound int64
	HighQC       *QC
	TC           *TC
}

func (ProposalContext) String

func (p ProposalContext) String() string

type ProposalContextProvider

type ProposalContextProvider interface {
	GetProposalContext() *ProposalContext
}

type ProposalExecutor

type ProposalExecutor interface {
	ExecuteProposal(block *Block) (executionResult ExecutionResult)
	ExecuteProposalAsync(block *Block)
}

type ProposalGenerator

type ProposalGenerator interface {
	GenerateProposal(context *ProposalContext) *ContentProposal
	GenerateProposalAsync(context *ProposalContext, callback func(*ContentProposal))
}

ProposalGenerator provides a proposal whenever needed

type ProposalVerifier

type ProposalVerifier interface {
	VerifyProposal(proposal *ContentProposal) *VerifyResult
	VerifyProposalAsync(proposal *ContentProposal)
}

type QC

type QC struct {
	VoteData       VoteInfo
	JointSignature JointSignature
}

msgp QC

func (*QC) DecodeMsg

func (z *QC) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*QC) EncodeMsg

func (z *QC) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*QC) MarshalMsg

func (z *QC) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*QC) Msgsize

func (z *QC) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*QC) String

func (q *QC) String() string

func (*QC) UnmarshalMsg

func (z *QC) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type Signature

type Signature []byte

msgp Signature

func (*Signature) DecodeMsg

func (z *Signature) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (Signature) EncodeMsg

func (z Signature) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (Signature) MarshalMsg

func (z Signature) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (Signature) Msgsize

func (z Signature) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Signature) UnmarshalMsg

func (z *Signature) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type SignatureCollector

type SignatureCollector interface {
	GetThreshold() int
	GetCurrentCount() int
	GetSignature(index int) (v Signature, ok bool)
	GetJointSignature() JointSignature
	Collected() bool
	Collect(sig Signature, index int)
	Has(index int) bool
}

type TC

type TC struct {
	Round          int64 // round of the block
	JointSignature JointSignature
}

msgp TC

func (*TC) DecodeMsg

func (z *TC) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*TC) EncodeMsg

func (z *TC) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*TC) MarshalMsg

func (z *TC) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*TC) Msgsize

func (z *TC) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*TC) String

func (t *TC) String() string

func (*TC) UnmarshalMsg

func (z *TC) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type VerifyResult

type VerifyResult struct {
	Ok bool
}

type VoteInfo

type VoteInfo struct {
	Id               string // Id of the block
	Round            int64  // round of the block
	ParentId         string // Id of the parent
	ParentRound      int64  // round of the parent
	GrandParentId    string // Id of the grandParent
	GrandParentRound int64  // round of the grandParent
	ExecStateId      string // speculated execution state
}

msgp VoteInfo

func (*VoteInfo) DecodeMsg

func (z *VoteInfo) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*VoteInfo) EncodeMsg

func (z *VoteInfo) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (VoteInfo) GetHashContent

func (i VoteInfo) GetHashContent() string

func (*VoteInfo) MarshalMsg

func (z *VoteInfo) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*VoteInfo) Msgsize

func (z *VoteInfo) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (VoteInfo) String

func (i VoteInfo) String() string

func (*VoteInfo) UnmarshalMsg

func (z *VoteInfo) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

Jump to

Keyboard shortcuts

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