blockchain

package
v0.73.0-preview.13 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProviderNullChain  = "nullchain"
	ProviderTendermint = "tendermint"
)
View Source
const (
	// AbciTxnValidationFailure ...
	AbciTxnValidationFailure uint32 = 51

	// AbciTxnDecodingFailure code is returned when CheckTx or DeliverTx fail to decode the Txn.
	AbciTxnDecodingFailure uint32 = 60

	// AbciTxnInternalError code is returned when CheckTx or DeliverTx fail to process the Txn.
	AbciTxnInternalError uint32 = 70

	// AbciTxnPartialProcessingError code is return when a batch instruction partially fail.
	AbciTxnPartialProcessingError uint32 = 71

	// AbciUnknownCommandError code is returned when the app doesn't know how to handle a given command.
	AbciUnknownCommandError uint32 = 80

	// AbciSpamError code is returned when CheckTx or DeliverTx fail spam protection tests.
	AbciSpamError uint32 = 89
)

Variables

View Source
var ErrClientNotReady = errors.New("tendermint client is not ready")

Functions

func NewResponseCheckTx added in v0.56.0

func NewResponseCheckTx(code uint32, info string) types.ResponseCheckTx

func NewResponseCheckTxError added in v0.56.0

func NewResponseCheckTxError(code uint32, err error) types.ResponseCheckTx

func NewResponseDeliverTx added in v0.56.0

func NewResponseDeliverTx(code uint32, info string) types.ResponseDeliverTx

func NewResponseDeliverTxError added in v0.56.0

func NewResponseDeliverTxError(code uint32, err error) types.ResponseDeliverTx

Types

type ChainClientImpl

type ChainClientImpl interface {
	GetGenesisTime(context.Context) (time.Time, error)
	GetChainID(context.Context) (string, error)
	GetStatus(context.Context) (*tmctypes.ResultStatus, error)
	GetNetworkInfo(context.Context) (*tmctypes.ResultNetInfo, error)
	GetUnconfirmedTxCount(context.Context) (int, error)
	Health(context.Context) (*tmctypes.ResultHealth, error)
	SendTransactionAsync(context.Context, []byte) (*tmctypes.ResultBroadcastTx, error)
	SendTransactionSync(context.Context, []byte) (*tmctypes.ResultBroadcastTx, error)
	CheckTransaction(context.Context, []byte) (*tmctypes.ResultCheckTx, error)
	SendTransactionCommit(context.Context, []byte) (*tmctypes.ResultBroadcastTxCommit, error)
	GenesisValidators(context.Context) ([]*tmtypes.Validator, error)
	Validators(context.Context, *int64) ([]*tmtypes.Validator, error)
	Subscribe(context.Context, func(tmctypes.ResultEvent) error, ...string) error
	Start() error
}

nolint: interfacebloat

type ChainServerImpl

type ChainServerImpl interface {
	ReloadConf(cfg Config)
	Stop() error
	Start() error
}

type Client

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

Client abstract all communication to the blockchain.

func NewClient

func NewClient() *Client

NewClient instantiate a new blockchain client.

func NewClientWithImpl

func NewClientWithImpl(clt ChainClientImpl) *Client

func (*Client) CheckRawTransaction

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

func (*Client) CheckTransaction

func (c *Client) CheckTransaction(ctx context.Context, tx *commandspb.Transaction) (*tmctypes.ResultCheckTx, error)

func (*Client) GenesisValidators

func (c *Client) GenesisValidators() ([]*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() (*tmctypes.ResultHealth, error)

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

func (*Client) Set

func (c *Client) Set(clt ChainClientImpl)

func (*Client) Start

func (c *Client) Start() error

func (*Client) SubmitRawTransactionAsync

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

func (*Client) SubmitRawTransactionCommit

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

func (*Client) SubmitRawTransactionSync

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

func (*Client) SubmitTransactionAsync

func (c *Client) SubmitTransactionAsync(ctx context.Context, tx *commandspb.Transaction) (*tmctypes.ResultBroadcastTx, error)

func (*Client) SubmitTransactionCommit

func (c *Client) SubmitTransactionCommit(ctx context.Context, tx *commandspb.Transaction) (*tmctypes.ResultBroadcastTxCommit, error)

func (*Client) SubmitTransactionSync

func (c *Client) SubmitTransactionSync(ctx context.Context, tx *commandspb.Transaction) (*tmctypes.ResultBroadcastTx, error)

func (*Client) Subscribe

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

func (*Client) Validators

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

type Config

type Config struct {
	Level               encoding.LogLevel `long:"log-level"`
	LogTimeDebug        bool              `long:"log-time-debug"`
	LogOrderSubmitDebug bool              `long:"log-order-submit-debug"`
	LogOrderAmendDebug  bool              `long:"log-order-amend-debug"`
	LogOrderCancelDebug bool              `long:"log-order-cancel-debug"`
	ChainProvider       string            `long:"chain-provider"`

	Tendermint TendermintConfig `group:"Tendermint" namespace:"tendermint"`
	Null       NullChainConfig  `group:"NullChain"  namespace:"nullchain"`
}

Config represent the configuration of the blockchain package.

func NewDefaultConfig

func NewDefaultConfig() Config

NewDefaultConfig creates an instance of the package specific configuration, given a pointer to a logger instance to be used for logging within the package.

type NullChainConfig

type NullChainConfig struct {
	Level                encoding.LogLevel `long:"log-level"`
	BlockDuration        encoding.Duration `description:"(default 1s)"                           long:"block-duration"`
	TransactionsPerBlock uint64            `description:"(default 10)"                           long:"transactions-per-block"`
	GenesisFile          string            `description:"path to a tendermint genesis file"      long:"genesis-file"`
	IP                   string            `description:"time-forwarding IP (default localhost)" long:"ip"`
	Port                 int               `description:"time-forwarding port (default 3009)"    long:"port"`
	Replay               ReplayConfig
}

func NewDefaultNullChainConfig

func NewDefaultNullChainConfig() NullChainConfig

NewDefaultNullChainConfig creates an instance of the package specific configuration, given a pointer to a logger instance to be used for logging within the package.

type ReplayConfig added in v0.62.0

type ReplayConfig struct {
	Record     bool   `description:"whether to record block data to a file to allow replaying" long:"record"`
	Replay     bool   `description:"whether to replay any blockdata found in replay-file"      long:"replay"`
	ReplayFile string `description:"path to file of which to write/read replay data"           long:"replay-file"`
}

type Server

type Server struct {
	*Config
	// contains filtered or unexported fields
}

Server abstraction for the abci server.

func NewServer

func NewServer(log *logging.Logger, srv ChainServerImpl) *Server

NewServer instantiate a new blockchain server.

func (*Server) ReloadConf

func (s *Server) ReloadConf(cfg Config)

func (*Server) Start

func (s *Server) Start() error

func (*Server) Stop

func (s *Server) Stop() error

Stop gracefully shutdowns down the blockchain provider's server.

type TendermintConfig

type TendermintConfig struct {
	Level   encoding.LogLevel `description:" "                             long:"log-level"`
	RPCAddr string            `description:"address of the tendermint rpc" long:"rpc-addr"`
}

func NewDefaultTendermintConfig

func NewDefaultTendermintConfig() TendermintConfig

NewDefaultTendermintConfig creates an instance of the package specific configuration, given a pointer to a logger instance to be used for logging within the package.

Directories

Path Synopsis
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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