types

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const HashLen = types.HashLen

Variables

View Source
var (
	ErrNotFound        = types.ErrNotFound
	ErrTxNotFound      = types.ErrTxNotFound
	ErrTxAlreadyExists = types.ErrTxAlreadyExists
)

The following errors must be aliases for errors.Is to work properly.

View Source
var (
	HashBytes          = types.HashBytes
	ErrBlkNotFound     = errors.New("block not available")
	ErrStillProcessing = errors.New("block still being executed")
	ErrNoResponse      = errors.New("stream closed without response")
	ErrPeersNotFound   = errors.New("no peers available")
)

Functions

This section is empty.

Types

type AckRes

type AckRes struct {
	ACK bool
	// only required if ACK is false
	NackStatus *NackStatus
	Height     int64
	BlkHash    Hash
	// only required if ACK is true
	AppHash *Hash
	// optional, only required if the nack status is NackStatusOutOfSync
	OutOfSyncProof *OutOfSyncProof

	// Signature
	Signature *types.Signature
}

func (AckRes) MarshalBinary

func (ar AckRes) MarshalBinary() ([]byte, error)

func (*AckRes) OutOfSync

func (ar *AckRes) OutOfSync() (*OutOfSyncProof, bool)

func (AckRes) String

func (ar AckRes) String() string

func (*AckRes) UnmarshalBinary

func (ar *AckRes) UnmarshalBinary(data []byte) error

func (*AckRes) Valid

func (ar *AckRes) Valid() error

type BlockGetter

type BlockGetter interface {
	Have(Hash) bool
	Get(Hash) (*types.Block, *types.CommitInfo, error)
	GetByHeight(int64) (Hash, *types.Block, *types.CommitInfo, error) // note: we can impl GetBlockHeader easily too
}

type BlockResultsStorer

type BlockResultsStorer interface {
	StoreResults(hash Hash, results []types.TxResult) error
	Results(hash Hash) ([]types.TxResult, error)
	Result(hash Hash, idx uint32) (*types.TxResult, error)
}

type BlockStore

type BlockStore interface {
	BlockGetter
	RawGetter
	BlockStorer
	TxGetter
	BlockResultsStorer

	Best() (height int64, blkHash, appHash Hash, stamp time.Time)

	PreFetch(Hash) (bool, func()) // should be app level instead (TODO: remove)

	Close() error
}

type BlockStorer

type BlockStorer interface {
	Store(*types.Block, *types.CommitInfo) error
}

type ConsensusReset

type ConsensusReset struct {
	ToHeight int64
	TxIDs    []Hash
}

func (ConsensusReset) Bytes

func (cr ConsensusReset) Bytes() []byte

func (ConsensusReset) MarshalBinary

func (cr ConsensusReset) MarshalBinary() ([]byte, error)

func (ConsensusReset) String

func (cr ConsensusReset) String() string

func (*ConsensusReset) UnmarshalBinary

func (cr *ConsensusReset) UnmarshalBinary(data []byte) error

type DiscoveryRequest

type DiscoveryRequest struct{}

func (DiscoveryRequest) String

func (dr DiscoveryRequest) String() string

type DiscoveryResponse

type DiscoveryResponse struct {
	BestHeight int64
}

func (DiscoveryResponse) Bytes

func (dr DiscoveryResponse) Bytes() []byte

func (DiscoveryResponse) MarshalBinary

func (dr DiscoveryResponse) MarshalBinary() ([]byte, error)

func (DiscoveryResponse) String

func (dr DiscoveryResponse) String() string

func (*DiscoveryResponse) UnmarshalBinary

func (dr *DiscoveryResponse) UnmarshalBinary(data []byte) error

type Hash

type Hash = types.Hash

type HexBytes

type HexBytes = types.HexBytes

type MemPool

type MemPool interface {
	Size() (count, bts int)
	Get(Hash) *Tx
	Remove(Hash)
	Store(*Tx) (found, rejected bool)
	PeekN(maxNumTxns, maxTotalTxBytes int) []*Tx
	PreFetch(txid Hash) (ok bool, done func()) // should be app level instead
}

type NackStatus

type NackStatus string

NackStatus desribes the reason for a nack response.

const (
	// If the block validation fails either due to invalid header info such as
	// AppHash or the ValidatorHash or Invalid Merkle hash etc.
	NackStatusInvalidBlock NackStatus = "invalid_block"
	// If leader proposes a new block for an already committed height, indicating
	// that the leader may potentially be out of sync with the rest of the network.
	// This requires the validator to prove to the leader that the block is indeed
	// committed by sending the block header with the leaders signature in the Vote.
	NackStatusOutOfSync NackStatus = "out_of_sync"
	// other unknown miscellaneous reasons for nack
	NackStatusUnknown NackStatus = "unknown"
)

func (NackStatus) String

func (ns NackStatus) String() string

type OutOfSyncProof

type OutOfSyncProof struct {
	// Header is the block header corresponding to the best height the node is at.
	Header *types.BlockHeader
	// Signature is the signature of the block header provided by the leader.
	Signature []byte
}

OutOfSyncProof is the evidence that the validator provides to the leader in the NACK vote to inform leader that it is out of sync with the network.

type QualifiedBlock

type QualifiedBlock struct {
	Block    *types.Block
	Hash     Hash
	Proposed bool
	AppHash  *Hash
}

type RawGetter

type RawGetter interface {
	GetRaw(Hash) ([]byte, *types.CommitInfo, error)
	GetRawByHeight(int64) (Hash, []byte, *types.CommitInfo, error)
}

type Role

type Role int
const (
	RoleLeader Role = iota
	RoleValidator
	RoleSentry
)

func (Role) String

func (r Role) String() string

type Tx

type Tx struct {
	*types.Transaction
	// contains filtered or unexported fields
}

Tx represents an immutable transaction. The constructor will compute the hash, which it will return directly from the Hash method. This means that the hash is only computed once. However, it is important note that the transaction fields should not be changed, because the hash will not be correct.

This is intended for use in node internals, primarily mempool and consensus engine where the hash is repeatedly accessed on deep call stacks.

In most cases, you should use the Tx type from the core/types package. Be aware of the cost of computing the hash, and avoid recomputing it.

If you use this type, be aware of the mutability caveat, and consider the cost of the memory allocation, and the persistence of the hash potentially after it is no longer needed.

func NewTx

func NewTx(tx *types.Transaction) *Tx

NewTx creates a new Tx from a *core/types.Transaction. This computes and stores the hash, which is returned by the Hash method without any recomputation. As such, the transaction fields should not be changed since the hash is never recomputed.

func (Tx) Bytes

func (tx Tx) Bytes() []byte

func (Tx) Hash

func (tx Tx) Hash() types.Hash

Hash returns the hash computed on construction. This shadows the Hash method of the *core/types.Transaction.

type TxGetter

type TxGetter interface {
	GetTx(txHash types.Hash) (raw *types.Transaction, height int64, blkHash types.Hash, blkIdx uint32, err error)
	HaveTx(Hash) bool
}

Directories

Path Synopsis
Package sql defines common type required by SQL database implementations and consumers.
Package sql defines common type required by SQL database implementations and consumers.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳