Documentation
¶
Index ¶
- func Marshal(s Message) (bytes.Buffer, error)
- func MarshalAgreement(r *bytes.Buffer, a Agreement) error
- func MarshalBid(r *bytes.Buffer, tx *transactions.Bid) error
- func MarshalBlock(r *bytes.Buffer, b *block.Block) error
- func MarshalCandidate(b *bytes.Buffer, c Candidate) error
- func MarshalCertificate(r *bytes.Buffer, c *block.Certificate) error
- func MarshalCoinbase(w *bytes.Buffer, c *transactions.Coinbase) error
- func MarshalHashable(r *bytes.Buffer, h *block.Header) error
- func MarshalHeader(r *bytes.Buffer, h *block.Header) error
- func MarshalInput(w *bytes.Buffer, i *transactions.Input, encodeSignature bool) error
- func MarshalOutput(w *bytes.Buffer, o *transactions.Output) error
- func MarshalReduction(r *bytes.Buffer, bev Reduction) error
- func MarshalScore(r *bytes.Buffer, sev Score) error
- func MarshalStake(r *bytes.Buffer, tx *transactions.Stake) error
- func MarshalStandard(w *bytes.Buffer, s *transactions.Standard) error
- func MarshalStepVotes(r *bytes.Buffer, vote *StepVotes) error
- func MarshalTimelock(r *bytes.Buffer, tx *transactions.Timelock) error
- func MarshalTx(r *bytes.Buffer, tx transactions.Transaction) error
- func MarshalVoteSet(r *bytes.Buffer, evs []Reduction) error
- func MarshalVotes(r *bytes.Buffer, votes []*StepVotes) error
- func MockCertificate(hash []byte, round uint64, keys []key.Keys, p *user.Provisioners) *block.Certificate
- func SignAgreement(a *Agreement, keys key.Keys) error
- func UnmarshalAgreement(r *bytes.Buffer, a *Agreement) error
- func UnmarshalAgreementMessage(r *bytes.Buffer, m SerializableMessage) error
- func UnmarshalBid(r *bytes.Buffer, tx *transactions.Bid) error
- func UnmarshalBlock(r *bytes.Buffer, b *block.Block) error
- func UnmarshalCandidate(b *bytes.Buffer, c *Candidate) error
- func UnmarshalCandidateMessage(b *bytes.Buffer, m SerializableMessage) error
- func UnmarshalCertificate(r *bytes.Buffer, c *block.Certificate) error
- func UnmarshalCoinbase(w *bytes.Buffer, c *transactions.Coinbase) error
- func UnmarshalHeader(r *bytes.Buffer, h *block.Header) error
- func UnmarshalInput(r *bytes.Buffer, i *transactions.Input) error
- func UnmarshalLegacyBlock(r *bytes.Buffer, b *block.Block) error
- func UnmarshalLegacyStake(r *bytes.Buffer, tx *transactions.Stake) error
- func UnmarshalOutput(r *bytes.Buffer, o *transactions.Output) error
- func UnmarshalReduction(r *bytes.Buffer, bev *Reduction) error
- func UnmarshalReductionMessage(r *bytes.Buffer, m SerializableMessage) error
- func UnmarshalScore(r *bytes.Buffer, sev *Score) error
- func UnmarshalScoreMessage(r *bytes.Buffer, m SerializableMessage) error
- func UnmarshalStake(r *bytes.Buffer, tx *transactions.Stake) error
- func UnmarshalStandard(w *bytes.Buffer, s *transactions.Standard) error
- func UnmarshalTimelock(r *bytes.Buffer, tx *transactions.Timelock) error
- func UnmarshalTx(r *bytes.Buffer) (transactions.Transaction, error)
- func UnmarshalTxMessage(r *bytes.Buffer, m SerializableMessage) error
- func UnmarshalVotes(r *bytes.Buffer, votes []*StepVotes) error
- type Agreement
- func (a Agreement) Cmp(other Agreement) int
- func (a Agreement) Equal(aev Agreement) bool
- func (a Agreement) GenerateCertificate() *block.Certificate
- func (a Agreement) Sender() []byte
- func (a *Agreement) SetSignature(signedVotes []byte)
- func (a Agreement) SignedVotes() []byte
- func (a Agreement) State() header.Header
- func (a Agreement) String() string
- type Candidate
- type Message
- type Reduction
- func MockCommitteeVoteSet(p *user.Provisioners, k []key.Keys, hash []byte, committeeSize int, ...) []Reduction
- func MockReduction(hash []byte, round uint64, step uint8, keys []key.Keys, iterativeIdx ...int) Reduction
- func MockVoteSet(hash []byte, round uint64, step uint8, keys []key.Keys, amount int) []Reduction
- func MockVotes(hash []byte, round uint64, step uint8, keys []key.Keys, amount int) []Reduction
- func NewReduction(hdr header.Header) *Reduction
- func UnmarshalVoteSet(r *bytes.Buffer) ([]Reduction, error)
- type Score
- type ScoreProposal
- type Serializable
- type SerializableMessage
- type StepVotes
- type StepVotesMsg
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Marshal ¶
Marshal a Message into a buffer. The buffer *does* include its Category (so if this is undesired, the client of this call needs to explicitly call topics.Extract on the resulting buffer TODO: interface - once the Gossip preprocessing is removed from the Coordinator, there won't be a need for marshalBuffer
func MarshalAgreement ¶
MarshalAgreement marshals an Agreement event into a buffer.
func MarshalBid ¶
func MarshalBid(r *bytes.Buffer, tx *transactions.Bid) error
MarshalBid into a buffer
func MarshalBlock ¶
MarshalBlock marshals a block into a binary buffer
func MarshalCandidate ¶
MarshalCandidate encodes a Candidate to a binary form
func MarshalCertificate ¶
func MarshalCertificate(r *bytes.Buffer, c *block.Certificate) error
MarshalCertificate marshals a certificate
func MarshalCoinbase ¶
func MarshalCoinbase(w *bytes.Buffer, c *transactions.Coinbase) error
MarshalCoinbase into a buffer
func MarshalHashable ¶
MarshalHashable marshals the hashable part of the block into a binary buffer
func MarshalHeader ¶
MarshalHeader marshals the header of a block into a binary buffer
func MarshalInput ¶
MarshalInput marshals an Input object into a bytes.Buffer.
func MarshalOutput ¶
func MarshalOutput(w *bytes.Buffer, o *transactions.Output) error
MarshalOutput encode an Output struct and write to w.
func MarshalReduction ¶
MarshalReduction a Reduction event into a buffer.
func MarshalScore ¶
MarshalScore the buffer into a committee Event Field order is the following: * Blind Bid Fields [Score, Proof, Z, BidList, Seed, Candidate Block Hash]
func MarshalStake ¶
func MarshalStake(r *bytes.Buffer, tx *transactions.Stake) error
MarshalStake into a buffer
func MarshalStandard ¶
func MarshalStandard(w *bytes.Buffer, s *transactions.Standard) error
MarshalStandard marshals a standard transaction into a buffer
func MarshalStepVotes ¶
MarshalStepVotes marshals the aggregated form of the BLS PublicKey and Signature for an ordered set of votes
func MarshalTimelock ¶
func MarshalTimelock(r *bytes.Buffer, tx *transactions.Timelock) error
MarshalTimelock marshals a time lock into a buffer
func MarshalTx ¶
func MarshalTx(r *bytes.Buffer, tx transactions.Transaction) error
MarshalTx marshals a tx into a buffer
func MarshalVoteSet ¶
MarshalVoteSet marshals a slice of Reduction events to a buffer.
func MarshalVotes ¶
MarshalVotes marshals an array of StepVotes
func MockCertificate ¶
func MockCertificate(hash []byte, round uint64, keys []key.Keys, p *user.Provisioners) *block.Certificate
MockCertificate mocks a certificate
func SignAgreement ¶
SignAgreement signs an aggregated agreement event XXX: either use this function or delete it!! Right now it is not used
func UnmarshalAgreement ¶
UnmarshalAgreement unmarshals the buffer into an Agreement Field order is the following: * Header [BLS Public Key; Round; Step] * Agreement [Signed Vote Set; Vote Set; BlockHash]
func UnmarshalAgreementMessage ¶
func UnmarshalAgreementMessage(r *bytes.Buffer, m SerializableMessage) error
UnmarshalAgreementMessage unmarshal a network inbound Agreement
func UnmarshalBid ¶
func UnmarshalBid(r *bytes.Buffer, tx *transactions.Bid) error
UnmarshalBid tx from a buffer
func UnmarshalBlock ¶
UnmarshalBlock unmarshals a block from a binary buffer
func UnmarshalCandidate ¶
UnmarshalCandidate consumes a buffer, instantiate and fills the Candidate fields
func UnmarshalCandidateMessage ¶
func UnmarshalCandidateMessage(b *bytes.Buffer, m SerializableMessage) error
UnmarshalCandidateMessage encodes a message.Message (with a Candidate payload) into a buffer
func UnmarshalCertificate ¶
func UnmarshalCertificate(r *bytes.Buffer, c *block.Certificate) error
UnmarshalCertificate unmarshals a certificate
func UnmarshalCoinbase ¶
func UnmarshalCoinbase(w *bytes.Buffer, c *transactions.Coinbase) error
UnmarshalCoinbase from a buffer
func UnmarshalHeader ¶
UnmarshalHeader unmarshal a block header from a binary buffer
func UnmarshalInput ¶
func UnmarshalInput(r *bytes.Buffer, i *transactions.Input) error
UnmarshalInput from a bytes.Buffer.
func UnmarshalLegacyBlock ¶
UnmarshalLegacyBlock unmarshals a block from a binary buffer carrying legacy Stake transactions TODO: this should be better handled with a Marshaller object that supports different versions of the protocol
func UnmarshalLegacyStake ¶
func UnmarshalLegacyStake(r *bytes.Buffer, tx *transactions.Stake) error
UnmarshalLegacyStake is Deprecated. It is used solely to allow reutilization and parsing of the legacy Genesis Block
func UnmarshalOutput ¶
func UnmarshalOutput(r *bytes.Buffer, o *transactions.Output) error
UnmarshalOutput decodes an Output object from r into an output struct.
func UnmarshalReduction ¶
UnmarshalReduction unmarshals the buffer into a Reduction event.
func UnmarshalReductionMessage ¶
func UnmarshalReductionMessage(r *bytes.Buffer, m SerializableMessage) error
UnmarshalReductionMessage unmarshals a serializzation from a buffer
func UnmarshalScore ¶
UnmarshalScore unmarshals the buffer into a Score Event Field order is the following: * Score Payload [score, proof, Z, BidList, Seed, Block Candidate Hash]
func UnmarshalScoreMessage ¶
func UnmarshalScoreMessage(r *bytes.Buffer, m SerializableMessage) error
UnmarshalScoreMessage unmarshal a ScoreMessage from a buffer
func UnmarshalStake ¶
func UnmarshalStake(r *bytes.Buffer, tx *transactions.Stake) error
UnmarshalStake from a buffer
func UnmarshalStandard ¶
func UnmarshalStandard(w *bytes.Buffer, s *transactions.Standard) error
UnmarshalStandard tx from a buffer
func UnmarshalTimelock ¶
func UnmarshalTimelock(r *bytes.Buffer, tx *transactions.Timelock) error
UnmarshalTimelock tx from a buffer
func UnmarshalTx ¶
func UnmarshalTx(r *bytes.Buffer) (transactions.Transaction, error)
UnmarshalTx unmarshals a tx from a buffer
func UnmarshalTxMessage ¶
func UnmarshalTxMessage(r *bytes.Buffer, m SerializableMessage) error
UnmarshalTxMessage unmarshals a Message carrying a tx from a buffer
Types ¶
type Agreement ¶
type Agreement struct {
VotesPerStep []*StepVotes
Repr *big.Int
// contains filtered or unexported fields
}
Agreement is the Event created at the end of the Reduction process. It includes the aggregated compressed signatures of all voters
func MockAgreement ¶
func MockAgreement(hash []byte, round uint64, step uint8, keys []key.Keys, p *user.Provisioners, iterativeIdx ...int) Agreement
MockAgreement returns a mocked Agreement Event, to be used for testing purposes. It includes a vararg iterativeIdx to help avoiding duplicates when testing
func NewAgreement ¶
NewAgreement returns an empty Agreement event. It is supposed to be used by the (secondstep reducer) for creating Agreement messages
func (Agreement) GenerateCertificate ¶
func (a Agreement) GenerateCertificate() *block.Certificate
GenerateCertificate is used by the Chain component
func (*Agreement) SetSignature ¶
SetSignature set a signature to the Agreement
func (Agreement) SignedVotes ¶
SignedVotes returns the signed vote
type Candidate ¶
type Candidate struct {
*block.Block
*block.Certificate
}
Candidate is the composition of block and certificates
func MakeCandidate ¶
func MakeCandidate(blk *block.Block, cert *block.Certificate) Candidate
MakeCandidate creates a Candidate from a block and a certificate. It is meant for actual creation of the Candidate, rather than struct-decoding of a transmitted one
func NewCandidate ¶
func NewCandidate() *Candidate
NewCandidate is used for instantiating a new Candidate
type Message ¶
type Message interface {
//fmt.Stringer
Category() topics.Topic
Payload() interface{}
Equal(Message) bool
Id() []byte
}
Message is the core of the message-oriented architecture of the node. It is particularly important within the consensus, but in practice any component ends up dealing with it. It encapsulates the data exchanged by different nodes as well as internal components. The Message transits inside of the eventbus and is de- serialized through the Gossip procedure
type Reduction ¶
type Reduction struct {
SignedHash []byte
// contains filtered or unexported fields
}
Reduction is one of the messages used in the consensus algorithms. As such it encapsulates a header.Header to allow the Coordinator to correctly enforce the sequence of state changes expressed through the algorithm
func MockCommitteeVoteSet ¶
func MockCommitteeVoteSet(p *user.Provisioners, k []key.Keys, hash []byte, committeeSize int, round uint64, step uint8) []Reduction
MockCommitteeVoteSet mocks a VoteSet
func MockReduction ¶
func MockReduction(hash []byte, round uint64, step uint8, keys []key.Keys, iterativeIdx ...int) Reduction
MockReduction mocks a Reduction event and returns it. It includes a vararg iterativeIdx to help avoiding duplicates when testing
func MockVoteSet ¶
MockVoteSet mocks a slice of Reduction events for two adjacent steps, and returns it.
func NewReduction ¶
NewReduction returns and empty Reduction event.
func UnmarshalVoteSet ¶
UnmarshalVoteSet unmarshals a Reduction slice from a buffer
type Score ¶
type Score struct {
ScoreProposal
PrevHash []byte
VoteHash []byte
}
Score extends the ScoreProposal with additional fields related to the candidate it pairs up with. The Score is supposed to be immutable once created and it gets forwarded to the other nodes
func EmptyScore ¶
func EmptyScore() Score
EmptyScore is used primarily to initialize the Score, since empty scores should not be propagated externally
func NewScore ¶
func NewScore(proposal ScoreProposal, pubkey, prevHash, voteHash []byte) *Score
NewScore creates a new Score from a proposal
type ScoreProposal ¶
type ScoreProposal struct {
Score []byte
Proof []byte
Z []byte
BidListSubset []byte
Seed []byte
// contains filtered or unexported fields
}
ScoreProposal is an internal packet created by the node. the Score Message with the fields consistent with the Blind Bid data structure
func EmptyScoreProposal ¶
func EmptyScoreProposal(hdr header.Header) ScoreProposal
EmptyScoreProposal is used to initialize a ScoreProposal. It is used primarily by the internal Score generator
func MockScoreProposal ¶
func MockScoreProposal(hdr header.Header) ScoreProposal
MockScoreProposal mocks a ScoreProposal up
func NewScoreProposal ¶
NewScoreProposal creates a new ScoreProposa
func (ScoreProposal) IsEmpty ¶
func (e ScoreProposal) IsEmpty() bool
IsEmpty tests a ScoreProposal for emptyness
func (ScoreProposal) Sender ¶
func (e ScoreProposal) Sender() []byte
Sender of a Score event is the anonymous Z
func (ScoreProposal) State ¶
func (e ScoreProposal) State() header.Header
State is used to comply to the consensus.Message interface
func (ScoreProposal) String ¶
func (e ScoreProposal) String() string
String representation of the ScoreProposal
type Serializable ¶
type Serializable interface {
SetPayload(interface{})
}
Serializable allows to set a payload
type SerializableMessage ¶
type SerializableMessage interface {
Message
Serializable
}
SerializableMessage is a Serializable and a Message
type StepVotes ¶
StepVotes represents the aggregated votes for one reduction step. Normally an Agreement event includes two of these structures. They need to be kept separated since the BitSet representation of the Signees does not admit duplicates, whereas the same provisioner may very well be included in the committee for both Reduction steps
func GenVotes ¶
func GenVotes(hash []byte, round uint64, step uint8, keys []key.Keys, p *user.Provisioners) []*StepVotes
GenVotes randomly generates a slice of StepVotes with the indicated length. Albeit random, the generation is consistent with the rules of Votes
func NewStepVotes ¶
func NewStepVotes() *StepVotes
NewStepVotes returns a new StepVotes structure for a given round, step and block hash
func UnmarshalStepVotes ¶
UnmarshalStepVotes unmarshals a single StepVote
type StepVotesMsg ¶
type StepVotesMsg struct {
StepVotes
// contains filtered or unexported fields
}
StepVotesMsg is the internal message exchanged by the consensus components (through the signer.SendInternally method). It is not meant for external communications and therefore it does not have a Marshal/Unmarshal methods associated
func NewStepVotesMsg ¶
func NewStepVotesMsg(round uint64, hash []byte, sender []byte, sv StepVotes) StepVotesMsg
NewStepVotesMsg creates a StepVotesMsg
func (StepVotesMsg) State ¶
func (s StepVotesMsg) State() header.Header
State returns the Header without information about Sender (as this is only for internal communications)