client

package
v0.12.3 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2021 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package client provides a client for the FISCO BCOS RPC API.

Package client provides a client for the FISCO BCOS RPC API.

Index

Constants

View Source
const (
	BlockLimit int64 = 600
)
View Source
const (
	//V2_5_0 is node version v2.5.0
	V2_5_0 int = 0x02050000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIHandler

type APIHandler struct {
	*conn.Connection
}

APIHandler defines typed wrappers for the FISCO BCOS RPC API.

func NewAPIHandler

func NewAPIHandler(c *conn.Connection) *APIHandler

NewAPIHandler create a new API handler

func (*APIHandler) AsyncSendRawTransaction

func (api *APIHandler) AsyncSendRawTransaction(ctx context.Context, groupID int, tx *types.Transaction, handler func(*types.Receipt, error)) error

AsyncSendRawTransaction send a transaction async

func (*APIHandler) BroadcastAMOPMsg

func (api *APIHandler) BroadcastAMOPMsg(topic string, data []byte) error

func (*APIHandler) BroadcastAMOPPrivateMsg

func (api *APIHandler) BroadcastAMOPPrivateMsg(topic string, data []byte) error

func (*APIHandler) Call

func (api *APIHandler) Call(ctx context.Context, groupID int, msg ethereum.CallMsg) ([]byte, error)

Call invoke the call method of rpc api

func (*APIHandler) GetBlockByHash

func (api *APIHandler) GetBlockByHash(ctx context.Context, groupID int, blockHash common.Hash, includeTx bool) ([]byte, error)

GetBlockByHash returns the block information according to the given block hash

func (*APIHandler) GetBlockByNumber

func (api *APIHandler) GetBlockByNumber(ctx context.Context, groupID int, blockNumber int64, includeTx bool) ([]byte, error)

GetBlockByNumber returns the block information according to the given block number(hex format)

func (*APIHandler) GetBlockHashByNumber

func (api *APIHandler) GetBlockHashByNumber(ctx context.Context, groupID int, blockNumber int64) (*common.Hash, error)

GetBlockHashByNumber returns the block hash according to the given block number

func (*APIHandler) GetBlockLimit

func (api *APIHandler) GetBlockLimit(ctx context.Context, groupID int) (*big.Int, error)

GetBlockLimit returns the blocklimit for current blocknumber

func (*APIHandler) GetBlockNumber

func (api *APIHandler) GetBlockNumber(ctx context.Context, groupID int) (int64, error)

GetBlockNumber returns the latest block height(hex format) on a given groupID.

func (*APIHandler) GetChainID

func (api *APIHandler) GetChainID(ctx context.Context) (*big.Int, error)

GetChainID returns the Chain ID of the FISCO BCOS running on the nodes.

func (*APIHandler) GetClientVersion

func (api *APIHandler) GetClientVersion(ctx context.Context) ([]byte, error)

GetClientVersion returns the version of FISCO BCOS running on the nodes.

func (*APIHandler) GetCode

func (api *APIHandler) GetCode(ctx context.Context, groupID int, address common.Address) ([]byte, error)

GetCode returns the contract code according to the contract address

func (*APIHandler) GetConsensusStatus

func (api *APIHandler) GetConsensusStatus(ctx context.Context, groupID int) ([]byte, error)

GetConsensusStatus returns the status information about the consensus algorithm on a specific groupID

func (*APIHandler) GetContractAddress

func (api *APIHandler) GetContractAddress(ctx context.Context, groupID int, txHash common.Hash) (common.Address, error)

GetContractAddress returns a contract address according to the transaction hash

func (*APIHandler) GetGroupList

func (api *APIHandler) GetGroupList(ctx context.Context) ([]byte, error)

GetGroupList returns the groupID list that the node belongs to

func (*APIHandler) GetGroupPeers

func (api *APIHandler) GetGroupPeers(ctx context.Context, groupID int) ([]byte, error)

GetGroupPeers returns the nodes and the overser nodes list on a specific group

func (*APIHandler) GetNodeIDList

func (api *APIHandler) GetNodeIDList(ctx context.Context, groupID int) ([]byte, error)

GetNodeIDList returns the ID information of the connected peers and itself

func (*APIHandler) GetObserverList

func (api *APIHandler) GetObserverList(ctx context.Context, groupID int) ([]byte, error)

GetObserverList returns the list of observer nodes' ID according to the groupID

func (*APIHandler) GetPBFTView

func (api *APIHandler) GetPBFTView(ctx context.Context, groupID int) ([]byte, error)

GetPBFTView returns the latest PBFT view(hex format) of the specific group and it will returns a wrong sentence if the consensus algorithm is not the PBFT.

func (*APIHandler) GetPeers

func (api *APIHandler) GetPeers(ctx context.Context, groupID int) ([]byte, error)

GetPeers returns the information of the connected peers

func (*APIHandler) GetPendingTransactions

func (api *APIHandler) GetPendingTransactions(ctx context.Context, groupID int) ([]byte, error)

GetPendingTransactions returns information of the pending transactions

func (*APIHandler) GetPendingTxSize

func (api *APIHandler) GetPendingTxSize(ctx context.Context, groupID int) ([]byte, error)

GetPendingTxSize returns amount of the pending transactions

func (*APIHandler) GetSealerList

func (api *APIHandler) GetSealerList(ctx context.Context, groupID int) ([]byte, error)

GetSealerList returns the list of consensus nodes' ID according to the groupID

func (*APIHandler) GetSyncStatus

func (api *APIHandler) GetSyncStatus(ctx context.Context, groupID int) ([]byte, error)

GetSyncStatus returns the synchronization status of the group

func (*APIHandler) GetSystemConfigByKey

func (api *APIHandler) GetSystemConfigByKey(ctx context.Context, groupID int, configKey string) ([]byte, error)

GetSystemConfigByKey returns value according to the key(only tx_count_limit, tx_gas_limit could work)

func (*APIHandler) GetTotalTransactionCount

func (api *APIHandler) GetTotalTransactionCount(ctx context.Context, groupID int) ([]byte, error)

GetTotalTransactionCount returns the total amount of transactions and the block height at present

func (*APIHandler) GetTransactionByBlockHashAndIndex

func (api *APIHandler) GetTransactionByBlockHashAndIndex(ctx context.Context, groupID int, blockHash common.Hash, txIndex int) ([]byte, error)

GetTransactionByBlockHashAndIndex returns the transaction information according to the given block hash and transaction index

func (*APIHandler) GetTransactionByBlockNumberAndIndex

func (api *APIHandler) GetTransactionByBlockNumberAndIndex(ctx context.Context, groupID int, blockNumber int64, txIndex int) ([]byte, error)

GetTransactionByBlockNumberAndIndex returns the transaction information according to the given block number and transaction index

func (*APIHandler) GetTransactionByHash

func (api *APIHandler) GetTransactionByHash(ctx context.Context, groupID int, txHash common.Hash) ([]byte, error)

GetTransactionByHash returns the transaction information according to the given transaction hash

func (*APIHandler) GetTransactionReceipt

func (api *APIHandler) GetTransactionReceipt(ctx context.Context, groupID int, txHash common.Hash) (*types.Receipt, error)

GetTransactionReceipt returns the transaction receipt according to the given transaction hash

func (*APIHandler) PublishPrivateTopic

func (api *APIHandler) PublishPrivateTopic(topic string, publicKey []*ecdsa.PublicKey) error

func (*APIHandler) SendAMOPMsg

func (api *APIHandler) SendAMOPMsg(topic string, data []byte) ([]byte, error)

func (*APIHandler) SendAMOPPrivateMsg

func (api *APIHandler) SendAMOPPrivateMsg(topic string, data []byte) ([]byte, error)

func (*APIHandler) SendRawTransaction

func (api *APIHandler) SendRawTransaction(ctx context.Context, groupID int, tx *types.Transaction) (*types.Receipt, error)

SendRawTransaction injects a signed transaction into the pending pool for execution.

If the transaction was a contract creation use the TransactionReceipt method to get the contract address after the transaction has been mined.

func (*APIHandler) SubscribeBlockNumberNotify

func (api *APIHandler) SubscribeBlockNumberNotify(groupID uint64, handler func(int64)) error

func (*APIHandler) SubscribePrivateTopic

func (api *APIHandler) SubscribePrivateTopic(topic string, privateKey *ecdsa.PrivateKey, handler func([]byte, *[]byte)) error

func (*APIHandler) SubscribeTopic

func (api *APIHandler) SubscribeTopic(topic string, handler func([]byte, *[]byte)) error

func (*APIHandler) TransactionReceipt

func (api *APIHandler) TransactionReceipt(ctx context.Context, groupID int, txHash common.Hash) (*types.Receipt, error)

TransactionReceipt returns the receipt of a transaction by transaction hash. Note that the receipt is not available for pending transactions.

func (*APIHandler) UnsubscribeBlockNumberNotify

func (api *APIHandler) UnsubscribeBlockNumberNotify(groupID uint64) error

func (*APIHandler) UnsubscribePrivateTopic

func (api *APIHandler) UnsubscribePrivateTopic(topic string) error

func (*APIHandler) UnsubscribeTopic

func (api *APIHandler) UnsubscribeTopic(topic string) error

type Client

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

Client defines typed wrappers for the Ethereum RPC API.

func Dial

func Dial(config *conf.Config) (*Client, error)

Dial connects a client to the given URL and groupID.

func DialContext

func DialContext(ctx context.Context, config *conf.Config) (*Client, error)

DialContext pass the context to the rpc client

func (*Client) AsyncSendTransaction

func (c *Client) AsyncSendTransaction(ctx context.Context, tx *types.Transaction, handler func(*types.Receipt, error)) error

AsyncSendTransaction send transaction async

func (*Client) BroadcastAMOPMsg

func (c *Client) BroadcastAMOPMsg(topic string, data []byte) error

func (*Client) BroadcastAMOPPrivateMsg

func (c *Client) BroadcastAMOPPrivateMsg(topic string, data []byte) error

func (*Client) CallContract

func (c *Client) CallContract(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)

CallContract invoke the call method of rpc api

func (*Client) Close

func (c *Client) Close()

Close disconnects the rpc

func (*Client) CodeAt

func (c *Client) CodeAt(ctx context.Context, account common.Address, blockNumber *big.Int) ([]byte, error)

CodeAt returns the contract code of the given account. The block number can be nil, in which case the code is taken from the latest known block.

func (*Client) FilterLogs

func (c *Client) FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]types.Log, error)

FilterLogs executes a filter query.

func (*Client) GetBlockByHash

func (c *Client) GetBlockByHash(ctx context.Context, blockHash common.Hash, includeTx bool) ([]byte, error)

GetBlockByHash returns the block information according to the given block hash

func (*Client) GetBlockByNumber

func (c *Client) GetBlockByNumber(ctx context.Context, blockNumber int64, includeTx bool) ([]byte, error)

GetBlockByNumber returns the block information according to the given block number(hex format)

func (*Client) GetBlockHashByNumber

func (c *Client) GetBlockHashByNumber(ctx context.Context, blockNumber int64) (*common.Hash, error)

GetBlockHashByNumber returns the block hash according to the given block number

func (*Client) GetBlockLimit

func (c *Client) GetBlockLimit(ctx context.Context) (*big.Int, error)

GetBlockLimit returns the blocklimit for current blocknumber

func (*Client) GetBlockNumber

func (c *Client) GetBlockNumber(ctx context.Context) (int64, error)

GetBlockNumber returns the latest block height(hex format) on a given groupID.

func (*Client) GetCallOpts

func (c *Client) GetCallOpts() *bind.CallOpts

GetCallOpts return *bind.CallOpts

func (*Client) GetChainID

func (c *Client) GetChainID(ctx context.Context) (*big.Int, error)

GetChainID returns the Chain ID of the FISCO BCOS running on the nodes.

func (*Client) GetClientVersion

func (c *Client) GetClientVersion(ctx context.Context) ([]byte, error)

GetClientVersion returns the version of FISCO BCOS running on the nodes.

func (*Client) GetCode

func (c *Client) GetCode(ctx context.Context, address common.Address) ([]byte, error)

GetCode returns the contract code according to the contract address

func (*Client) GetCompatibleVersion

func (c *Client) GetCompatibleVersion() int

GetCompatibleVersion returns the compatible version of FISCO BCOS

func (*Client) GetConsensusStatus

func (c *Client) GetConsensusStatus(ctx context.Context) ([]byte, error)

GetConsensusStatus returns the status information about the consensus algorithm on a specific groupID

func (*Client) GetContractAddress

func (c *Client) GetContractAddress(ctx context.Context, txHash common.Hash) (common.Address, error)

GetContractAddress returns a contract address according to the transaction hash

func (*Client) GetGroupID

func (c *Client) GetGroupID() *big.Int

GetGroupID returns the groupID of the client

func (*Client) GetGroupList

func (c *Client) GetGroupList(ctx context.Context) ([]byte, error)

GetGroupList returns the groupID list that the node belongs to

func (*Client) GetGroupPeers

func (c *Client) GetGroupPeers(ctx context.Context) ([]byte, error)

GetGroupPeers returns the nodes and the overser nodes list on a specific group

func (*Client) GetNodeIDList

func (c *Client) GetNodeIDList(ctx context.Context) ([]byte, error)

GetNodeIDList returns the ID information of the connected peers and itself

func (*Client) GetObserverList

func (c *Client) GetObserverList(ctx context.Context) ([]byte, error)

GetObserverList returns the list of observer nodes' ID according to the groupID

func (*Client) GetPBFTView

func (c *Client) GetPBFTView(ctx context.Context) ([]byte, error)

GetPBFTView returns the latest PBFT view(hex format) of the specific group and it will returns a wrong sentence if the consensus algorithm is not the PBFT.

func (*Client) GetPeers

func (c *Client) GetPeers(ctx context.Context) ([]byte, error)

GetPeers returns the information of the connected peers

func (*Client) GetPendingTransactions

func (c *Client) GetPendingTransactions(ctx context.Context) ([]byte, error)

GetPendingTransactions returns information of the pending transactions

func (*Client) GetPendingTxSize

func (c *Client) GetPendingTxSize(ctx context.Context) ([]byte, error)

GetPendingTxSize returns amount of the pending transactions

func (*Client) GetSealerList

func (c *Client) GetSealerList(ctx context.Context) ([]byte, error)

GetSealerList returns the list of consensus nodes' ID according to the groupID

func (*Client) GetSyncStatus

func (c *Client) GetSyncStatus(ctx context.Context) ([]byte, error)

GetSyncStatus returns the synchronization status of the group

func (*Client) GetSystemConfigByKey

func (c *Client) GetSystemConfigByKey(ctx context.Context, configKey string) ([]byte, error)

GetSystemConfigByKey returns value according to the key(only tx_count_limit, tx_gas_limit could work)

func (*Client) GetTotalTransactionCount

func (c *Client) GetTotalTransactionCount(ctx context.Context) ([]byte, error)

GetTotalTransactionCount returns the total amount of transactions and the block height at present

func (*Client) GetTransactOpts

func (c *Client) GetTransactOpts() *bind.TransactOpts

GetTransactOpts return *bind.TransactOpts

func (*Client) GetTransactionByBlockHashAndIndex

func (c *Client) GetTransactionByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, txIndex int) ([]byte, error)

GetTransactionByBlockHashAndIndex returns the transaction information according to the given block hash and transaction index

func (*Client) GetTransactionByBlockNumberAndIndex

func (c *Client) GetTransactionByBlockNumberAndIndex(ctx context.Context, blockNumber int64, txIndex int) ([]byte, error)

GetTransactionByBlockNumberAndIndex returns the transaction information according to the given block number and transaction index

func (*Client) GetTransactionByHash

func (c *Client) GetTransactionByHash(ctx context.Context, txHash common.Hash) ([]byte, error)

GetTransactionByHash returns the transaction information according to the given transaction hash

func (*Client) GetTransactionReceipt

func (c *Client) GetTransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)

GetTransactionReceipt returns the transaction receipt according to the given transaction hash

func (*Client) IsClosed added in v0.12.2

func (c *Client) IsClosed() bool

func (*Client) PendingCallContract

func (c *Client) PendingCallContract(ctx context.Context, msg ethereum.CallMsg) ([]byte, error)

PendingCallContract executes a message call transaction using the EVM. The state seen by the contract call is the pending state.

func (*Client) PendingCodeAt

func (c *Client) PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error)

PendingCodeAt returns the contract code of the given account in the pending state.

func (*Client) PublishPrivateTopic

func (c *Client) PublishPrivateTopic(topic string, publicKey []*ecdsa.PublicKey) error

func (*Client) SMCrypto

func (c *Client) SMCrypto() bool

SMCrypto returns true if use sm crypto

func (*Client) SendAMOPMsg

func (c *Client) SendAMOPMsg(topic string, data []byte) ([]byte, error)

func (*Client) SendAMOPPrivateMsg

func (c *Client) SendAMOPPrivateMsg(topic string, data []byte) ([]byte, error)

func (*Client) SendTransaction

func (c *Client) SendTransaction(ctx context.Context, tx *types.Transaction) (*types.Receipt, error)

SendTransaction injects a signed transaction into the pending pool for execution.

If the transaction was a contract creation use the TransactionReceipt method to get the contract address after the transaction has been mined.

func (*Client) SetGroupID

func (c *Client) SetGroupID(newID int)

SetGroupID sets the groupID of the client

func (*Client) SubscribeBlockNumberNotify

func (c *Client) SubscribeBlockNumberNotify(handler func(int64)) error

func (*Client) SubscribeFilterLogs

func (c *Client) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)

SubscribeFilterLogs subscribes to the results of a streaming filter query.

func (*Client) SubscribePrivateTopic

func (c *Client) SubscribePrivateTopic(topic string, privateKey *ecdsa.PrivateKey, handler func([]byte, *[]byte)) error

func (*Client) SubscribeTopic

func (c *Client) SubscribeTopic(topic string, handler func([]byte, *[]byte)) error

func (*Client) TransactionReceipt

func (c *Client) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)

TransactionReceipt returns the receipt of a transaction by transaction hash. Note that the receipt is not available for pending transactions.

func (*Client) UnsubscribeBlockNumberNotify

func (c *Client) UnsubscribeBlockNumberNotify() error

func (*Client) UnsubscribePrivateTopic

func (c *Client) UnsubscribePrivateTopic(topic string) error

func (*Client) UnsubscribeTopic

func (c *Client) UnsubscribeTopic(topic string) error

func (*Client) WaitMined

func (c *Client) WaitMined(tx *types.Transaction) (*types.Receipt, error)

WaitMined is wrapper of bind.WaitMined

Jump to

Keyboard shortcuts

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