ballot

package
v0.0.0-...-8aa4d74 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2019 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TypesProposerTransaction map[operation.OperationType]struct{} = map[operation.OperationType]struct{}{
	operation.TypeCollectTxFee: struct{}{},
	operation.TypeInflation:    struct{}{},
}

Functions

func CheckHasCorrectTime

func CheckHasCorrectTime(timeStr string) error

func CheckProposerTransactionFee

func CheckProposerTransactionFee(c common.Checker, args ...interface{}) (err error)

func CheckProposerTransactionOperationTypes

func CheckProposerTransactionOperationTypes(c common.Checker, args ...interface{}) (err error)

func NewCollectTxFeeFromBallot

func NewCollectTxFeeFromBallot(blt Ballot, commonAccount string, txs ...transaction.Transaction) (opb operation.CollectTxFee, err error)

func NewInflationFromBallot

func NewInflationFromBallot(blt Ballot, commonAccount string, initialBalance common.Amount) (opb operation.Inflation, err error)

Types

type Ballot

type Ballot struct {
	H BallotHeader
	B BallotBody
}

func NewBallot

func NewBallot(fromAddr string, proposerAddr string, basis voting.Basis, transactions []string) (b *Ballot)

func NewBallotFromJSON

func NewBallotFromJSON(data []byte) (b Ballot, err error)

func (Ballot) Confirmed

func (b Ballot) Confirmed() string

func (Ballot) Equal

func (b Ballot) Equal(m common.Message) bool

func (Ballot) GetHash

func (b Ballot) GetHash() string

func (Ballot) GetType

func (b Ballot) GetType() common.MessageType

func (Ballot) IsEmpty

func (b Ballot) IsEmpty() bool

func (Ballot) IsFromProposer

func (b Ballot) IsFromProposer() bool

func (Ballot) IsValidVersion

func (b Ballot) IsValidVersion(version string) bool

func (Ballot) IsWellFormed

func (b Ballot) IsWellFormed(conf common.Config) (err error)

func (Ballot) Proposer

func (b Ballot) Proposer() string

func (Ballot) ProposerConfirmed

func (b Ballot) ProposerConfirmed() string

func (Ballot) ProposerTransaction

func (b Ballot) ProposerTransaction() ProposerTransaction

func (Ballot) Serialize

func (b Ballot) Serialize() (encoded []byte, err error)

func (*Ballot) SetProposerTransaction

func (b *Ballot) SetProposerTransaction(ptx ProposerTransaction)

SetProposerTransaction should be set in `Ballot`, without it can not be passed thru `Ballot.IsWellFormed()`.

func (*Ballot) SetReason

func (b *Ballot) SetReason(reason *errors.Error)

func (*Ballot) SetSource

func (b *Ballot) SetSource(source string)

func (*Ballot) SetVote

func (b *Ballot) SetVote(state State, vote voting.Hole)

func (*Ballot) Sign

func (b *Ballot) Sign(kp keypair.KP, networkID []byte)

func (*Ballot) SignByProposer

func (b *Ballot) SignByProposer(kp keypair.KP, networkID []byte)

func (Ballot) Source

func (b Ballot) Source() string

func (Ballot) State

func (b Ballot) State() State

func (Ballot) String

func (b Ballot) String() string

func (Ballot) Transactions

func (b Ballot) Transactions() []string

func (*Ballot) TransactionsLength

func (b *Ballot) TransactionsLength() int

func (Ballot) VerifyProposer

func (b Ballot) VerifyProposer(networkID []byte) (err error)

func (Ballot) VerifySource

func (b Ballot) VerifySource(networkID []byte) (err error)

func (Ballot) Version

func (b Ballot) Version() string

func (Ballot) Vote

func (b Ballot) Vote() voting.Hole

func (Ballot) VotingBasis

func (b Ballot) VotingBasis() voting.Basis

type BallotBody

type BallotBody struct {
	Confirmed string             `json:"confirmed"` // created time, ISO8601
	Proposed  BallotBodyProposed `json:"proposed"`
	Source    string             `json:"source"`
	State     State              `json:"state"`
	Vote      voting.Hole        `json:"vote"`
	Reason    *errors.Error      `json:"reason"`
}

func (BallotBody) MakeHash

func (rb BallotBody) MakeHash() []byte

func (BallotBody) MakeHashString

func (rb BallotBody) MakeHashString() string

type BallotBodyProposed

type BallotBodyProposed struct {
	Confirmed           string              `json:"confirmed"` // created time, ISO8601
	Proposer            string              `json:"proposer"`
	VotingBasis         voting.Basis        `json:"voting_basis"`
	Transactions        []string            `json:"transactions"`
	ProposerTransaction ProposerTransaction `json:"proposer_transaction"`
}

type BallotHeader

type BallotHeader struct {
	Version           string `json:"version"`            // version of `BallotBody`
	Hash              string `json:"hash"`               // hash of `BallotBody`
	Signature         string `json:"signature"`          // signed by source node of <networkID> + `Hash`
	ProposerSignature string `json:"proposer_signature"` // signed by proposer of <networkID> + `Hash` of `BallotBodyProposed`
}

type ProposerTransaction

type ProposerTransaction struct {
	transaction.Transaction
}

func NewProposerTransaction

func NewProposerTransaction(proposer string, ops ...operation.Operation) (ptx ProposerTransaction, err error)

func NewProposerTransactionFromBallot

func NewProposerTransactionFromBallot(blt Ballot, opc operation.CollectTxFee, opi operation.Inflation) (ptx ProposerTransaction, err error)

func (ProposerTransaction) CollectTxFee

func (p ProposerTransaction) CollectTxFee() (opb operation.CollectTxFee, err error)

func (ProposerTransaction) Inflation

func (p ProposerTransaction) Inflation() (opb operation.Inflation, err error)

func (ProposerTransaction) IsWellFormed

func (p ProposerTransaction) IsWellFormed(conf common.Config) (err error)

func (ProposerTransaction) IsWellFormedWithBallot

func (p ProposerTransaction) IsWellFormedWithBallot(blt Ballot, conf common.Config) (err error)

func (*ProposerTransaction) UnmarshalJSON

func (p *ProposerTransaction) UnmarshalJSON(b []byte) error

type State

type State uint
const (
	StateNONE State = iota
	StateINIT
	StateSIGN
	StateACCEPT
	StateALLCONFIRM
)

func (State) IsValid

func (s State) IsValid() bool

func (State) IsValidForVote

func (s State) IsValidForVote() bool

func (State) Next

func (s State) Next() State

func (State) String

func (s State) String() string

Jump to

Keyboard shortcuts

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