Documentation ¶
Index ¶
- Constants
- Variables
- func IsVoteTypeValid(type_ byte) bool
- type Block
- func (b *Block) AddEvidence(evidence []tps.Evidence)
- func (b *Block) FillHeader()
- func (b *Block) Hash() cmn.HexBytes
- func (b *Block) HashesTo(hash []byte) bool
- func (b *Block) MakePartSet(partSize int) *tps.PartSet
- func (b *Block) String() string
- func (b *Block) StringIndented(indent string) string
- func (b *Block) StringShort() string
- func (b *Block) ValidateBasic() error
- type Commit
- func (commit *Commit) BitArray() *cmn.BitArray
- func (commit *Commit) FirstPrecommit() *Vote
- func (commit *Commit) GetByIndex(index int) *Vote
- func (commit *Commit) Hash() cmn.HexBytes
- func (commit *Commit) Height() int64
- func (commit *Commit) IsCommit() bool
- func (commit *Commit) Round() int
- func (commit *Commit) Size() int
- func (commit *Commit) StringIndented(indent string) string
- func (commit *Commit) Type() byte
- func (commit *Commit) ValidateBasic() error
- type Data
- type ErrVoteConflictingVotes
- type Event
- type EventDataNewBlock
- type EventDataNewCommit
- type EventDataNewPrecommit
- type EventDataNewPrevote
- type EventDataNewProposal
- type EvidenceData
- type Header
- type Once
- type Proposal
- type Reference
- type SignedHeader
- type Vote
- type VoteSet
Constants ¶
const ( VoteTypePrevote = byte(0x01) VoteTypePrecommit = byte(0x02) )
Types of votes TODO Make a new type "VoteType"
Variables ¶
var ( ErrRefInvalidType = errors.New("Invalid Reference Type") ErrRefInvalidHash = errors.New("Invalid Reference Hash") )
var (
ErrVoteChannelNotMatch = errors.New("Invalid Channel")
)
Functions ¶
func IsVoteTypeValid ¶
Types ¶
type Block ¶
type Block struct { *Header `json:"header"` *Data `json:"data"` Evidence EvidenceData `json:"evidence"` LastCommit *Commit `json:"last_commit"` }
Block defines the atomic unit of a oneledger blockchain. TODO: add Version byte
func MakeBlock ¶
MakeBlock returns a new block with an empty header, except what can be computed from itself. It populates the same set of fields validated by ValidateBasic
func (*Block) AddEvidence ¶
AddEvidence appends the given evidence to the block
func (*Block) FillHeader ¶
func (b *Block) FillHeader()
FillHeader fills in any remaining header fields that are a function of the block data
func (*Block) Hash ¶
Hash computes and returns the block hash. If the block is incomplete, block hash is nil for safety.
func (*Block) HashesTo ¶
HashesTo is a convenience function that checks if a block hashes to the given argument. A nil block never hashes to anything, and nothing hashes to a nil hash.
func (*Block) MakePartSet ¶
MakePartSet returns a PartSet containing parts of a serialized block. This is the form in which the block is gossipped to peers.
func (*Block) StringIndented ¶
StringIndented returns a string representation of the block
func (*Block) StringShort ¶
StringShort returns a shortened string representation of the block
func (*Block) ValidateBasic ¶
ValidateBasic performs basic validation that doesn't involve state data. It checks the internal consistency of the block.
type Commit ¶
type Commit struct { // NOTE: The Precommits are in order of address to preserve the bonded ValidatorSet order. // Any peer with a block can gossip precommits by index with a peer without recalculating the // active ValidatorSet. BlockID tps.BlockID `json:"blockID"` Precommits []*Vote `json:"precommits"` // contains filtered or unexported fields }
Commit contains the evidence that a block was committed by a set of validators. NOTE: Commit is empty for height 1, but never nil.
func (*Commit) FirstPrecommit ¶
FirstPrecommit returns the first non-nil precommit in the commit
func (*Commit) GetByIndex ¶
GetByIndex returns the vote corresponding to a given validator index
func (*Commit) StringIndented ¶
StringIndented returns a string representation of the commit
func (*Commit) ValidateBasic ¶
ValidateBasic performs basic validation that doesn't involve state data.
type Data ¶
type Data struct { // Txs that will be applied by state @ block.Height+1. // NOTE: not all txs here are valid. We're just agreeing on the order first. // This means that block.AppHash does not include these txs. Txs tps.Txs `json:"txs"` // contains filtered or unexported fields }
Data contains the set of transactions included in the block
func (*Data) StringIndented ¶
StringIndented returns a string representation of the transactions
type ErrVoteConflictingVotes ¶
type ErrVoteConflictingVotes struct {
*types.DuplicateVoteEvidence
}
func NewConflictingVoteError ¶
func NewConflictingVoteError(val *types.Validator, voteA, voteB *Vote) *ErrVoteConflictingVotes
func (*ErrVoteConflictingVotes) Error ¶
func (err *ErrVoteConflictingVotes) Error() string
type EventDataNewBlock ¶
type EventDataNewBlock struct {
Block *Block `json:"block"`
}
type EventDataNewCommit ¶
type EventDataNewCommit struct {
Commit *Commit `json:"commit"`
}
type EventDataNewPrecommit ¶
type EventDataNewPrecommit struct {
Precommit *Commit `json:"precommit"`
}
type EventDataNewPrevote ¶
type EventDataNewPrevote struct {
Vote *Vote `json:"vote"`
}
type EventDataNewProposal ¶
type EventDataNewProposal struct {
Proposal *Proposal `json:"proposal"`
}
type EvidenceData ¶
type EvidenceData struct { Evidence tps.EvidenceList `json:"evidence"` // contains filtered or unexported fields }
EvidenceData contains any evidence of malicious wrong-doing by validators
func (*EvidenceData) Hash ¶
func (data *EvidenceData) Hash() cmn.HexBytes
Hash returns the hash of the data.
func (*EvidenceData) StringIndented ¶
func (data *EvidenceData) StringIndented(indent string) string
StringIndented returns a string representation of the evidence.
type Header ¶
type Header struct { // basic block info ChainID string `json:"chain_id"` Height int64 `json:"height"` Time time.Time `json:"time"` NumTxs int64 `json:"num_txs"` // prev block info LastBlockID tps.BlockID `json:"last_block_id"` TotalTxs int64 `json:"total_txs"` // hashes of block data LastCommitHash cmn.HexBytes `json:"last_commit_hash"` // commit from validators from the last block DataHash cmn.HexBytes `json:"data_hash"` // transactions // hashes from the app output from the prev block ValidatorsHash cmn.HexBytes `json:"validators_hash"` // validators for the current block ConsensusHash cmn.HexBytes `json:"consensus_hash"` // consensus params for current block AppHash cmn.HexBytes `json:"app_hash"` // state after txs from the previous block LastResultsHash cmn.HexBytes `json:"last_results_hash"` // root hash of all results from the txs from the previous block // consensus info EvidenceHash cmn.HexBytes `json:"evidence_hash"` // evidence included in the block }
Header defines the structure of a oneledger block header TODO: limit header size NOTE: changes to the Header should be duplicated in the abci Header
func (*Header) StringIndented ¶
StringIndented returns a string representation of the header
type Once ¶
type Once struct {
// contains filtered or unexported fields
}
Once is an object that will perform exactly one action.
func (*Once) Do ¶
func (o *Once) Do(f func())
Do calls the function f if and only if Do is being called for the first time for this instance of Once. In other words, given
var once Once
if once.Do(f) is called multiple times, only the first call will invoke f, even if f has a different value in each invocation. A new instance of Once is required for each function to execute.
Do is intended for initialization that must be run exactly once. Since f is niladic, it may be necessary to use a function literal to capture the arguments to a function to be invoked by Do:
config.once.Do(func() { config.init(filename) })
Because no call to Do returns until the one call to f returns, if f causes Do to be called, it will deadlock.
If f panics, Do considers it to have returned; future calls of Do return without calling f.
type Reference ¶
type SignedHeader ¶
SignedHeader is a header along with the commits that prove it