types

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2018 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VoteTypePrevote   = byte(0x01)
	VoteTypePrecommit = byte(0x02)
)

Types of votes TODO Make a new type "VoteType"

Variables

View Source
var (
	ErrRefInvalidType = errors.New("Invalid Reference Type")
	ErrRefInvalidHash = errors.New("Invalid Reference Hash")
)
View Source
var (
	ErrVoteChannelNotMatch = errors.New("Invalid Channel")
)

Functions

func IsVoteTypeValid

func IsVoteTypeValid(type_ byte) bool

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

func MakeBlock(height int64, txs []tps.Tx, commit *Commit) *Block

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

func (b *Block) AddEvidence(evidence []tps.Evidence)

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

func (b *Block) Hash() cmn.HexBytes

Hash computes and returns the block hash. If the block is incomplete, block hash is nil for safety.

func (*Block) HashesTo

func (b *Block) HashesTo(hash []byte) bool

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

func (b *Block) MakePartSet(partSize int) *tps.PartSet

MakePartSet returns a PartSet containing parts of a serialized block. This is the form in which the block is gossipped to peers.

func (*Block) String

func (b *Block) String() string

String returns a string representation of the block

func (*Block) StringIndented

func (b *Block) StringIndented(indent string) string

StringIndented returns a string representation of the block

func (*Block) StringShort

func (b *Block) StringShort() string

StringShort returns a shortened string representation of the block

func (*Block) ValidateBasic

func (b *Block) ValidateBasic() error

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) BitArray

func (commit *Commit) BitArray() *cmn.BitArray

BitArray returns a BitArray of which validators voted in this commit

func (*Commit) FirstPrecommit

func (commit *Commit) FirstPrecommit() *Vote

FirstPrecommit returns the first non-nil precommit in the commit

func (*Commit) GetByIndex

func (commit *Commit) GetByIndex(index int) *Vote

GetByIndex returns the vote corresponding to a given validator index

func (*Commit) Hash

func (commit *Commit) Hash() cmn.HexBytes

Hash returns the hash of the commit

func (*Commit) Height

func (commit *Commit) Height() int64

Height returns the height of the commit

func (*Commit) IsCommit

func (commit *Commit) IsCommit() bool

IsCommit returns true if there is at least one vote

func (*Commit) Round

func (commit *Commit) Round() int

Round returns the round of the commit

func (*Commit) Size

func (commit *Commit) Size() int

Size returns the number of votes in the commit

func (*Commit) StringIndented

func (commit *Commit) StringIndented(indent string) string

StringIndented returns a string representation of the commit

func (*Commit) Type

func (commit *Commit) Type() byte

Type returns the vote type of the commit, which is always VoteTypePrecommit

func (*Commit) ValidateBasic

func (commit *Commit) ValidateBasic() error

ValidateBasic performs basic validation that doesn't involve state data.

type Data

type Data struct {

	// Tx 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) Hash

func (data *Data) Hash() cmn.HexBytes

Hash returns the hash of the data

func (*Data) StringIndented

func (data *Data) StringIndented(indent string) string

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 Event

type Event interface {
}

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 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) Hash

func (h *Header) Hash() cmn.HexBytes

Hash returns the hash of the header. Returns nil if ValidatorHash is missing.

func (*Header) StringIndented

func (h *Header) StringIndented(indent string) string

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 Proposal

type Proposal struct {
}

func NewProposal

func NewProposal() *Proposal

type Reference

type Reference struct {
	Type          string       `json:"type"`
	Url           url.URL      `json:"url"`
	ReferenceHash cmn.HexBytes `json:"referenceHash"`
}

func (*Reference) Hash

func (reference *Reference) Hash() cmn.HexBytes

type SignedHeader

type SignedHeader struct {
	Header *Header `json:"header"`
	Commit *Commit `json:"commit"`
}

SignedHeader is a header along with the commits that prove it

type Vote

type Vote struct {
	Vote    types.Vote `json:"vote"`
	Channel int        `json:"channel"`
}

Represents a prevote, precommit, or commit vote from validators for consensus.

func (*Vote) Copy

func (vote *Vote) Copy() *Vote

func (*Vote) String

func (vote *Vote) String() string

func (*Vote) Verify

func (vote *Vote) Verify(chainID string, pubKey crypto.PubKey, channel int) error

func (*Vote) WriteSignBytes

func (vote *Vote) WriteSignBytes(chainID string, w io.Writer, n *int, err *error)

type VoteSet

type VoteSet struct {
}

func NewVoteSet

func NewVoteSet() *VoteSet

Jump to

Keyboard shortcuts

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