abci

package
v0.0.0-...-f6bc33c Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2023 License: MIT Imports: 31 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

func AddCommonDeliverTxEvents

func AddCommonDeliverTxEvents(resp types.ResponseDeliverTx, tx Tx) types.ResponseDeliverTx

Types

type App

type App struct {
	abci.BaseApplication

	// handlers
	OnInitChain  OnInitChainHandler
	OnBeginBlock OnBeginBlockHandler
	OnEndBlock   OnEndBlockHandler
	OnCheckTx    OnCheckTxHandler
	OnDeliverTx  OnDeliverTxHandler
	OnCommit     OnCommitHandler

	// spam check
	OnCheckTxSpam   OnCheckTxSpamHandler
	OnDeliverTxSpam OnDeliverTxSpamHandler

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

func New

func New(codec Codec) *App

func (*App) ApplySnapshotChunk

func (app *App) ApplySnapshotChunk(req types.RequestApplySnapshotChunk) (resp types.ResponseApplySnapshotChunk)

func (*App) BeginBlock

func (app *App) BeginBlock(req types.RequestBeginBlock) (resp types.ResponseBeginBlock)

func (*App) CheckTx

func (app *App) CheckTx(req types.RequestCheckTx) (resp types.ResponseCheckTx)

func (*App) Commit

func (app *App) Commit() (resp types.ResponseCommit)

func (*App) DeliverTx

func (app *App) DeliverTx(req types.RequestDeliverTx) (resp types.ResponseDeliverTx)

func (*App) EndBlock

func (app *App) EndBlock(req types.RequestEndBlock) (resp types.ResponseEndBlock)

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(req types.RequestInfo) types.ResponseInfo

func (*App) InitChain

func (app *App) InitChain(req types.RequestInitChain) (resp types.ResponseInitChain)

func (*App) ListSnapshots

func (app *App) ListSnapshots(req types.RequestListSnapshots) (resp types.ResponseListSnapshots)

func (*App) LoadSnapshotChunk

func (app *App) LoadSnapshotChunk(req types.RequestLoadSnapshotChunk) (resp types.ResponseLoadSnapshotChunk)

func (*App) OfferSnapshot

func (app *App) OfferSnapshot(req types.RequestOfferSnapshot) (resp types.ResponseOfferSnapshot)

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/tendermint/tendermint/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 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(types.RequestInfo) types.ResponseInfo

ABCI hooks.

type ListSnapshotsHandler

type ListSnapshotsHandler func(types.RequestListSnapshots) types.ResponseListSnapshots

ABCI hooks.

type LoadSnapshotChunkHandler

type LoadSnapshotChunkHandler func(types.RequestLoadSnapshotChunk) types.ResponseLoadSnapshotChunk

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/tendermint/tendermint/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

type MaybePartialError interface {
	error
	IsPartial() bool
}

type OffserSnapshotHandler

type OffserSnapshotHandler func(types.RequestOfferSnapshot) types.ResponseOfferSnapshot

ABCI hooks.

type OnBeginBlockHandler

type OnBeginBlockHandler func(types.RequestBeginBlock) (context.Context, types.ResponseBeginBlock)

ABCI hooks.

type OnCheckTxHandler

ABCI hooks.

type OnCheckTxSpamHandler

type OnCheckTxSpamHandler func(Tx) types.ResponseCheckTx

ABCI hooks.

type OnCommitHandler

type OnCommitHandler func() types.ResponseCommit

ABCI hooks.

type OnDeliverTxHandler

ABCI hooks.

type OnDeliverTxSpamHandler

type OnDeliverTxSpamHandler func(context.Context, Tx) types.ResponseDeliverTx

ABCI hooks.

type OnEndBlockHandler

type OnEndBlockHandler func(types.RequestEndBlock) (context.Context, types.ResponseEndBlock)

ABCI hooks.

type OnInitChainHandler

type OnInitChainHandler func(types.RequestInitChain) types.ResponseInitChain

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 {
	// 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
}

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