Documentation ¶
Overview ¶
Package client provides a client for the FISCO BCOS RPC API.
Index ¶
- Constants
- Variables
- func LoadECPrivateKeyFromPEM(path string) ([]byte, string, error)
- func LoadECPublicKeyFromPEM(path string) ([]byte, string, error)
- type Client
- func (c *Client) AsyncSendTransaction(ctx context.Context, tx *types.Transaction, contract *common.Address, ...) error
- func (c *Client) BroadcastAMOPMsg(topic string, data []byte) error
- func (c *Client) CallContract(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)
- func (c *Client) Close()
- func (c *Client) CodeAt(ctx context.Context, address common.Address, blockNumber *big.Int) ([]byte, error)
- func (c *Client) GetBlockByHash(ctx context.Context, blockHash common.Hash, onlyHeader, onlyTxHash bool) (*types.Block, error)
- func (c *Client) GetBlockByNumber(ctx context.Context, blockNumber int64, onlyHeader, onlyTxHash bool) (*types.Block, error)
- func (c *Client) GetBlockHashByNumber(ctx context.Context, blockNumber int64) (*common.Hash, error)
- func (c *Client) GetBlockNumber(ctx context.Context) (int64, error)
- func (c *Client) GetCallOpts() *bind.CallOpts
- func (c *Client) GetChainID(ctx context.Context) (string, error)
- func (c *Client) GetCode(ctx context.Context, address common.Address) ([]byte, error)
- func (c *Client) GetConsensusStatus(ctx context.Context) ([]byte, error)
- func (c *Client) GetContractAddress(ctx context.Context, txHash common.Hash) (common.Address, error)
- func (c *Client) GetGroupID() string
- func (c *Client) GetGroupInfo(ctx context.Context) ([]byte, error)
- func (c *Client) GetGroupInfoList(ctx context.Context) ([]byte, error)
- func (c *Client) GetGroupList(ctx context.Context) ([]byte, error)
- func (c *Client) GetGroupPeers(ctx context.Context) ([]byte, error)
- func (c *Client) GetNodeIDList(ctx context.Context) ([]byte, error)
- func (c *Client) GetNodeInfo(ctx context.Context, nodeId string) ([]byte, error)
- func (c *Client) GetObserverList(ctx context.Context) ([]byte, error)
- func (c *Client) GetPBFTView(ctx context.Context) ([]byte, error)
- func (c *Client) GetPeers(ctx context.Context) ([]byte, error)
- func (c *Client) GetPendingTxSize(ctx context.Context) ([]byte, error)
- func (c *Client) GetSealerList(ctx context.Context) ([]byte, error)
- func (c *Client) GetSyncStatus(ctx context.Context) (*types.SyncStatus, error)
- func (c *Client) GetSystemConfigByKey(ctx context.Context, configKey string) (*types.SystemConfig, error)
- func (c *Client) GetTotalTransactionCount(ctx context.Context) (*types.TransactionCount, error)
- func (c *Client) GetTransactOpts() *bind.TransactOpts
- func (c *Client) GetTransactionByHash(ctx context.Context, txHash common.Hash, withProof bool) (*types.TransactionDetail, error)
- func (c *Client) GetTransactionReceipt(ctx context.Context, txHash common.Hash, withProof bool) (*types.Receipt, error)
- func (c *Client) PendingCallContract(ctx context.Context, msg ethereum.CallMsg) ([]byte, error)
- func (c *Client) PendingCodeAt(ctx context.Context, address common.Address) ([]byte, error)
- func (c *Client) PublishAmopTopicMessage(ctx context.Context, topic string, data []byte, handler func([]byte, error)) error
- func (c *Client) SMCrypto() bool
- func (c *Client) SendAmopResponse(peer, seq string, data []byte) error
- func (c *Client) SendTransaction(ctx context.Context, tx *types.Transaction, contract *common.Address, ...) (*types.Receipt, error)
- func (c *Client) SetCallOpts(opts *bind.CallOpts)
- func (c *Client) SetGroupID(newID string)
- func (c *Client) SetTransactOpts(opts *bind.TransactOpts)
- func (c *Client) SubscribeAmopTopic(ctx context.Context, topic string, handler func([]byte, *[]byte)) error
- func (c *Client) SubscribeBlockNumberNotify(ctx context.Context, handler func(int64)) error
- func (c *Client) SubscribeEventLogs(ctx context.Context, eventLogParams types.EventLogParams, ...) (string, error)
- func (c *Client) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
- func (c *Client) UnSubscribeEventLogs(ctx context.Context, taskId string) error
- func (c *Client) UnsubscribeAmopTopic(topic string) error
- func (c *Client) UnsubscribeBlockNumberNotify()
- func (c *Client) WaitMined(tx *types.Transaction) (*types.Receipt, error)
- type Config
- type Connection
- func (c *Connection) BroadcastAmopMsg(topic string, data []byte)
- func (c *Connection) Call(result interface{}, method string, args ...interface{}) error
- func (c *Connection) CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error
- func (c *Connection) Close()
- func (c *Connection) GetCSDK() *csdk.CSDK
- func (c *Connection) PublishAmopTopicMessage(ctx context.Context, topic string, data []byte, handler func([]byte, error)) error
- func (c *Connection) SendAmopResponse(peer, seq string, data []byte)
- func (c *Connection) SubscribeAmopTopic(topic string, handler func(data []byte, response *[]byte)) error
- func (c *Connection) SubscribeBlockNumberNotify(handler func(int64)) error
- func (c *Connection) SubscribeEventLogs(eventLogParams types.EventLogParams, handler func(int, []types.Log)) (string, error)
- func (c *Connection) UnsubscribeAmopTopic(topic string)
- func (c *Connection) UnsubscribeBlockNumberNotify()
- func (c *Connection) UnsubscribeEventLogs(taskID string)
- type Error
- type EventLogRespResult
- type ServerCodec
Constants ¶
const (
BlockLimit int64 = 600
)
Variables ¶
Functions ¶
func LoadECPrivateKeyFromPEM ¶
LoadECPrivateKeyFromPEM reads file, divides into key and certificates
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client defines typed wrappers for the Ethereum RPC API.
func DialContext ¶
DialContext pass the context to the rpc client
func (*Client) AsyncSendTransaction ¶
func (c *Client) AsyncSendTransaction(ctx context.Context, tx *types.Transaction, contract *common.Address, input []byte, handler func(*types.Receipt, error)) error
AsyncSendTransaction send transaction async
func (*Client) BroadcastAMOPMsg ¶
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) CodeAt ¶
func (c *Client) CodeAt(ctx context.Context, address 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) GetBlockByHash ¶
func (c *Client) GetBlockByHash(ctx context.Context, blockHash common.Hash, onlyHeader, onlyTxHash bool) (*types.Block, error)
GetBlockByHash returns the block information according to the given block hash
func (*Client) GetBlockByNumber ¶
func (c *Client) GetBlockByNumber(ctx context.Context, blockNumber int64, onlyHeader, onlyTxHash bool) (*types.Block, error)
GetBlockByNumber returns the block information according to the given block number(hex format)
func (*Client) GetBlockHashByNumber ¶
GetBlockHashByNumber returns the block hash according to the given block number
func (*Client) GetBlockNumber ¶
GetBlockNumber returns the latest block height(hex format) on a given groupID.
func (*Client) GetCallOpts ¶
GetCallOpts return *bind.CallOpts
func (*Client) GetChainID ¶
GetChainID returns the Chain ID of the FISCO BCOS running on the nodes.
func (*Client) GetConsensusStatus ¶
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 ¶
GetGroupID returns the groupID of the client
func (*Client) GetGroupInfoList ¶
GetGroupInfoList returns the ID information of the connected peers and itself
func (*Client) GetGroupList ¶
GetGroupList returns the groupID list that the node belongs to
func (*Client) GetGroupPeers ¶
GetGroupPeers returns the nodes and the overser nodes list on a specific group
func (*Client) GetNodeIDList ¶
GetNodeIDList returns the ID information of the connected peers and itself
func (*Client) GetNodeInfo ¶
func (*Client) GetObserverList ¶
GetObserverList returns the list of observer nodes' ID according to the groupID
func (*Client) GetPBFTView ¶
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) GetPendingTxSize ¶
GetPendingTxSize returns amount of the pending transactions
func (*Client) GetSealerList ¶
GetSealerList returns the list of consensus nodes' ID according to the groupID
func (*Client) GetSyncStatus ¶
GetSyncStatus returns the synchronization status of the group
func (*Client) GetSystemConfigByKey ¶
func (c *Client) GetSystemConfigByKey(ctx context.Context, configKey string) (*types.SystemConfig, error)
GetSystemConfigByKey returns value according to the key(only tx_count_limit, tx_gas_limit could work)
func (*Client) GetTotalTransactionCount ¶
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) GetTransactionByHash ¶
func (c *Client) GetTransactionByHash(ctx context.Context, txHash common.Hash, withProof bool) (*types.TransactionDetail, 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, withProof bool) (*types.Receipt, error)
GetTransactionReceipt returns the transaction receipt according to the given transaction hash
func (*Client) PendingCallContract ¶
PendingCallContract executes a message call transaction using the EVM. The state seen by the contract call is the pending state.
func (*Client) PendingCodeAt ¶
PendingCodeAt returns the contract code of the given account in the pending state.
func (*Client) PublishAmopTopicMessage ¶
func (*Client) SendAmopResponse ¶
func (*Client) SendTransaction ¶
func (c *Client) SendTransaction(ctx context.Context, tx *types.Transaction, contract *common.Address, input []byte) (*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) SetCallOpts ¶
SetCallOpts set call opts
func (*Client) SetGroupID ¶
SetGroupID sets the groupID of the client
func (*Client) SetTransactOpts ¶
func (c *Client) SetTransactOpts(opts *bind.TransactOpts)
SetTransactOpts set auth
func (*Client) SubscribeAmopTopic ¶
func (c *Client) SubscribeAmopTopic(ctx context.Context, topic string, handler func([]byte, *[]byte)) error
amop
func (*Client) SubscribeBlockNumberNotify ¶
func (*Client) SubscribeEventLogs ¶
func (c *Client) SubscribeEventLogs(ctx context.Context, eventLogParams types.EventLogParams, handler func(int, []types.Log)) (string, error)
eventlog
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) UnSubscribeEventLogs ¶
func (*Client) UnsubscribeAmopTopic ¶
func (*Client) UnsubscribeBlockNumberNotify ¶
func (c *Client) UnsubscribeBlockNumberNotify()
type Config ¶
type Config struct { TLSCaFile string TLSKeyFile string TLSCertFile string TLSSmEnKeyFile string TLSSmEnCertFile string IsSMCrypto bool PrivateKey []byte GroupID string Host string Port int DisableSsl bool }
Config contains configuration items for sdk
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection represents a connection to an RPC server.
func ClientFromContext ¶
func ClientFromContext(ctx context.Context) (*Connection, bool)
ClientFromContext Connection retrieves the client from the context, if any. This can be used to perform 'reverse calls' in a handler method.
func NewConnection ¶
func NewConnection(config *Config) (*Connection, error)
func NewConnectionByFile ¶
func NewConnectionByFile(configFile, groupID string, privateKey []byte) (*Connection, error)
func (*Connection) BroadcastAmopMsg ¶
func (c *Connection) BroadcastAmopMsg(topic string, data []byte)
func (*Connection) Call ¶
func (c *Connection) Call(result interface{}, method string, args ...interface{}) error
Call performs a JSON-RPC call with the given arguments and unmarshals into result if no error occurred.
The result must be a pointer so that package json can unmarshal into it. You can also pass nil, in which case the result is ignored.
func (*Connection) CallContext ¶
func (c *Connection) CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error
CallContext performs a JSON-RPC call with the given arguments. If the context is canceled before the call has successfully returned, CallContext returns immediately.
The result must be a pointer so that package json can unmarshal into it. You can also pass nil, in which case the result is ignored.
func (*Connection) Close ¶
func (c *Connection) Close()
Close closes the client, aborting any in-flight requests.
func (*Connection) GetCSDK ¶
func (c *Connection) GetCSDK() *csdk.CSDK
func (*Connection) PublishAmopTopicMessage ¶
func (*Connection) SendAmopResponse ¶
func (c *Connection) SendAmopResponse(peer, seq string, data []byte)
func (*Connection) SubscribeAmopTopic ¶
func (c *Connection) SubscribeAmopTopic(topic string, handler func(data []byte, response *[]byte)) error
func (*Connection) SubscribeBlockNumberNotify ¶
func (c *Connection) SubscribeBlockNumberNotify(handler func(int64)) error
func (*Connection) SubscribeEventLogs ¶
func (c *Connection) SubscribeEventLogs(eventLogParams types.EventLogParams, handler func(int, []types.Log)) (string, error)
func (*Connection) UnsubscribeAmopTopic ¶
func (c *Connection) UnsubscribeAmopTopic(topic string)
func (*Connection) UnsubscribeBlockNumberNotify ¶
func (c *Connection) UnsubscribeBlockNumberNotify()
func (*Connection) UnsubscribeEventLogs ¶
func (c *Connection) UnsubscribeEventLogs(taskID string)
type EventLogRespResult ¶
type EventLogRespResult struct { LogIndex int `json:"logIndex"` TransactionIndex int `json:"transactionIndex"` TransactionHash string `json:"transactionHash"` //BlockHash string `json:"blockHash"` BlockNumber uint64 `json:"blockNumber"` Address string `json:"address"` Data string `json:"data"` Topics []string `json:"topics"` }
type ServerCodec ¶
type ServerCodec interface { Read() (msgs []*jsonrpcMessage, isBatch bool, err error) Close() // contains filtered or unexported methods }
ServerCodec implements reading, parsing and writing RPC messages for the server side of a RPC session. Implementations must be go-routine safe since the codec can be called in multiple go-routines concurrently.