tmcli

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2019 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TmDefaultServer = "http://127.0.0.1:26657"

Functions

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range or equal to 202 Accepted. API error responses are expected to have either no response body, or a JSON response body that maps to ErrorResponse. Any other response body will be silently ignored.

The error type will be *RateLimitError for rate limit exceeded errors, *AcceptedError for 202 Accepted status codes, and *TwoFactorAuthError for two-factor authentication errors.

func NewOption

func NewOption(fs ...SetOption) (*option, error)

NewOption 创建可选参数

func NewTestTmServer

func NewTestTmServer() *testTmServer

Types

type AbciQueryOption

type AbciQueryOption struct {
	Path    string `url:"path,omitempty"`
	Data    []byte `url:"data,omitempty"`
	Height  int64  `url:"height,omitempty"`
	Trusted bool   `url:"trusted,omitempty"`
}

type BlockOption

type BlockOption struct {
	Height int `url:"height,omitempty"`
}

type BlockResultsOption

type BlockResultsOption struct {
	Height int `url:"height,omitempty"`
}

type BlockchainOption

type BlockchainOption struct {
	MinHeight int64 `url:"minHeight,omitempty"`
	MaxHeight int64 `url:"maxHeight,omitempty"`
}

type BroadcastTxAsyncOption

type BroadcastTxAsyncOption struct {
	Tx string `url:"tx,omitempty"`
}

type BroadcastTxCommitOption

type BroadcastTxCommitOption struct {
	Tx string `url:"tx,omitempty"`
}

type BroadcastTxSyncOption

type BroadcastTxSyncOption struct {
	Tx string `url:"tx,omitempty"`
}

type Client

type Client struct {
	Test int

	Status             *statusService
	AbciInfo           *abciInfoService
	ConsensusState     *consensusStateService
	DumpConsensusState *dumpConsensusStateService
	Genesis            *genesisService
	Health             *healthService
	NetInfo            *netInfoService
	NumUnconfirmedTxs  *numUnconfirmedTxsService
	AbciQuery          *abciQueryService
	Block              *blockService
	BlockResults       *blockResultsService
	Blockchain         *blockchainService
	BroadcastTxAsync   *broadcastTxAsyncService
	BroadcastTxCommit  *broadcastTxCommitService
	BroadcastTxSync    *broadcastTxSyncService
	Subscribe          *subscribeService
	Tx                 *txService
	TxSearch           *txSearchService
	UnconfirmedTxs     *unconfirmedTxsService
	Unsubscribe        *unsubscribeService
	Validators         *validatorsService
	// contains filtered or unexported fields
}

Client 客户端结构

func NewClient

func NewClient(opt *option) *Client

NewClient 创建tendermint Client

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*http.Response, error)

do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it. If rate limit is exceeded and reset time is in the future, do returns *RateLimitError immediately without making a network API call.

The provided ctx must be non-nil. If it is canceled or times out, ctx.Err() will be returned.

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)

newRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the BaseURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.

type SetOption

type SetOption func(options *option) error

func SetOptionHost

func SetOptionHost(host string) SetOption

SetOptionHost 设置可选参数host

type SubscribeOption

type SubscribeOption struct {
	Query string `url:"query,omitempty"`
}

type TxOption

type TxOption struct {
	Hash  []byte `url:"hash,omitempty"`
	Prove bool   `url:"prove,omitempty"`
}

type TxSearchOption

type TxSearchOption struct {
	Prove   bool `url:"prove,omitempty"`
	Page    int  `url:"page,omitempty"`
	PerPage int  `url:"perPage,omitempty"`
}

type UnconfirmedTxsOption

type UnconfirmedTxsOption struct {
	Limit int `url:"limit,omitempty"`
}

type UnsubscribeOption

type UnsubscribeOption struct {
	Query string `url:"query,omitempty"`
}

type ValidatorsOption

type ValidatorsOption struct {
	Height int `url:"height,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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