client

package
v0.0.32 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2021 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Timeout             = 15 * time.Second
	ErrCodeClient       = "client_error"
	ErrCodeDecodeFailed = "decode_error"
	ErrCodeUnexpected   = "unexpected_error"
	ErrCodeConnect      = "connect_error"
	ErrCodeBadParam     = "bad_param_error"
)

Timeout is the max duration for connection and read attempt

Variables

This section is empty.

Functions

This section is empty.

Types

type ChainAPI

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

ChainAPI implements Node to provide access to the chain-related RPC methods

func (*ChainAPI) GetBlock

func (c *ChainAPI) GetBlock(height uint64) (*api.ResultBlock, error)

GetBlock gets a block by height

func (*ChainAPI) GetBlockInfo

func (c *ChainAPI) GetBlockInfo(height uint64) (*api.ResultBlockInfo, error)

GetBlockInfo gets a summarized block data for the given height

func (*ChainAPI) GetHeight

func (c *ChainAPI) GetHeight() (uint64, error)

GetHeight returns the height of the blockchain

func (*ChainAPI) GetValidators

func (c *ChainAPI) GetValidators(height uint64) ([]*api.ResultValidator, error)

GetValidators gets validators at a given block height

func (*ChainAPI) IsSyncing

func (c *ChainAPI) IsSyncing() (bool, error)

IsSyncing checks whether the node is synchronizing with peers

type DHTAPI

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

DHTAPI implements DHT to provide access to the DHT network

func (*DHTAPI) Announce

func (d *DHTAPI) Announce(key string) error

Announce announces the given key to the network

func (*DHTAPI) GetPeers

func (d *DHTAPI) GetPeers() ([]string, error)

GetPeers returns node IDs of connected peers

func (*DHTAPI) GetProviders

func (d *DHTAPI) GetProviders(key string) ([]*api.ResultDHTProvider, error)

GetProviders returns providers of the given key

func (*DHTAPI) GetRepoObjectProviders

func (d *DHTAPI) GetRepoObjectProviders(hash string) ([]*api.ResultDHTProvider, error)

GetRepoObjectProviders returns providers for the given repository object hash

func (*DHTAPI) Lookup

func (d *DHTAPI) Lookup(key string) (string, error)

Lookup finds a value stored under the given key

func (*DHTAPI) Store

func (d *DHTAPI) Store(key, value string) error

Store stores a value under the given key on the DHT

type PoolAPI

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

PoolAPI implements Pool to provide access to the DHT network

func (*PoolAPI) GetPushPoolSize

func (d *PoolAPI) GetPushPoolSize() (int, error)

GetPushPoolSize returns size information of the mempool

func (*PoolAPI) GetSize

func (d *PoolAPI) GetSize() (*api.ResultPoolSize, error)

GetSize returns size information of the mempool

type PushKeyAPI

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

PushKeyAPI provides access to the pushkey-related RPC methods

func (*PushKeyAPI) GetOwner

func (pk *PushKeyAPI) GetOwner(addr string, blockHeight ...uint64) (*api.ResultAccount, error)

GetOwner gets the account that owns the given push key

func (*PushKeyAPI) Register

Register registers a public key as a push key

type RPCAPI

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

RPCAPI provides access to the rpc server-related methods

func (*RPCAPI) GetMethods

func (c *RPCAPI) GetMethods() ([]rpc.MethodInfo, error)

GetMethods gets all methods supported by the RPC server

type RPCClient

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

RPCClient provides the ability to interact with a JSON-RPC 2.0 service

func NewClient

func NewClient(opts *types.Options) *RPCClient

NewClient creates an instance of Client

func (*RPCClient) Call

func (c *RPCClient) Call(method string, params interface{}) (res util.Map, statusCode int, err error)

Call calls a method on the RPCClient service.

RETURNS:

  • res: JSON-RPC 2.0 success response
  • statusCode: RPCServer response code
  • err: Client error or JSON-RPC 2.0 error response. 0 = Client error

func (*RPCClient) DHT

func (c *RPCClient) DHT() types.DHT

DHT exposes methods for accessing the DHT network

func (*RPCClient) GetOptions

func (c *RPCClient) GetOptions() *types.Options

GetOptions returns the client's option

func (*RPCClient) Node

func (c *RPCClient) Node() types.Node

Node exposes methods for accessing chain information

func (*RPCClient) Pool

func (c *RPCClient) Pool() types.Pool

Pool exposes methods for managing push keys

func (*RPCClient) PushKey

func (c *RPCClient) PushKey() types.PushKey

PushKey exposes methods for managing push keys

func (*RPCClient) RPC

func (c *RPCClient) RPC() types.RPC

RPC exposes methods for managing the RPC server

func (*RPCClient) Repo

func (c *RPCClient) Repo() types.Repo

Repo exposes methods for managing repositories

func (*RPCClient) SetCallFunc

func (c *RPCClient) SetCallFunc(f callerFunc)

SetCallFunc sets the RPC call function

func (*RPCClient) Ticket

func (c *RPCClient) Ticket() types.Ticket

Ticket exposes methods for purchasing and managing tickets

func (*RPCClient) Tx

func (c *RPCClient) Tx() types.Tx

Tx exposes methods for creating and accessing the transactions

func (*RPCClient) User

func (c *RPCClient) User() types.User

User exposes methods for accessing user information

type RepoAPI

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

RepoAPI provides access to the repo-related RPC methods

func (*RepoAPI) AddContributors

func (c *RepoAPI) AddContributors(body *api.BodyAddRepoContribs) (*api.ResultHash, error)

AddContributors creates transaction to create a add repo contributors

func (*RepoAPI) Create

func (c *RepoAPI) Create(body *api.BodyCreateRepo) (*api.ResultCreateRepo, error)

Create creates a new repository

func (*RepoAPI) Get

func (c *RepoAPI) Get(name string, opts ...*api.GetRepoOpts) (*api.ResultRepository, error)

Get finds and returns a repository

func (*RepoAPI) VoteProposal

func (c *RepoAPI) VoteProposal(body *api.BodyRepoVote) (*api.ResultHash, error)

VoteProposal creates transaction to vote for/against a repository's proposal

type TicketAPI

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

TicketAPI provides access to ticket-related RPC methods

func (*TicketAPI) Buy

func (t *TicketAPI) Buy(body *api.BodyBuyTicket) (*api.ResultHash, error)

Buy creates a transaction to buy a validator ticket

func (*TicketAPI) BuyHost

func (t *TicketAPI) BuyHost(body *api.BodyBuyTicket) (*api.ResultHash, error)

BuyHost creates a transaction to buy a host ticket

func (*TicketAPI) List

func (t *TicketAPI) List(body *api.BodyTicketQuery) (res []*api.ResultTicket, err error)

List returns active validator tickets associated with a public key

func (*TicketAPI) ListHost

func (t *TicketAPI) ListHost(body *api.BodyTicketQuery) (res []*api.ResultTicket, err error)

ListHost returns active hosts tickets associated with a public key

type TxAPI

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

TxAPI provides access to the transaction-related RPC methods

func (*TxAPI) Get

func (t *TxAPI) Get(hash string) (*api.ResultTx, error)

Get gets a transaction by its hash

func (*TxAPI) Send

func (t *TxAPI) Send(data map[string]interface{}) (*api.ResultHash, error)

Send sends a signed transaction payload to the mempool

type UserAPI

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

UserAPI provides access to user-related RPC methods

func (*UserAPI) Get

func (u *UserAPI) Get(address string, blockHeight ...uint64) (*api.ResultAccount, error)

Get gets an account corresponding to a given address

func (*UserAPI) GetBalance

func (u *UserAPI) GetBalance(address string, blockHeight ...uint64) (float64, error)

GetBalance returns the spendable balance of an account

func (*UserAPI) GetKeys

func (u *UserAPI) GetKeys() ([]string, error)

GetKeys finds an account by address

func (*UserAPI) GetNonce

func (u *UserAPI) GetNonce(address string, blockHeight ...uint64) (uint64, error)

GetNonce gets the nonce of a user account corresponding to the given address

func (*UserAPI) GetPrivateKey

func (u *UserAPI) GetPrivateKey(address string, passphrase string) (string, error)

GetPrivateKey returns the private key of a key on the keystore

func (*UserAPI) GetPublicKey

func (u *UserAPI) GetPublicKey(address string, passphrase string) (string, error)

GetPublicKey returns the public key of a key on the keystore

func (*UserAPI) GetStakedBalance

func (u *UserAPI) GetStakedBalance(address string, blockHeight ...uint64) (float64, error)

GetStakedBalance returns the staked coin balance of an account

func (*UserAPI) GetValidator

func (u *UserAPI) GetValidator(includePrivKey bool) (*api.ResultValidatorInfo, error)

GetValidator get the validator information of the node

func (*UserAPI) Send

func (u *UserAPI) Send(body *api.BodySendCoin) (*api.ResultHash, error)

Send sends coins from a user account to another account or repository

func (*UserAPI) SetCommission

func (u *UserAPI) SetCommission(body *api.BodySetCommission) (*api.ResultHash, error)

SetCommission update the validator commission percentage of an account

Jump to

Keyboard shortcuts

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