sebak: boscoin.io/sebak/lib/ballot Index | Files

package ballot

import "boscoin.io/sebak/lib/ballot"

Index

Package Files

ballot.go ballot_state.go proposer_transaction.go util.go

Variables

var ProposerTransactionWellFormedCheckerFuncs = []common.CheckerFunc{
    transaction.CheckOverOperationsLimit,
    transaction.CheckSource,
    CheckProposerTransactionFee,
    CheckProposerTransactionOperationTypes,
    transaction.CheckOperations,
    transaction.CheckVerifySignature,
}
var TypesProposerTransaction map[operation.OperationType]struct{} = map[operation.OperationType]struct{}{
    operation.TypeCollectTxFee: struct{}{},
    operation.TypeInflation:    struct{}{},
}

func CheckHasCorrectTime Uses

func CheckHasCorrectTime(timeStr string) error

func CheckProposerTransactionFee Uses

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

func CheckProposerTransactionOperationTypes Uses

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

func NewCollectTxFeeFromBallot Uses

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

func NewInflationFromBallot Uses

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

type Ballot Uses

type Ballot struct {
    H   BallotHeader
    B   BallotBody
}

func NewBallot Uses

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

func NewBallotFromJSON Uses

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

func (Ballot) Confirmed Uses

func (b Ballot) Confirmed() string

func (Ballot) Equal Uses

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

func (Ballot) GetHash Uses

func (b Ballot) GetHash() string

func (Ballot) GetType Uses

func (b Ballot) GetType() common.MessageType

func (Ballot) IsEmpty Uses

func (b Ballot) IsEmpty() bool

func (Ballot) IsFromProposer Uses

func (b Ballot) IsFromProposer() bool

func (Ballot) IsValidVersion Uses

func (b Ballot) IsValidVersion(version string) bool

func (Ballot) IsWellFormed Uses

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

func (Ballot) Proposer Uses

func (b Ballot) Proposer() string

func (Ballot) ProposerConfirmed Uses

func (b Ballot) ProposerConfirmed() string

func (Ballot) ProposerTransaction Uses

func (b Ballot) ProposerTransaction() ProposerTransaction

func (Ballot) Serialize Uses

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

func (*Ballot) SetProposerTransaction Uses

func (b *Ballot) SetProposerTransaction(ptx ProposerTransaction)

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

func (*Ballot) SetReason Uses

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

func (*Ballot) SetSource Uses

func (b *Ballot) SetSource(source string)

func (*Ballot) SetVote Uses

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

func (*Ballot) Sign Uses

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

func (*Ballot) SignByProposer Uses

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

func (Ballot) Source Uses

func (b Ballot) Source() string

func (Ballot) State Uses

func (b Ballot) State() State

func (Ballot) String Uses

func (b Ballot) String() string

func (Ballot) Transactions Uses

func (b Ballot) Transactions() []string

func (*Ballot) TransactionsLength Uses

func (b *Ballot) TransactionsLength() int

func (Ballot) VerifyProposer Uses

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

func (Ballot) VerifySource Uses

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

func (Ballot) Version Uses

func (b Ballot) Version() string

func (Ballot) Vote Uses

func (b Ballot) Vote() voting.Hole

func (Ballot) VotingBasis Uses

func (b Ballot) VotingBasis() voting.Basis

type BallotBody Uses

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 Uses

func (rb BallotBody) MakeHash() []byte

func (BallotBody) MakeHashString Uses

func (rb BallotBody) MakeHashString() string

type BallotBodyProposed Uses

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 Uses

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 Uses

type ProposerTransaction struct {
    transaction.Transaction
}

func NewProposerTransaction Uses

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

func NewProposerTransactionFromBallot Uses

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

func (ProposerTransaction) CollectTxFee Uses

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

func (ProposerTransaction) Inflation Uses

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

func (ProposerTransaction) IsWellFormed Uses

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

func (ProposerTransaction) IsWellFormedWithBallot Uses

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

func (*ProposerTransaction) UnmarshalJSON Uses

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

type State Uses

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

func (State) IsValid Uses

func (s State) IsValid() bool

func (State) IsValidForVote Uses

func (s State) IsValidForVote() bool

func (State) Next Uses

func (s State) Next() State

func (State) String Uses

func (s State) String() string

Package ballot imports 9 packages (graph) and is imported by 15 packages. Updated 2019-02-20. Refresh now. Tools for package owners.