types

package
v0.10.0-beta-1 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2025 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

View Source
const HashLen = types.HashLen

Variables

View Source
var (
	HashBytes          = types.HashBytes
	ErrTxNotFound      = errors.New("tx not available")
	ErrTxAlreadyExists = errors.New("transaction already exists")
	ErrBlkNotFound     = errors.New("block not available")
	ErrStillProcessing = errors.New("block still being executed")
	ErrNoResponse      = errors.New("stream closed without response")
)
View Source
var ErrNotFound = types.ErrNotFound

Functions

This section is empty.

Types

type AckRes

type AckRes struct {
	ACK     bool
	Height  int64
	BlkHash Hash
	AppHash *Hash

	// Signature
	PubKeyType crypto.KeyType
	PubKey     []byte // crypto.PublicKey
	Signature  []byte
}

func (AckRes) MarshalBinary

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

func (AckRes) String

func (ar AckRes) String() string

func (*AckRes) UnmarshalBinary

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

type AckStatus

type AckStatus int
const (
	AckStatusDisagree AckStatus = iota
	AckStatusAgree
	AckStatusDiverge
)

func (*AckStatus) String

func (ack *AckStatus) String() string

type BlockGetter

type BlockGetter interface {
	Have(Hash) bool
	Get(Hash) (*types.Block, *CommitInfo, error)
	GetByHeight(int64) (Hash, *types.Block, *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
	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, *CommitInfo) error
}

type CommitInfo

type CommitInfo struct {
	AppHash      Hash
	Votes        []*VoteInfo
	ParamUpdates types.ParamUpdates
}

CommitInfo includes the information about the commit of the block. Such as the signatures of the validators aggreeing to the block.

func (*CommitInfo) MarshalBinary

func (ci *CommitInfo) MarshalBinary() ([]byte, error)

func (*CommitInfo) UnmarshalBinary

func (ci *CommitInfo) UnmarshalBinary(data []byte) 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() int
	ReapN(int) []NamedTx
	Get(Hash) *types.Transaction
	Remove(Hash)
	Store(Hash, *types.Transaction)
	PeekN(n int) []NamedTx
	// Check([]byte)
	PreFetch(txid Hash) bool // should be app level instead
}

type NamedTx

type NamedTx struct {
	Hash Hash
	Tx   *types.Transaction
}

type NodeStatus

type NodeStatus struct {
	Role            string                   `json:"role"`
	CatchingUp      bool                     `json:"catching_up"`
	CommittedHeader *types.BlockHeader       `json:"committed_header"`
	CommitInfo      *CommitInfo              `json:"commit_info"`
	Params          *types.NetworkParameters `json:"params"`
}

type QualifiedBlock

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

type RawGetter

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

type Role

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

func (Role) String

func (r Role) String() string

type Signature

type Signature struct {
	PubKeyType crypto.KeyType
	PubKey     []byte // public key of the validator

	Data []byte
}

func SignVote

func SignVote(blkID Hash, ack bool, appHash *Hash, privKey crypto.PrivateKey) (*Signature, error)

func (*Signature) ReadFrom

func (s *Signature) ReadFrom(r io.Reader) (int64, error)

func (*Signature) WriteTo

func (s *Signature) WriteTo(w io.Writer) (int64, error)

type TxGetter

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

type VoteInfo

type VoteInfo struct {
	// VoteSignature is the signature of the blkHash + nack | blkHash + ack + appHash
	Signature Signature

	// Ack is set to true if the validator agrees with the block
	// in terms of the AppHash, ValidatorSet, MerkleRoot of Txs etc.
	AckStatus AckStatus
	// AppHash is optional, it set only if the AckStatus is AckStatusDivereged.
	// AppHash is implied to be the AppHash in the CommitInfo if the AckStatus is AckStatusAgree.
	// AppHash is nil if the AckStatus is AckStatusDisagree.
	AppHash *Hash
}

func (*VoteInfo) MarshalBinary

func (v *VoteInfo) MarshalBinary() ([]byte, error)

func (*VoteInfo) UnmarshalBinary

func (v *VoteInfo) UnmarshalBinary(data []byte) error

func (*VoteInfo) Verify

func (v *VoteInfo) Verify(blkID Hash, appHash Hash) error

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