types

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2018 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventBond              = "Bond"
	EventCompleteProposal  = "CompleteProposal"
	EventDupeout           = "Dupeout"
	EventFork              = "Fork"
	EventLock              = "Lock"
	EventNewBlock          = "NewBlock"
	EventNewBlockHeader    = "NewBlockHeader"
	EventNewRound          = "NewRound"
	EventNewRoundStep      = "NewRoundStep"
	EventPolka             = "Polka"
	EventRebond            = "Rebond"
	EventRelock            = "Relock"
	EventTimeoutPropose    = "TimeoutPropose"
	EventTimeoutWait       = "TimeoutWait"
	EventTx                = "Tx"
	EventUnbond            = "Unbond"
	EventUnlock            = "Unlock"
	EventVote              = "Vote"
	EventProposalHeartbeat = "ProposalHeartbeat"
)

Reserved event types

View Source
const (
	EventDataTypeNewBlock          = byte(0x01)
	EventDataTypeFork              = byte(0x02)
	EventDataTypeTx                = byte(0x03)
	EventDataTypeNewBlockHeader    = byte(0x04)
	EventDataTypeRoundState        = byte(0x11)
	EventDataTypeVote              = byte(0x12)
	EventDataTypeProposalHeartbeat = byte(0x20)
)
View Source
const (
	// EventTypeKey is a reserved key, used to specify event type in tags.
	EventTypeKey = "tm.event"
	// TxHashKey is a reserved key, used to specify transaction's hash.
	// see EventBus#PublishEventTx
	TxHashKey = "tx.hash"
	// TxHeightKey is a reserved key, used to specify transaction block's height.
	// see EventBus#PublishEventTx
	TxHeightKey = "tx.height"
)
View Source
const (
	VoteTypePrevote   = byte(0x01)
	VoteTypePrecommit = byte(0x02)
)

Types of votes TODO Make a new type "VoteType"

Variables

View Source
var (
	EventDataNameNewBlock          = "new_block"
	EventDataNameNewBlockHeader    = "new_block_header"
	EventDataNameTx                = "tx"
	EventDataNameRoundState        = "round_state"
	EventDataNameVote              = "vote"
	EventDataNameProposalHeartbeat = "proposal_heartbeat"
)
View Source
var (
	EventQueryBond              = QueryForEvent(EventBond)
	EventQueryUnbond            = QueryForEvent(EventUnbond)
	EventQueryRebond            = QueryForEvent(EventRebond)
	EventQueryDupeout           = QueryForEvent(EventDupeout)
	EventQueryFork              = QueryForEvent(EventFork)
	EventQueryNewBlock          = QueryForEvent(EventNewBlock)
	EventQueryNewBlockHeader    = QueryForEvent(EventNewBlockHeader)
	EventQueryNewRound          = QueryForEvent(EventNewRound)
	EventQueryNewRoundStep      = QueryForEvent(EventNewRoundStep)
	EventQueryTimeoutPropose    = QueryForEvent(EventTimeoutPropose)
	EventQueryCompleteProposal  = QueryForEvent(EventCompleteProposal)
	EventQueryPolka             = QueryForEvent(EventPolka)
	EventQueryUnlock            = QueryForEvent(EventUnlock)
	EventQueryLock              = QueryForEvent(EventLock)
	EventQueryRelock            = QueryForEvent(EventRelock)
	EventQueryTimeoutWait       = QueryForEvent(EventTimeoutWait)
	EventQueryVote              = QueryForEvent(EventVote)
	EventQueryProposalHeartbeat = QueryForEvent(EventProposalHeartbeat)
	EventQueryTx                = QueryForEvent(EventTx)
)
View Source
var (
	PeerStateKey     = "ConsensusReactor.peerState"
	PeerMempoolChKey = "MempoolReactor.peerMempoolCh"
)

UNSTABLE

View Source
var (
	ErrPartSetUnexpectedIndex = errors.New("Error part set unexpected index")
	ErrPartSetInvalidProof    = errors.New("Error part set invalid proof")
)
View Source
var (
	ErrInvalidBlockPartSignature = errors.New("Error invalid block part signature")
	ErrInvalidBlockPartHash      = errors.New("Error invalid block part hash")
)
View Source
var (
	ErrVoteUnexpectedStep            = errors.New("Unexpected step")
	ErrVoteInvalidValidatorIndex     = errors.New("Invalid validator index")
	ErrVoteInvalidValidatorAddress   = errors.New("Invalid validator address")
	ErrVoteInvalidSignature          = errors.New("Invalid signature")
	ErrVoteInvalidBlockHash          = errors.New("Invalid block hash")
	ErrVoteNonDeterministicSignature = errors.New("Non-deterministic signature")
	ErrVoteNil                       = errors.New("Nil vote")
)
View Source
var TM2PB = tm2pb{}

TM2PB is used for converting Tendermint types to protobuf types. UNSTABLE

View Source
var ValidatorCodec = validatorCodec{}

Functions

func CanonicalTime added in v0.15.0

func CanonicalTime(t time.Time) string

func EventQueryTxFor added in v0.13.0

func EventQueryTxFor(tx Tx) tmpubsub.Query

func IsVoteTypeValid added in v0.8.0

func IsVoteTypeValid(type_ byte) bool

func QueryForEvent added in v0.14.0

func QueryForEvent(eventType string) tmpubsub.Query

func RandValidator

func RandValidator(randPower bool, minPower int64) (*Validator, *PrivValidatorFS)

RandValidator returns a randomized validator, useful for testing. UNSTABLE

func RandValidatorSet

func RandValidatorSet(numValidators int, votingPower int64) (*ValidatorSet, []*PrivValidatorFS)

RandValidatorSet returns a randomized validator set, useful for testing. NOTE: PrivValidator are in order. UNSTABLE

func SignBytes

func SignBytes(chainID string, o Signable) []byte

SignBytes is a convenience method for getting the bytes to sign of a Signable.

Types

type ABCIResult added in v0.15.0

type ABCIResult struct {
	Code uint32       `json:"code"`
	Data cmn.HexBytes `json:"data"`
}

ABCIResult is the deterministic component of a ResponseDeliverTx. TODO: add Tags

func NewResultFromResponse added in v0.15.0

func NewResultFromResponse(response *abci.ResponseDeliverTx) ABCIResult

func (ABCIResult) Hash added in v0.15.0

func (a ABCIResult) Hash() []byte

Hash returns the canonical hash of the ABCIResult

type ABCIResults added in v0.15.0

type ABCIResults []ABCIResult

ABCIResults wraps the deliver tx results to return a proof

func NewResults added in v0.15.0

func NewResults(del []*abci.ResponseDeliverTx) ABCIResults

NewResults creates ABCIResults from ResponseDeliverTx

func (ABCIResults) Bytes added in v0.15.0

func (a ABCIResults) Bytes() []byte

Bytes serializes the ABCIResponse using go-wire

func (ABCIResults) Hash added in v0.15.0

func (a ABCIResults) Hash() []byte

Hash returns a merkle hash of all results

func (ABCIResults) ProveResult added in v0.15.0

func (a ABCIResults) ProveResult(i int) merkle.SimpleProof

ProveResult returns a merkle proof of one result from the set

type Address added in v0.16.0

type Address = cmn.HexBytes

Address is hex bytes. TODO: crypto.Address

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 Tendermint blockchain. TODO: add Version byte

func MakeBlock added in v0.8.0

func MakeBlock(height int64, txs []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 added in v0.15.0

func (b *Block) AddEvidence(evidence []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) *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 BlockEventPublisher added in v0.15.0

type BlockEventPublisher interface {
	PublishEventNewBlock(block EventDataNewBlock) error
	PublishEventNewBlockHeader(header EventDataNewBlockHeader) error
	PublishEventTx(EventDataTx) error
}

BlockEventPublisher publishes all block related events

type BlockGossip added in v0.15.0

type BlockGossip struct {
	BlockPartSizeBytes int `json:"block_part_size_bytes"` // NOTE: must not be 0
}

BlockGossip determine consensus critical elements of how blocks are gossiped

func DefaultBlockGossip added in v0.15.0

func DefaultBlockGossip() BlockGossip

DefaultBlockGossip returns a default BlockGossip.

type BlockID added in v0.8.0

type BlockID struct {
	Hash        cmn.HexBytes  `json:"hash"`
	PartsHeader PartSetHeader `json:"parts"`
}

BlockID defines the unique ID of a block as its Hash and its PartSetHeader

func (BlockID) Equals added in v0.8.0

func (blockID BlockID) Equals(other BlockID) bool

Equals returns true if the BlockID matches the given BlockID

func (BlockID) IsZero added in v0.8.0

func (blockID BlockID) IsZero() bool

IsZero returns true if this is the BlockID for a nil-block

func (BlockID) Key added in v0.8.0

func (blockID BlockID) Key() string

Key returns a machine-readable string representation of the BlockID

func (BlockID) String added in v0.8.0

func (blockID BlockID) String() string

String returns a human readable string representation of the BlockID

func (BlockID) WriteSignBytes added in v0.8.0

func (blockID BlockID) WriteSignBytes(w io.Writer, n *int, err *error)

WriteSignBytes writes the canonical bytes of the BlockID to the given writer for digital signing

type BlockMeta

type BlockMeta struct {
	BlockID BlockID `json:"block_id"` // the block hash and partsethash
	Header  *Header `json:"header"`   // The block's Header
}

BlockMeta contains meta information about a block - namely, it's ID and Header.

func NewBlockMeta

func NewBlockMeta(block *Block, blockParts *PartSet) *BlockMeta

NewBlockMeta returns a new BlockMeta from the block and its blockParts.

type BlockSize added in v0.15.0

type BlockSize struct {
	MaxBytes int   `json:"max_bytes"` // NOTE: must not be 0 nor greater than 100MB
	MaxTxs   int   `json:"max_txs"`
	MaxGas   int64 `json:"max_gas"`
}

BlockSize contain limits on the block size.

func DefaultBlockSize added in v0.15.0

func DefaultBlockSize() BlockSize

DefaultBlockSize returns a default BlockSize.

type BlockStore added in v0.9.0

type BlockStore interface {
	BlockStoreRPC
	SaveBlock(block *Block, blockParts *PartSet, seenCommit *Commit)
}

BlockStore defines the BlockStore interface used by the ConsensusState. UNSTABLE

type BlockStoreRPC added in v0.9.0

type BlockStoreRPC interface {
	Height() int64

	LoadBlockMeta(height int64) *BlockMeta
	LoadBlock(height int64) *Block
	LoadBlockPart(height int64, index int) *Part

	LoadBlockCommit(height int64) *Commit
	LoadSeenCommit(height int64) *Commit
}

BlockStoreRPC is the block store interface used by the RPC. UNSTABLE

type CanonicalJSONBlockID added in v0.8.0

type CanonicalJSONBlockID struct {
	Hash        cmn.HexBytes               `json:"hash,omitempty"`
	PartsHeader CanonicalJSONPartSetHeader `json:"parts,omitempty"`
}

func CanonicalBlockID added in v0.8.0

func CanonicalBlockID(blockID BlockID) CanonicalJSONBlockID

type CanonicalJSONHeartbeat added in v0.10.3

type CanonicalJSONHeartbeat struct {
	Height           int64   `json:"height"`
	Round            int     `json:"round"`
	Sequence         int     `json:"sequence"`
	ValidatorAddress Address `json:"validator_address"`
	ValidatorIndex   int     `json:"validator_index"`
}

func CanonicalHeartbeat added in v0.10.3

func CanonicalHeartbeat(heartbeat *Heartbeat) CanonicalJSONHeartbeat

type CanonicalJSONOnceHeartbeat added in v0.10.3

type CanonicalJSONOnceHeartbeat struct {
	ChainID   string                 `json:"chain_id"`
	Heartbeat CanonicalJSONHeartbeat `json:"heartbeat"`
}

type CanonicalJSONOnceProposal added in v0.8.0

type CanonicalJSONOnceProposal struct {
	ChainID  string                `json:"chain_id"`
	Proposal CanonicalJSONProposal `json:"proposal"`
}

type CanonicalJSONOnceVote added in v0.8.0

type CanonicalJSONOnceVote struct {
	ChainID string            `json:"chain_id"`
	Vote    CanonicalJSONVote `json:"vote"`
}

type CanonicalJSONPartSetHeader added in v0.8.0

type CanonicalJSONPartSetHeader struct {
	Hash  cmn.HexBytes `json:"hash"`
	Total int          `json:"total"`
}

func CanonicalPartSetHeader added in v0.8.0

func CanonicalPartSetHeader(psh PartSetHeader) CanonicalJSONPartSetHeader

type CanonicalJSONProposal added in v0.8.0

type CanonicalJSONProposal struct {
	BlockPartsHeader CanonicalJSONPartSetHeader `json:"block_parts_header"`
	Height           int64                      `json:"height"`
	POLBlockID       CanonicalJSONBlockID       `json:"pol_block_id"`
	POLRound         int                        `json:"pol_round"`
	Round            int                        `json:"round"`
	Timestamp        string                     `json:"timestamp"`
}

func CanonicalProposal added in v0.8.0

func CanonicalProposal(proposal *Proposal) CanonicalJSONProposal

type CanonicalJSONVote added in v0.8.0

type CanonicalJSONVote struct {
	BlockID   CanonicalJSONBlockID `json:"block_id"`
	Height    int64                `json:"height"`
	Round     int                  `json:"round"`
	Timestamp string               `json:"timestamp"`
	Type      byte                 `json:"type"`
}

func CanonicalVote added in v0.8.0

func CanonicalVote(vote *Vote) CanonicalJSONVote

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    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 MakeCommit added in v0.15.0

func MakeCommit(blockID BlockID, height int64, round int,
	voteSet *VoteSet,
	validators []*PrivValidatorFS) (*Commit, error)

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 ConsensusParams added in v0.11.0

type ConsensusParams struct {
	BlockSize      `json:"block_size_params"`
	TxSize         `json:"tx_size_params"`
	BlockGossip    `json:"block_gossip_params"`
	EvidenceParams `json:"evidence_params"`
}

ConsensusParams contains consensus critical parameters that determine the validity of blocks.

func DefaultConsensusParams added in v0.11.0

func DefaultConsensusParams() *ConsensusParams

DefaultConsensusParams returns a default ConsensusParams.

func (*ConsensusParams) Hash added in v0.15.0

func (params *ConsensusParams) Hash() []byte

Hash returns a merkle hash of the parameters to store in the block header

func (ConsensusParams) Update added in v0.15.0

func (params ConsensusParams) Update(params2 *abci.ConsensusParams) ConsensusParams

Update returns a copy of the params with updates from the non-zero fields of p2. NOTE: note: must not modify the original

func (*ConsensusParams) Validate added in v0.11.0

func (params *ConsensusParams) Validate() error

Validate validates the ConsensusParams to ensure all values are within their allowed limits, and returns an error if they are not.

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 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 DefaultSigner

type DefaultSigner struct {
	PrivKey crypto.PrivKey `json:"priv_key"`
}

DefaultSigner implements Signer. It uses a standard, unencrypted crypto.PrivKey.

func NewDefaultSigner

func NewDefaultSigner(priv crypto.PrivKey) *DefaultSigner

NewDefaultSigner returns an instance of DefaultSigner.

func (*DefaultSigner) Sign

func (ds *DefaultSigner) Sign(msg []byte) (crypto.Signature, error)

Sign implements Signer. It signs the byte slice with a private key.

type DuplicateVoteEvidence added in v0.15.0

type DuplicateVoteEvidence struct {
	PubKey crypto.PubKey
	VoteA  *Vote
	VoteB  *Vote
}

DuplicateVoteEvidence contains evidence a validator signed two conflicting votes.

func (*DuplicateVoteEvidence) Address added in v0.15.0

func (dve *DuplicateVoteEvidence) Address() []byte

Address returns the address of the validator.

func (*DuplicateVoteEvidence) Equal added in v0.15.0

func (dve *DuplicateVoteEvidence) Equal(ev Evidence) bool

Equal checks if two pieces of evidence are equal.

func (*DuplicateVoteEvidence) Hash added in v0.15.0

func (dve *DuplicateVoteEvidence) Hash() []byte

Hash returns the hash of the evidence.

func (*DuplicateVoteEvidence) Height added in v0.15.0

func (dve *DuplicateVoteEvidence) Height() int64

Height returns the height this evidence refers to.

func (*DuplicateVoteEvidence) Index added in v0.15.0

func (dve *DuplicateVoteEvidence) Index() int

Index returns the index of the validator.

func (*DuplicateVoteEvidence) String added in v0.15.0

func (dve *DuplicateVoteEvidence) String() string

String returns a string representation of the evidence.

func (*DuplicateVoteEvidence) Verify added in v0.15.0

func (dve *DuplicateVoteEvidence) Verify(chainID string) error

Verify returns an error if the two votes aren't conflicting. To be conflicting, they must be from the same validator, for the same H/R/S, but for different blocks.

type ErrEvidenceInvalid added in v0.15.0

type ErrEvidenceInvalid struct {
	Evidence   Evidence
	ErrorValue error
}

ErrEvidenceInvalid wraps a piece of evidence and the error denoting how or why it is invalid.

func NewEvidenceInvalidErr added in v0.15.0

func NewEvidenceInvalidErr(ev Evidence, err error) *ErrEvidenceInvalid

func (*ErrEvidenceInvalid) Error added in v0.15.0

func (err *ErrEvidenceInvalid) Error() string

Error returns a string representation of the error.

type ErrVoteConflictingVotes added in v0.8.0

type ErrVoteConflictingVotes struct {
	*DuplicateVoteEvidence
}

func NewConflictingVoteError added in v0.15.0

func NewConflictingVoteError(val *Validator, voteA, voteB *Vote) *ErrVoteConflictingVotes

func (*ErrVoteConflictingVotes) Error added in v0.8.0

func (err *ErrVoteConflictingVotes) Error() string

type EventBus added in v0.13.0

type EventBus struct {
	cmn.BaseService
	// contains filtered or unexported fields
}

EventBus is a common bus for all events going through the system. All calls are proxied to underlying pubsub server. All events must be published using EventBus to ensure correct data types.

func NewEventBus added in v0.13.0

func NewEventBus() *EventBus

NewEventBus returns a new event bus.

func NewEventBusWithBufferCapacity added in v0.13.0

func NewEventBusWithBufferCapacity(cap int) *EventBus

NewEventBusWithBufferCapacity returns a new event bus with the given buffer capacity.

func (*EventBus) OnStart added in v0.13.0

func (b *EventBus) OnStart() error

func (*EventBus) OnStop added in v0.13.0

func (b *EventBus) OnStop()

func (*EventBus) Publish added in v0.13.0

func (b *EventBus) Publish(eventType string, eventData TMEventData) error

func (*EventBus) PublishEventCompleteProposal added in v0.13.0

func (b *EventBus) PublishEventCompleteProposal(event EventDataRoundState) error

func (*EventBus) PublishEventLock added in v0.13.0

func (b *EventBus) PublishEventLock(event EventDataRoundState) error

func (*EventBus) PublishEventNewBlock added in v0.13.0

func (b *EventBus) PublishEventNewBlock(event EventDataNewBlock) error

func (*EventBus) PublishEventNewBlockHeader added in v0.13.0

func (b *EventBus) PublishEventNewBlockHeader(event EventDataNewBlockHeader) error

func (*EventBus) PublishEventNewRound added in v0.13.0

func (b *EventBus) PublishEventNewRound(event EventDataRoundState) error

func (*EventBus) PublishEventNewRoundStep added in v0.13.0

func (b *EventBus) PublishEventNewRoundStep(event EventDataRoundState) error

func (*EventBus) PublishEventPolka added in v0.13.0

func (b *EventBus) PublishEventPolka(event EventDataRoundState) error

func (*EventBus) PublishEventProposalHeartbeat added in v0.13.0

func (b *EventBus) PublishEventProposalHeartbeat(event EventDataProposalHeartbeat) error

func (*EventBus) PublishEventRelock added in v0.13.0

func (b *EventBus) PublishEventRelock(event EventDataRoundState) error

func (*EventBus) PublishEventTimeoutPropose added in v0.13.0

func (b *EventBus) PublishEventTimeoutPropose(event EventDataRoundState) error

func (*EventBus) PublishEventTimeoutWait added in v0.13.0

func (b *EventBus) PublishEventTimeoutWait(event EventDataRoundState) error

func (*EventBus) PublishEventTx added in v0.13.0

func (b *EventBus) PublishEventTx(event EventDataTx) error

PublishEventTx publishes tx event with tags from Result. Note it will add predefined tags (EventTypeKey, TxHashKey). Existing tags with the same names will be overwritten.

func (*EventBus) PublishEventUnlock added in v0.13.0

func (b *EventBus) PublishEventUnlock(event EventDataRoundState) error

func (*EventBus) PublishEventVote added in v0.13.0

func (b *EventBus) PublishEventVote(event EventDataVote) error

func (*EventBus) SetLogger added in v0.13.0

func (b *EventBus) SetLogger(l log.Logger)

func (*EventBus) Subscribe added in v0.13.0

func (b *EventBus) Subscribe(ctx context.Context, subscriber string, query tmpubsub.Query, out chan<- interface{}) error

func (*EventBus) Unsubscribe added in v0.13.0

func (b *EventBus) Unsubscribe(ctx context.Context, subscriber string, query tmpubsub.Query) error

func (*EventBus) UnsubscribeAll added in v0.13.0

func (b *EventBus) UnsubscribeAll(ctx context.Context, subscriber string) error

type EventBusSubscriber added in v0.14.0

type EventBusSubscriber interface {
	Subscribe(ctx context.Context, subscriber string, query tmpubsub.Query, out chan<- interface{}) error
	Unsubscribe(ctx context.Context, subscriber string, query tmpubsub.Query) error
	UnsubscribeAll(ctx context.Context, subscriber string) error
}

type EventDataNewBlock

type EventDataNewBlock struct {
	Block *Block `json:"block"`
}

type EventDataNewBlockHeader

type EventDataNewBlockHeader struct {
	Header *Header `json:"header"`
}

light weight event for benchmarking

type EventDataProposalHeartbeat added in v0.10.3

type EventDataProposalHeartbeat struct {
	Heartbeat *Heartbeat
}

type EventDataRoundState

type EventDataRoundState struct {
	Height int64  `json:"height"`
	Round  int    `json:"round"`
	Step   string `json:"step"`

	// private, not exposed to websockets
	RoundState interface{} `json:"-"`
}

NOTE: This goes into the replay WAL

type EventDataTx

type EventDataTx struct {
	TxResult
}

All txs fire EventDataTx

type EventDataVote

type EventDataVote struct {
	Vote *Vote
}

type Evidence added in v0.15.0

type Evidence interface {
	Height() int64               // height of the equivocation
	Address() []byte             // address of the equivocating validator
	Index() int                  // index of the validator in the validator set
	Hash() []byte                // hash of the evidence
	Verify(chainID string) error // verify the evidence
	Equal(Evidence) bool         // check equality of evidence

	String() string
}

Evidence represents any provable malicious activity by a validator

type EvidenceData added in v0.15.0

type EvidenceData struct {
	Evidence EvidenceList `json:"evidence"`
	// contains filtered or unexported fields
}

EvidenceData contains any evidence of malicious wrong-doing by validators

func (*EvidenceData) Hash added in v0.15.0

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

Hash returns the hash of the data.

func (*EvidenceData) StringIndented added in v0.15.0

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

StringIndented returns a string representation of the evidence.

type EvidenceList added in v0.15.0

type EvidenceList []Evidence

EvidenceList is a list of Evidence. Evidences is not a word.

func (EvidenceList) Has added in v0.15.0

func (evl EvidenceList) Has(evidence Evidence) bool

Has returns true if the evidence is in the EvidenceList.

func (EvidenceList) Hash added in v0.15.0

func (evl EvidenceList) Hash() []byte

Hash returns the simple merkle root hash of the EvidenceList.

func (EvidenceList) String added in v0.15.0

func (evl EvidenceList) String() string

type EvidenceParams added in v0.15.0

type EvidenceParams struct {
	MaxAge int64 `json:"max_age"` // only accept new evidence more recent than this
}

EvidenceParams determine how we handle evidence of malfeasance

func DefaultEvidenceParams added in v0.15.0

func DefaultEvidenceParams() EvidenceParams

DefaultEvidence Params returns a default EvidenceParams.

type EvidencePool added in v0.15.0

type EvidencePool interface {
	PendingEvidence() []Evidence
	AddEvidence(Evidence) error
	Update(*Block)
}

EvidencePool defines the EvidencePool interface used by the ConsensusState. UNSTABLE

type GenesisDoc

type GenesisDoc struct {
	GenesisTime     time.Time          `json:"genesis_time"`
	ChainID         string             `json:"chain_id"`
	ConsensusParams *ConsensusParams   `json:"consensus_params,omitempty"`
	Validators      []GenesisValidator `json:"validators"`
	AppHash         cmn.HexBytes       `json:"app_hash"`
	AppOptions      interface{}        `json:"app_options,omitempty"`
}

GenesisDoc defines the initial conditions for a tendermint blockchain, in particular its validator set.

func GenesisDocFromFile added in v0.10.1

func GenesisDocFromFile(genDocFile string) (*GenesisDoc, error)

GenesisDocFromFile reads JSON data from a file and unmarshalls it into a GenesisDoc.

func GenesisDocFromJSON

func GenesisDocFromJSON(jsonBlob []byte) (*GenesisDoc, error)

GenesisDocFromJSON unmarshalls JSON data into a GenesisDoc.

func (*GenesisDoc) SaveAs

func (genDoc *GenesisDoc) SaveAs(file string) error

SaveAs is a utility method for saving GenensisDoc as a JSON file.

func (*GenesisDoc) ValidateAndComplete added in v0.11.0

func (genDoc *GenesisDoc) ValidateAndComplete() error

ValidateAndComplete checks that all necessary fields are present and fills in defaults for optional fields left empty

func (*GenesisDoc) ValidatorHash added in v0.10.1

func (genDoc *GenesisDoc) ValidatorHash() []byte

ValidatorHash returns the hash of the validator set contained in the GenesisDoc

type GenesisValidator

type GenesisValidator struct {
	PubKey crypto.PubKey `json:"pub_key"`
	Power  int64         `json:"power"`
	Name   string        `json:"name"`
}

GenesisValidator is an initial validator.

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 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 Tendermint 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 Heartbeat added in v0.10.3

type Heartbeat struct {
	ValidatorAddress Address          `json:"validator_address"`
	ValidatorIndex   int              `json:"validator_index"`
	Height           int64            `json:"height"`
	Round            int              `json:"round"`
	Sequence         int              `json:"sequence"`
	Signature        crypto.Signature `json:"signature"`
}

Heartbeat is a simple vote-like structure so validators can alert others that they are alive and waiting for transactions. Note: We aren't adding ",omitempty" to Heartbeat's json field tags because we always want the JSON representation to be in its canonical form.

func (*Heartbeat) Copy added in v0.10.3

func (heartbeat *Heartbeat) Copy() *Heartbeat

Copy makes a copy of the Heartbeat.

func (*Heartbeat) String added in v0.10.3

func (heartbeat *Heartbeat) String() string

String returns a string representation of the Heartbeat.

func (*Heartbeat) WriteSignBytes added in v0.10.3

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

WriteSignBytes writes the Heartbeat for signing. It panics if the Heartbeat is nil.

type Mempool added in v0.9.0

type Mempool interface {
	Lock()
	Unlock()

	Size() int
	CheckTx(Tx, func(*abci.Response)) error
	Reap(int) Txs
	Update(height int64, txs Txs) error
	Flush()
	FlushAppConn() error

	TxsAvailable() <-chan int64
	EnableTxsAvailable()
}

Mempool defines the mempool interface as used by the ConsensusState. Updates to the mempool need to be synchronized with committing a block so apps can reset their transient state on Commit UNSTABLE

type MockBadEvidence added in v0.15.0

type MockBadEvidence struct {
	MockGoodEvidence
}

UNSTABLE

func (MockBadEvidence) Equal added in v0.15.0

func (e MockBadEvidence) Equal(ev Evidence) bool

func (MockBadEvidence) String added in v0.15.0

func (e MockBadEvidence) String() string

func (MockBadEvidence) Verify added in v0.15.0

func (e MockBadEvidence) Verify(chainID string) error

type MockEvidencePool added in v0.15.0

type MockEvidencePool struct {
}

MockMempool is an empty implementation of a Mempool, useful for testing. UNSTABLE

func (MockEvidencePool) AddEvidence added in v0.15.0

func (m MockEvidencePool) AddEvidence(Evidence) error

func (MockEvidencePool) PendingEvidence added in v0.15.0

func (m MockEvidencePool) PendingEvidence() []Evidence

func (MockEvidencePool) Update added in v0.15.0

func (m MockEvidencePool) Update(*Block)

type MockGoodEvidence added in v0.15.0

type MockGoodEvidence struct {
	Height_  int64
	Address_ []byte
	Index_   int
}

UNSTABLE

func NewMockGoodEvidence added in v0.15.0

func NewMockGoodEvidence(height int64, index int, address []byte) MockGoodEvidence

UNSTABLE

func (MockGoodEvidence) Address added in v0.15.0

func (e MockGoodEvidence) Address() []byte

func (MockGoodEvidence) Equal added in v0.15.0

func (e MockGoodEvidence) Equal(ev Evidence) bool

func (MockGoodEvidence) Hash added in v0.15.0

func (e MockGoodEvidence) Hash() []byte

func (MockGoodEvidence) Height added in v0.15.0

func (e MockGoodEvidence) Height() int64

func (MockGoodEvidence) Index added in v0.15.0

func (e MockGoodEvidence) Index() int

func (MockGoodEvidence) String added in v0.15.0

func (e MockGoodEvidence) String() string

func (MockGoodEvidence) Verify added in v0.15.0

func (e MockGoodEvidence) Verify(chainID string) error

type MockMempool added in v0.9.0

type MockMempool struct {
}

MockMempool is an empty implementation of a Mempool, useful for testing. UNSTABLE

func (MockMempool) CheckTx added in v0.9.0

func (m MockMempool) CheckTx(tx Tx, cb func(*abci.Response)) error

func (MockMempool) EnableTxsAvailable added in v0.10.3

func (m MockMempool) EnableTxsAvailable()

func (MockMempool) Flush added in v0.9.0

func (m MockMempool) Flush()

func (MockMempool) FlushAppConn added in v0.16.0

func (m MockMempool) FlushAppConn() error

func (MockMempool) Lock added in v0.9.0

func (m MockMempool) Lock()

func (MockMempool) Reap added in v0.9.0

func (m MockMempool) Reap(n int) Txs

func (MockMempool) Size added in v0.9.0

func (m MockMempool) Size() int

func (MockMempool) TxsAvailable added in v0.10.3

func (m MockMempool) TxsAvailable() <-chan int64

func (MockMempool) Unlock added in v0.9.0

func (m MockMempool) Unlock()

func (MockMempool) Update added in v0.9.0

func (m MockMempool) Update(height int64, txs Txs) error

type NopEventBus added in v0.13.0

type NopEventBus struct{}

func (NopEventBus) PublishEventCompleteProposal added in v0.13.0

func (NopEventBus) PublishEventCompleteProposal(rs EventDataRoundState) error

func (NopEventBus) PublishEventLock added in v0.13.0

func (NopEventBus) PublishEventLock(rs EventDataRoundState) error

func (NopEventBus) PublishEventNewBlock added in v0.13.0

func (NopEventBus) PublishEventNewBlock(block EventDataNewBlock) error

func (NopEventBus) PublishEventNewBlockHeader added in v0.13.0

func (NopEventBus) PublishEventNewBlockHeader(header EventDataNewBlockHeader) error

func (NopEventBus) PublishEventNewRound added in v0.13.0

func (NopEventBus) PublishEventNewRound(rs EventDataRoundState) error

func (NopEventBus) PublishEventNewRoundStep added in v0.13.0

func (NopEventBus) PublishEventNewRoundStep(rs EventDataRoundState) error

func (NopEventBus) PublishEventPolka added in v0.13.0

func (NopEventBus) PublishEventPolka(rs EventDataRoundState) error

func (NopEventBus) PublishEventRelock added in v0.13.0

func (NopEventBus) PublishEventRelock(rs EventDataRoundState) error

func (NopEventBus) PublishEventTimeoutPropose added in v0.13.0

func (NopEventBus) PublishEventTimeoutPropose(rs EventDataRoundState) error

func (NopEventBus) PublishEventTimeoutWait added in v0.13.0

func (NopEventBus) PublishEventTimeoutWait(rs EventDataRoundState) error

func (NopEventBus) PublishEventTx added in v0.13.0

func (NopEventBus) PublishEventTx(tx EventDataTx) error

func (NopEventBus) PublishEventUnlock added in v0.13.0

func (NopEventBus) PublishEventUnlock(rs EventDataRoundState) error

func (NopEventBus) PublishEventVote added in v0.13.0

func (NopEventBus) PublishEventVote(vote EventDataVote) error

func (NopEventBus) Subscribe added in v0.13.0

func (NopEventBus) Subscribe(ctx context.Context, subscriber string, query tmpubsub.Query, out chan<- interface{}) error

func (NopEventBus) Unsubscribe added in v0.13.0

func (NopEventBus) Unsubscribe(ctx context.Context, subscriber string, query tmpubsub.Query) error

func (NopEventBus) UnsubscribeAll added in v0.13.0

func (NopEventBus) UnsubscribeAll(ctx context.Context, subscriber string) error

type Part

type Part struct {
	Index int                `json:"index"`
	Bytes cmn.HexBytes       `json:"bytes"`
	Proof merkle.SimpleProof `json:"proof"`
	// contains filtered or unexported fields
}

func (*Part) Hash

func (part *Part) Hash() []byte

func (*Part) String

func (part *Part) String() string

func (*Part) StringIndented

func (part *Part) StringIndented(indent string) string

type PartSet

type PartSet struct {
	// contains filtered or unexported fields
}

func NewPartSetFromData

func NewPartSetFromData(data []byte, partSize int) *PartSet

Returns an immutable, full PartSet from the data bytes. The data bytes are split into "partSize" chunks, and merkle tree computed.

func NewPartSetFromHeader

func NewPartSetFromHeader(header PartSetHeader) *PartSet

Returns an empty PartSet ready to be populated.

func (*PartSet) AddPart

func (ps *PartSet) AddPart(part *Part, verify bool) (bool, error)

func (*PartSet) BitArray

func (ps *PartSet) BitArray() *cmn.BitArray

func (*PartSet) Count

func (ps *PartSet) Count() int

func (*PartSet) GetPart

func (ps *PartSet) GetPart(index int) *Part

func (*PartSet) GetReader

func (ps *PartSet) GetReader() io.Reader

func (*PartSet) HasHeader

func (ps *PartSet) HasHeader(header PartSetHeader) bool

func (*PartSet) Hash

func (ps *PartSet) Hash() []byte

func (*PartSet) HashesTo

func (ps *PartSet) HashesTo(hash []byte) bool

func (*PartSet) Header

func (ps *PartSet) Header() PartSetHeader

func (*PartSet) IsComplete

func (ps *PartSet) IsComplete() bool

func (*PartSet) StringShort

func (ps *PartSet) StringShort() string

func (*PartSet) Total

func (ps *PartSet) Total() int

type PartSetHeader

type PartSetHeader struct {
	Total int          `json:"total"`
	Hash  cmn.HexBytes `json:"hash"`
}

func (PartSetHeader) Equals

func (psh PartSetHeader) Equals(other PartSetHeader) bool

func (PartSetHeader) IsZero

func (psh PartSetHeader) IsZero() bool

func (PartSetHeader) String

func (psh PartSetHeader) String() string

func (PartSetHeader) WriteSignBytes

func (psh PartSetHeader) WriteSignBytes(w io.Writer, n *int, err *error)

type PartSetReader

type PartSetReader struct {
	// contains filtered or unexported fields
}

func NewPartSetReader

func NewPartSetReader(parts []*Part) *PartSetReader

func (*PartSetReader) Read

func (psr *PartSetReader) Read(p []byte) (n int, err error)

type PrivValidator

type PrivValidator interface {
	GetAddress() Address // redundant since .PubKey().Address()
	GetPubKey() crypto.PubKey

	SignVote(chainID string, vote *Vote) error
	SignProposal(chainID string, proposal *Proposal) error
	SignHeartbeat(chainID string, heartbeat *Heartbeat) error
}

PrivValidator defines the functionality of a local Tendermint validator that signs votes, proposals, and heartbeats, and never double signs.

type PrivValidatorFS added in v0.11.0

type PrivValidatorFS struct {
	Address       Address          `json:"address"`
	PubKey        crypto.PubKey    `json:"pub_key"`
	LastHeight    int64            `json:"last_height"`
	LastRound     int              `json:"last_round"`
	LastStep      int8             `json:"last_step"`
	LastSignature crypto.Signature `json:"last_signature,omitempty"` // so we dont lose signatures
	LastSignBytes cmn.HexBytes     `json:"last_signbytes,omitempty"` // so we dont lose signatures

	// PrivKey should be empty if a Signer other than the default is being used.
	PrivKey crypto.PrivKey `json:"priv_key"`
	Signer  `json:"-"`
	// contains filtered or unexported fields
}

PrivValidatorFS implements PrivValidator using data persisted to disk to prevent double signing. The Signer itself can be mutated to use something besides the default, for instance a hardware signer.

func GenPrivValidatorFS added in v0.11.0

func GenPrivValidatorFS(filePath string) *PrivValidatorFS

GenPrivValidatorFS generates a new validator with randomly generated private key and sets the filePath, but does not call Save().

func LoadOrGenPrivValidatorFS added in v0.11.0

func LoadOrGenPrivValidatorFS(filePath string) *PrivValidatorFS

LoadOrGenPrivValidatorFS loads a PrivValidatorFS from the given filePath or else generates a new one and saves it to the filePath.

func LoadPrivValidatorFS added in v0.11.0

func LoadPrivValidatorFS(filePath string) *PrivValidatorFS

LoadPrivValidatorFS loads a PrivValidatorFS from the filePath.

func LoadPrivValidatorFSWithSigner added in v0.11.0

func LoadPrivValidatorFSWithSigner(filePath string, signerFunc func(PrivValidator) Signer) *PrivValidatorFS

LoadPrivValidatorWithSigner loads a PrivValidatorFS with a custom signer object. The PrivValidatorFS handles double signing prevention by persisting data to the filePath, while the Signer handles the signing. If the filePath does not exist, the PrivValidatorFS must be created manually and saved.

func (*PrivValidatorFS) GetAddress added in v0.11.0

func (pv *PrivValidatorFS) GetAddress() Address

GetAddress returns the address of the validator. Implements PrivValidator.

func (*PrivValidatorFS) GetPubKey added in v0.11.0

func (pv *PrivValidatorFS) GetPubKey() crypto.PubKey

GetPubKey returns the public key of the validator. Implements PrivValidator.

func (*PrivValidatorFS) Reset added in v0.11.0

func (privVal *PrivValidatorFS) Reset()

Reset resets all fields in the PrivValidatorFS. NOTE: Unsafe!

func (*PrivValidatorFS) Save added in v0.11.0

func (privVal *PrivValidatorFS) Save()

Save persists the PrivValidatorFS to disk.

func (*PrivValidatorFS) SignHeartbeat added in v0.11.0

func (privVal *PrivValidatorFS) SignHeartbeat(chainID string, heartbeat *Heartbeat) error

SignHeartbeat signs a canonical representation of the heartbeat, along with the chainID. Implements PrivValidator.

func (*PrivValidatorFS) SignProposal added in v0.11.0

func (privVal *PrivValidatorFS) SignProposal(chainID string, proposal *Proposal) error

SignProposal signs a canonical representation of the proposal, along with the chainID. Implements PrivValidator.

func (*PrivValidatorFS) SignVote added in v0.11.0

func (privVal *PrivValidatorFS) SignVote(chainID string, vote *Vote) error

SignVote signs a canonical representation of the vote, along with the chainID. Implements PrivValidator.

func (*PrivValidatorFS) String added in v0.11.0

func (privVal *PrivValidatorFS) String() string

String returns a string representation of the PrivValidatorFS.

type PrivValidatorsByAddress

type PrivValidatorsByAddress []*PrivValidatorFS

func (PrivValidatorsByAddress) Len

func (pvs PrivValidatorsByAddress) Len() int

func (PrivValidatorsByAddress) Less

func (pvs PrivValidatorsByAddress) Less(i, j int) bool

func (PrivValidatorsByAddress) Swap

func (pvs PrivValidatorsByAddress) Swap(i, j int)

type Proposal

type Proposal struct {
	Height           int64            `json:"height"`
	Round            int              `json:"round"`
	Timestamp        time.Time        `json:"timestamp"`
	BlockPartsHeader PartSetHeader    `json:"block_parts_header"`
	POLRound         int              `json:"pol_round"`    // -1 if null.
	POLBlockID       BlockID          `json:"pol_block_id"` // zero if null.
	Signature        crypto.Signature `json:"signature"`
}

Proposal defines a block proposal for the consensus. It refers to the block only by its PartSetHeader. It must be signed by the correct proposer for the given Height/Round to be considered valid. It may depend on votes from a previous round, a so-called Proof-of-Lock (POL) round, as noted in the POLRound and POLBlockID.

func NewProposal

func NewProposal(height int64, round int, blockPartsHeader PartSetHeader, polRound int, polBlockID BlockID) *Proposal

NewProposal returns a new Proposal. If there is no POLRound, polRound should be -1.

func (*Proposal) String

func (p *Proposal) String() string

String returns a string representation of the Proposal.

func (*Proposal) WriteSignBytes

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

WriteSignBytes writes the Proposal bytes for signing

type Signable

type Signable interface {
	WriteSignBytes(chainID string, w io.Writer, n *int, err *error)
}

Signable is an interface for all signable things. It typically removes signatures before serializing.

type SignedHeader added in v0.12.0

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

SignedHeader is a header along with the commits that prove it

type Signer

type Signer interface {
	Sign(msg []byte) (crypto.Signature, error)
}

Signer is an interface that defines how to sign messages. It is the caller's duty to verify the msg before calling Sign, eg. to avoid double signing. Currently, the only callers are SignVote, SignProposal, and SignHeartbeat.

type TMEventData

type TMEventData struct {
	TMEventDataInner `json:"unwrap"`
}

func (TMEventData) Empty added in v0.10.0

func (tmr TMEventData) Empty() bool

func (TMEventData) MarshalJSON added in v0.10.0

func (tmr TMEventData) MarshalJSON() ([]byte, error)

func (*TMEventData) UnmarshalJSON added in v0.10.0

func (tmr *TMEventData) UnmarshalJSON(data []byte) (err error)

func (TMEventData) Unwrap added in v0.10.0

func (tmr TMEventData) Unwrap() TMEventDataInner

type TMEventDataInner added in v0.10.0

type TMEventDataInner interface {
}

implements events.EventData

type Tx

type Tx []byte

Tx is an arbitrary byte array. NOTE: Tx has no types at this level, so when go-wire encoded it's just length-prefixed. Alternatively, it may make sense to add types here and let []byte be type 0x1 so we can have versioned txs if need be in the future.

func (Tx) Hash

func (tx Tx) Hash() []byte

Hash computes the RIPEMD160 hash of the go-wire encoded transaction.

func (Tx) String added in v0.10.0

func (tx Tx) String() string

String returns the hex-encoded transaction as a string.

type TxEventBuffer added in v0.13.0

type TxEventBuffer struct {
	// contains filtered or unexported fields
}

TxEventBuffer is a buffer of events, which uses a slice to temporarily store events.

func NewTxEventBuffer added in v0.13.0

func NewTxEventBuffer(next TxEventPublisher, capacity int) *TxEventBuffer

NewTxEventBuffer accepts a TxEventPublisher and returns a new buffer with the given capacity.

func (*TxEventBuffer) Flush added in v0.13.0

func (b *TxEventBuffer) Flush() error

Flush publishes events by running next.PublishWithTags on all cached events. Blocks. Clears cached events.

func (TxEventBuffer) Len added in v0.13.0

func (b TxEventBuffer) Len() int

Len returns the number of events cached.

func (*TxEventBuffer) PublishEventTx added in v0.13.0

func (b *TxEventBuffer) PublishEventTx(e EventDataTx) error

PublishEventTx buffers an event to be fired upon finality.

type TxEventPublisher added in v0.13.0

type TxEventPublisher interface {
	PublishEventTx(EventDataTx) error
}

type TxProof added in v0.9.1

type TxProof struct {
	Index, Total int
	RootHash     cmn.HexBytes
	Data         Tx
	Proof        merkle.SimpleProof
}

TxProof represents a Merkle proof of the presence of a transaction in the Merkle tree.

func (TxProof) LeafHash added in v0.9.1

func (tp TxProof) LeafHash() []byte

LeadHash returns the hash of the transaction this proof refers to.

func (TxProof) Validate added in v0.9.1

func (tp TxProof) Validate(dataHash []byte) error

Validate verifies the proof. It returns nil if the RootHash matches the dataHash argument, and if the proof is internally consistent. Otherwise, it returns a sensible error.

type TxResult added in v0.9.1

type TxResult struct {
	Height int64                  `json:"height"`
	Index  uint32                 `json:"index"`
	Tx     Tx                     `json:"tx"`
	Result abci.ResponseDeliverTx `json:"result"`
}

TxResult contains results of executing the transaction.

One usage is indexing transaction results.

type TxSize added in v0.15.0

type TxSize struct {
	MaxBytes int   `json:"max_bytes"`
	MaxGas   int64 `json:"max_gas"`
}

TxSize contain limits on the tx size.

func DefaultTxSize added in v0.15.0

func DefaultTxSize() TxSize

DefaultTxSize returns a default TxSize.

type Txs

type Txs []Tx

Txs is a slice of Tx.

func (Txs) Hash

func (txs Txs) Hash() []byte

Hash returns the simple Merkle root hash of the transactions.

func (Txs) Index added in v0.9.1

func (txs Txs) Index(tx Tx) int

Index returns the index of this transaction in the list, or -1 if not found

func (Txs) IndexByHash added in v0.9.1

func (txs Txs) IndexByHash(hash []byte) int

IndexByHash returns the index of this transaction hash in the list, or -1 if not found

func (Txs) Proof added in v0.9.1

func (txs Txs) Proof(i int) TxProof

Proof returns a simple merkle proof for this node.

Panics if i < 0 or i >= len(txs)

TODO: optimize this!

type Validator

type Validator struct {
	Address     Address       `json:"address"`
	PubKey      crypto.PubKey `json:"pub_key"`
	VotingPower int64         `json:"voting_power"`

	Accum int64 `json:"accum"`
}

Volatile state for each Validator NOTE: The Accum is not included in Validator.Hash(); make sure to update that method if changes are made here

func NewValidator added in v0.8.0

func NewValidator(pubKey crypto.PubKey, votingPower int64) *Validator

func (*Validator) CompareAccum

func (v *Validator) CompareAccum(other *Validator) *Validator

Returns the one with higher Accum.

func (*Validator) Copy

func (v *Validator) Copy() *Validator

Creates a new copy of the validator so we can mutate accum. Panics if the validator is nil.

func (*Validator) Hash

func (v *Validator) Hash() []byte

Hash computes the unique ID of a validator with a given voting power. It excludes the Accum value, which changes with every round.

func (*Validator) String

func (v *Validator) String() string

type ValidatorSet

type ValidatorSet struct {
	// NOTE: persisted via reflect, must be exported.
	Validators []*Validator `json:"validators"`
	Proposer   *Validator   `json:"proposer"`
	// contains filtered or unexported fields
}

ValidatorSet represent a set of *Validator at a given height. The validators can be fetched by address or index. The index is in order of .Address, so the indices are fixed for all rounds of a given blockchain height. On the other hand, the .AccumPower of each validator and the designated .GetProposer() of a set changes every round, upon calling .IncrementAccum(). NOTE: Not goroutine-safe. NOTE: All get/set to validators should copy the value for safety.

func NewValidatorSet

func NewValidatorSet(vals []*Validator) *ValidatorSet

func (*ValidatorSet) Add

func (valSet *ValidatorSet) Add(val *Validator) (added bool)

func (*ValidatorSet) Copy

func (valSet *ValidatorSet) Copy() *ValidatorSet

func (*ValidatorSet) GetByAddress

func (valSet *ValidatorSet) GetByAddress(address []byte) (index int, val *Validator)

func (*ValidatorSet) GetByIndex

func (valSet *ValidatorSet) GetByIndex(index int) (address []byte, val *Validator)

GetByIndex returns the validator by index. It returns nil values if index < 0 or index >= len(ValidatorSet.Validators)

func (*ValidatorSet) GetProposer added in v0.9.0

func (valSet *ValidatorSet) GetProposer() (proposer *Validator)

func (*ValidatorSet) HasAddress

func (valSet *ValidatorSet) HasAddress(address []byte) bool

func (*ValidatorSet) Hash

func (valSet *ValidatorSet) Hash() []byte

func (*ValidatorSet) IncrementAccum

func (valSet *ValidatorSet) IncrementAccum(times int)

incrementAccum and update the proposer

func (*ValidatorSet) Iterate

func (valSet *ValidatorSet) Iterate(fn func(index int, val *Validator) bool)

func (*ValidatorSet) Remove

func (valSet *ValidatorSet) Remove(address []byte) (val *Validator, removed bool)

func (*ValidatorSet) Size

func (valSet *ValidatorSet) Size() int

func (*ValidatorSet) String

func (valSet *ValidatorSet) String() string

func (*ValidatorSet) StringIndented

func (valSet *ValidatorSet) StringIndented(indent string) string

func (*ValidatorSet) TotalVotingPower

func (valSet *ValidatorSet) TotalVotingPower() int64

func (*ValidatorSet) Update

func (valSet *ValidatorSet) Update(val *Validator) (updated bool)

func (*ValidatorSet) VerifyCommit

func (valSet *ValidatorSet) VerifyCommit(chainID string, blockID BlockID, height int64, commit *Commit) error

Verify that +2/3 of the set had signed the given signBytes

func (*ValidatorSet) VerifyCommitAny added in v0.9.0

func (valSet *ValidatorSet) VerifyCommitAny(newSet *ValidatorSet, chainID string,
	blockID BlockID, height int64, commit *Commit) error

VerifyCommitAny will check to see if the set would be valid with a different validator set.

valSet is the validator set that we know * over 2/3 of the power in old signed this block

newSet is the validator set that signed this block

  • only votes from old are sufficient for 2/3 majority in the new set as well

That means that: * 10% of the valset can't just declare themselves kings * If the validator set is 3x old size, we need more proof to trust

type ValidatorsByAddress

type ValidatorsByAddress []*Validator

func (ValidatorsByAddress) Len

func (vs ValidatorsByAddress) Len() int

func (ValidatorsByAddress) Less

func (vs ValidatorsByAddress) Less(i, j int) bool

func (ValidatorsByAddress) Swap

func (vs ValidatorsByAddress) Swap(i, j int)

type Vote

type Vote struct {
	ValidatorAddress Address          `json:"validator_address"`
	ValidatorIndex   int              `json:"validator_index"`
	Height           int64            `json:"height"`
	Round            int              `json:"round"`
	Timestamp        time.Time        `json:"timestamp"`
	Type             byte             `json:"type"`
	BlockID          BlockID          `json:"block_id"` // zero if vote is nil.
	Signature        crypto.Signature `json:"signature"`
}

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 added in v0.15.0

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

func (*Vote) WriteSignBytes

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

type VoteSet

type VoteSet struct {
	// contains filtered or unexported fields
}

VoteSet helps collect signatures from validators at each height+round for a predefined vote type.

We need VoteSet to be able to keep track of conflicting votes when validators double-sign. Yet, we can't keep track of *all* the votes seen, as that could be a DoS attack vector.

There are two storage areas for votes. 1. voteSet.votes 2. voteSet.votesByBlock

`.votes` is the "canonical" list of votes. It always has at least one vote, if a vote from a validator had been seen at all. Usually it keeps track of the first vote seen, but when a 2/3 majority is found, votes for that get priority and are copied over from `.votesByBlock`.

`.votesByBlock` keeps track of a list of votes for a particular block. There are two ways a &blockVotes{} gets created in `.votesByBlock`. 1. the first vote seen by a validator was for the particular block. 2. a peer claims to have seen 2/3 majority for the particular block.

Since the first vote from a validator will always get added in `.votesByBlock` , all votes in `.votes` will have a corresponding entry in `.votesByBlock`.

When a &blockVotes{} in `.votesByBlock` reaches a 2/3 majority quorum, its votes are copied into `.votes`.

All this is memory bounded because conflicting votes only get added if a peer told us to track that block, each peer only gets to tell us 1 such block, and, there's only a limited number of peers.

NOTE: Assumes that the sum total of voting power does not exceed MaxUInt64.

func NewVoteSet

func NewVoteSet(chainID string, height int64, round int, type_ byte, valSet *ValidatorSet) *VoteSet

Constructs a new VoteSet struct used to accumulate votes for given height/round.

func (*VoteSet) AddVote added in v0.8.0

func (voteSet *VoteSet) AddVote(vote *Vote) (added bool, err error)

Returns added=true if vote is valid and new. Otherwise returns err=ErrVote[

UnexpectedStep | InvalidIndex | InvalidAddress |
InvalidSignature | InvalidBlockHash | ConflictingVotes ]

Duplicate votes return added=false, err=nil. Conflicting votes return added=*, err=ErrVoteConflictingVotes. NOTE: vote should not be mutated after adding. NOTE: VoteSet must not be nil NOTE: Vote must not be nil

func (*VoteSet) BitArray

func (voteSet *VoteSet) BitArray() *cmn.BitArray

func (*VoteSet) BitArrayByBlockID added in v0.8.0

func (voteSet *VoteSet) BitArrayByBlockID(blockID BlockID) *cmn.BitArray

func (*VoteSet) ChainID

func (voteSet *VoteSet) ChainID() string

func (*VoteSet) GetByAddress

func (voteSet *VoteSet) GetByAddress(address []byte) *Vote

func (*VoteSet) GetByIndex

func (voteSet *VoteSet) GetByIndex(valIndex int) *Vote

NOTE: if validator has conflicting votes, returns "canonical" vote

func (*VoteSet) HasAll added in v0.8.0

func (voteSet *VoteSet) HasAll() bool

func (*VoteSet) HasTwoThirdsAny

func (voteSet *VoteSet) HasTwoThirdsAny() bool

func (*VoteSet) HasTwoThirdsMajority

func (voteSet *VoteSet) HasTwoThirdsMajority() bool

func (*VoteSet) Height

func (voteSet *VoteSet) Height() int64

func (*VoteSet) IsCommit

func (voteSet *VoteSet) IsCommit() bool

func (*VoteSet) MakeCommit

func (voteSet *VoteSet) MakeCommit() *Commit

func (*VoteSet) Round

func (voteSet *VoteSet) Round() int

func (*VoteSet) SetPeerMaj23 added in v0.8.0

func (voteSet *VoteSet) SetPeerMaj23(peerID p2p.ID, blockID BlockID) error

If a peer claims that it has 2/3 majority for given blockKey, call this. NOTE: if there are too many peers, or too much peer churn, this can cause memory issues. TODO: implement ability to remove peers too NOTE: VoteSet must not be nil

func (*VoteSet) Size

func (voteSet *VoteSet) Size() int

func (*VoteSet) String

func (voteSet *VoteSet) String() string

func (*VoteSet) StringIndented

func (voteSet *VoteSet) StringIndented(indent string) string

func (*VoteSet) StringShort

func (voteSet *VoteSet) StringShort() string

func (*VoteSet) TwoThirdsMajority

func (voteSet *VoteSet) TwoThirdsMajority() (blockID BlockID, ok bool)

Returns either a blockhash (or nil) that received +2/3 majority. If there exists no such majority, returns (nil, PartSetHeader{}, false).

func (*VoteSet) Type

func (voteSet *VoteSet) Type() byte

type VoteSetReader

type VoteSetReader interface {
	Height() int64
	Round() int
	Type() byte
	Size() int
	BitArray() *cmn.BitArray
	GetByIndex(int) *Vote
	IsCommit() bool
}

Common interface between *consensus.VoteSet and types.Commit

Jump to

Keyboard shortcuts

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