abci

package
v0.75.8 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: AGPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyClientAddr = errors.New("abci client addr is empty in config")
View Source
var ErrNoNetworkGenesisState = errors.New("no network genesis state")

Functions

func AddCommonCheckTxEvents

func AddCommonCheckTxEvents(resp *types.ResponseCheckTx, tx Tx) *types.ResponseCheckTx

Types

type App

type App struct {
	abci.BaseApplication

	// handlers
	OnPrepareProposal PrepareProposalHandler
	OnProcessProposal ProcessProposalHandler
	OnInitChain       OnInitChainHandler
	OnCheckTx         OnCheckTxHandler
	OnCommit          OnCommitHandler
	OnBeginBlock      OnBeginBlockHandler
	OnEndBlock        OnEndBlockHandler
	OnFinalize        FinalizeHandler

	// spam check
	OnCheckTxSpam OnCheckTxSpamHandler

	OnListSnapshots      ListSnapshotsHandler
	OnOfferSnapshot      OfferSnapshotHandler
	OnLoadSnapshotChunk  LoadSnapshotChunkHandler
	OnApplySnapshotChunk ApplySnapshotChunkHandler
	OnInfo               InfoHandler
	// contains filtered or unexported fields
}

func New

func New(codec Codec) *App

func (*App) CheckTx

func (app *App) CheckTx(_ context.Context, req *types.RequestCheckTx) (*types.ResponseCheckTx, error)

func (*App) Commit

func (app *App) Commit(_ context.Context, req *types.RequestCommit) (*types.ResponseCommit, error)

func (*App) FinalizeBlock added in v0.74.0

FinalizeBlock lets the application process a whole block end to end.

func (*App) GetChainID

func (app *App) GetChainID() string

func (*App) HandleCheckTx

func (app *App) HandleCheckTx(cmd txn.Command, fn TxHandler) *App

func (*App) HandleDeliverTx

func (app *App) HandleDeliverTx(cmd txn.Command, fn TxHandler) *App

func (*App) Info

func (app *App) Info(ctx context.Context, req *types.RequestInfo) (*types.ResponseInfo, error)

func (*App) InitChain

func (app *App) InitChain(_ context.Context, req *types.RequestInitChain) (*types.ResponseInitChain, error)

func (*App) ListSnapshots

func (app *App) ListSnapshots(ctx context.Context, req *types.RequestListSnapshots) (*types.ResponseListSnapshots, error)

func (*App) LoadSnapshotChunk

func (app *App) LoadSnapshotChunk(ctx context.Context, req *types.RequestLoadSnapshotChunk) (*types.ResponseLoadSnapshotChunk, error)

func (*App) OfferSnapshot

func (app *App) OfferSnapshot(ctx context.Context, req *types.RequestOfferSnapshot) (*types.ResponseOfferSnapshot, error)

func (*App) PrepareProposal added in v0.74.0

PrepareProposal will take the given transactions from the mempool and attempts to prepare a proposal from them when it's our turn to do so while keeping the size, gas, pow, and spam constraints.

func (*App) ProcessProposal added in v0.74.0

ProcessProposal implements part of the Application interface. It accepts any proposal that does not contain a malformed transaction. NB: processProposal will not be called if the node is fast-sync-ing so no state change is allowed here!!!.

func (*App) SetChainID

func (app *App) SetChainID(chainID string)

type Client

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

func NewClient

func NewClient(addr string) (*Client, error)

func (*Client) CheckTransaction

func (c *Client) CheckTransaction(ctx context.Context, bytes []byte) (*tmctypes.ResultCheckTx, error)

func (*Client) Genesis

func (c *Client) Genesis(ctx context.Context) (*tmtypes.GenesisDoc, error)

func (*Client) GenesisValidators

func (c *Client) GenesisValidators(ctx context.Context) ([]*tmtypes.Validator, error)

func (*Client) GetChainID

func (c *Client) GetChainID(ctx context.Context) (chainID string, err error)

GetChainID retrieves the chainID from the blockchain.

func (*Client) GetGenesisTime

func (c *Client) GetGenesisTime(ctx context.Context) (genesisTime time.Time, err error)

GetGenesisTime retrieves the genesis time from the blockchain.

func (*Client) GetNetworkInfo

func (c *Client) GetNetworkInfo(ctx context.Context) (netInfo *tmctypes.ResultNetInfo, err error)

GetNetworkInfo return information of the current network.

func (*Client) GetStatus

func (c *Client) GetStatus(ctx context.Context) (status *tmctypes.ResultStatus, err error)

GetStatus returns the current status of the chain.

func (*Client) GetUnconfirmedTxCount

func (c *Client) GetUnconfirmedTxCount(ctx context.Context) (count int, err error)

GetUnconfirmedTxCount return the current count of unconfirmed transactions.

func (*Client) Health

func (c *Client) Health(ctx context.Context) (*tmctypes.ResultHealth, error)

Health returns the result of the health endpoint of the chain.

func (*Client) SendTransactionAsync

func (c *Client) SendTransactionAsync(ctx context.Context, bytes []byte) (*tmctypes.ResultBroadcastTx, error)

func (*Client) SendTransactionCommit

func (c *Client) SendTransactionCommit(ctx context.Context, bytes []byte) (*tmctypes.ResultBroadcastTxCommit, error)

func (*Client) SendTransactionSync

func (c *Client) SendTransactionSync(ctx context.Context, bytes []byte) (*tmctypes.ResultBroadcastTx, error)

func (*Client) Start

func (c *Client) Start() error

func (*Client) Subscribe

func (c *Client) Subscribe(ctx context.Context, fn func(tmctypes.ResultEvent) error, queries ...string) error

Subscribe subscribes to any event matching query (https://godoc.org/github.com/cometbft/cometbft/types#pkg-constants). Subscribe will call fn each time it receives an event from the node. The function returns nil when the context is canceled or when fn returns an error.

func (*Client) Validators

func (c *Client) Validators(ctx context.Context, height *int64) ([]*tmtypes.Validator, error)

type Codec

type Codec interface {
	Decode(in []byte, chainID string) (Tx, error)
}

type Command

type Command byte

type FinalizeHandler added in v0.74.0

type FinalizeHandler func() []byte

ABCI hooks.

type GenesisState

type GenesisState struct {
	// ReplayAttackThreshold protects the network against replay attacks. It sets a
	// toleration thershold between the current block in the chain and the block
	// heigh specified in the Tx.  Tx with blocks height >= than (chain's height -
	// distance) are rejected with a AbciTxnRejected.  It also keeps a ring-buffer
	// to cache seen Tx. The Ring buffer size defines the number of block to cache,
	// each block can hold an unlimited number of Txs.
	ReplayAttackThreshold uint `json:"replay_attack_threshold"`
}

func DefaultGenesis

func DefaultGenesis() GenesisState

func LoadGenesisState

func LoadGenesisState(bytes []byte) (*GenesisState, error)

type InfoHandler

type InfoHandler func(context.Context, *types.RequestInfo) (*types.ResponseInfo, error)

ABCI hooks.

type ListSnapshotsHandler

ABCI hooks.

type LocalClient

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

func (*LocalClient) CheckTransaction

func (c *LocalClient) CheckTransaction(ctx context.Context, bytes []byte) (*tmctypes.ResultCheckTx, error)

func (*LocalClient) Genesis

func (c *LocalClient) Genesis(ctx context.Context) (*tmtypes.GenesisDoc, error)

func (*LocalClient) GenesisValidators

func (c *LocalClient) GenesisValidators(ctx context.Context) ([]*tmtypes.Validator, error)

func (*LocalClient) GetChainID

func (c *LocalClient) GetChainID(ctx context.Context) (chainID string, err error)

GetChainID retrieves the chainID from the blockchain.

func (*LocalClient) GetGenesisTime

func (c *LocalClient) GetGenesisTime(ctx context.Context) (genesisTime time.Time, err error)

GetGenesisTime retrieves the genesis time from the blockchain.

func (*LocalClient) GetNetworkInfo

func (c *LocalClient) GetNetworkInfo(ctx context.Context) (netInfo *tmctypes.ResultNetInfo, err error)

GetNetworkInfo return information of the current network.

func (*LocalClient) GetStatus

func (c *LocalClient) GetStatus(ctx context.Context) (status *tmctypes.ResultStatus, err error)

GetStatus returns the current status of the chain.

func (*LocalClient) GetUnconfirmedTxCount

func (c *LocalClient) GetUnconfirmedTxCount(ctx context.Context) (count int, err error)

GetUnconfirmedTxCount return the current count of unconfirmed transactions.

func (*LocalClient) Health

Health returns the result of the health endpoint of the chain.

func (*LocalClient) SendTransactionAsync

func (c *LocalClient) SendTransactionAsync(ctx context.Context, bytes []byte) (*tmctypes.ResultBroadcastTx, error)

func (*LocalClient) SendTransactionCommit

func (c *LocalClient) SendTransactionCommit(ctx context.Context, bytes []byte) (*tmctypes.ResultBroadcastTxCommit, error)

func (*LocalClient) SendTransactionSync

func (c *LocalClient) SendTransactionSync(ctx context.Context, bytes []byte) (*tmctypes.ResultBroadcastTx, error)

func (*LocalClient) Start

func (c *LocalClient) Start() error

func (*LocalClient) Subscribe

func (c *LocalClient) Subscribe(ctx context.Context, fn func(tmctypes.ResultEvent) error, queries ...string) error

Subscribe subscribes to any event matching query (https://godoc.org/github.com/cometbft/cometbft/types#pkg-constants). Subscribe will call fn each time it receives an event from the node. The function returns nil when the context is canceled or when fn returns an error.

func (*LocalClient) Validators

func (c *LocalClient) Validators(ctx context.Context, height *int64) ([]*tmtypes.Validator, error)

type MaybePartialError added in v0.71.0

type MaybePartialError interface {
	error
	IsPartial() bool
}

type OfferSnapshotHandler added in v0.73.0

ABCI hooks.

type OnBeginBlockHandler

type OnBeginBlockHandler func(uint64, string, time.Time, string, []Tx) context.Context

ABCI hooks.

type OnCheckTxHandler

ABCI hooks.

type OnCheckTxSpamHandler

type OnCheckTxSpamHandler func(Tx) types.ResponseCheckTx

ABCI hooks.

type OnCommitHandler

type OnCommitHandler func() (*types.ResponseCommit, error)

ABCI hooks.

type OnDeliverTxHandler

type OnDeliverTxHandler func(context.Context, Tx)

ABCI hooks.

type OnEndBlockHandler

type OnEndBlockHandler func(blockHeight uint64) (types.ValidatorUpdates, types1.ConsensusParams)

ABCI hooks.

type OnInitChainHandler

type OnInitChainHandler func(*types.RequestInitChain) (*types.ResponseInitChain, error)

ABCI hooks.

type PrepareProposalHandler added in v0.74.0

type PrepareProposalHandler func(txs []Tx, raWtxs [][]byte) [][]byte

ABCI hooks.

type ProcessProposalHandler added in v0.74.0

type ProcessProposalHandler func(txs []Tx) bool

ABCI hooks.

type SnapshotEngine

type SnapshotEngine interface {
	AddProviders(provs ...types.StateProvider)
}

type TmLogger

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

func (*TmLogger) Debug

func (tl *TmLogger) Debug(msg string, keyVals ...interface{})

func (*TmLogger) Error

func (tl *TmLogger) Error(msg string, keyVals ...interface{})

func (*TmLogger) Info

func (tl *TmLogger) Info(msg string, keyVals ...interface{})

func (*TmLogger) With

func (tl *TmLogger) With(keyVals ...interface{}) tmlog.Logger

type TmNode

type TmNode struct {
	MempoolSize int64
	// contains filtered or unexported fields
}

func NewTmNode

func NewTmNode(
	conf blockchain.Config,
	log *logging.Logger,
	homeDir string,
	app types.Application,
	genesisDoc *tmtypes.GenesisDoc,
) (*TmNode, error)

func (*TmNode) GetClient

func (t *TmNode) GetClient() (*LocalClient, error)

func (*TmNode) ReloadConf

func (*TmNode) ReloadConf(cfg blockchain.Config)

func (*TmNode) Start

func (t *TmNode) Start() error

func (*TmNode) Stop

func (t *TmNode) Stop() error

type Tx

type Tx interface {
	Command() txn.Command
	Unmarshal(interface{}) error
	PubKey() []byte
	PubKeyHex() string
	Party() string
	Hash() []byte
	Signature() []byte
	BlockHeight() uint64
	GetCmd() interface{}
	GetPoWNonce() uint64
	GetPoWTID() string
	GetVersion() uint32
	GetLength() int
	GetNonce() uint64
}

type TxHandler

type TxHandler func(ctx context.Context, tx Tx) error

Jump to

Keyboard shortcuts

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