Documentation ¶
Overview ¶
Package ethclient provides a client for the Ethereum RPC API.
Index ¶
- Constants
- type Client
- func (ec *Client) AcceptProposalForAdmin(ctx context.Context, fullNodeId string, from common.Address) (string, error)
- func (ec *Client) AcceptProposalForCommon(ctx context.Context, fullNodeId string, from common.Address) (string, error)
- func (ec *Client) AcceptProposalForExit(ctx context.Context, fullNodeId string, from common.Address) (string, error)
- func (ec *Client) AcceptProposalForJoin(ctx context.Context, fullNodeId string, from common.Address) (string, error)
- func (ec *Client) AddPeer(ctx context.Context, url string, from common.Address) (bool, error)
- func (ec *Client) BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error)
- func (ec *Client) BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error)
- func (ec *Client) BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error)
- func (ec *Client) CallContract(ctx context.Context, msg simplechain.CallMsg, blockNumber *big.Int) ([]byte, error)
- func (ec *Client) ChainID(ctx context.Context) (*big.Int, error)
- func (ec *Client) Close()
- func (ec *Client) CodeAt(ctx context.Context, account common.Address, blockNumber *big.Int) ([]byte, error)
- func (ec *Client) EstimateGas(ctx context.Context, msg simplechain.CallMsg) (uint64, error)
- func (ec *Client) Exit(ctx context.Context, from common.Address) (string, error)
- func (ec *Client) FilterLogs(ctx context.Context, q simplechain.FilterQuery) ([]types.Log, error)
- func (ec *Client) GetAdminCount(ctx context.Context) (int, error)
- func (ec *Client) GetAllStatingRecord(ctx context.Context, from common.Address) (string, error)
- func (ec *Client) GetContractAbi(ctx context.Context, contractName string, from common.Address) (string, error)
- func (ec *Client) GetNodeByRole(ctx context.Context, role *big.Int, from common.Address) (string, error)
- func (ec *Client) GetNodeInfo(ctx context.Context, fullNodeId string, from common.Address) (*NodeInfo, error)
- func (ec *Client) GetNodeInfoByName(ctx context.Context, nodeName string, from common.Address) (string, error)
- func (ec *Client) GetNodeRole(ctx context.Context, fullNodeId string, from common.Address) (*big.Int, error)
- func (ec *Client) GetPermissionContractAddress(ctx context.Context) (string, error)
- func (ec *Client) GetPoolNonce(ctx context.Context, account common.Address) (uint64, error)
- func (ec *Client) GetSigners(ctx context.Context, number *big.Int) ([]common.Address, error)
- func (ec *Client) GetSnapshot(ctx context.Context, number *big.Int) (*clique.Snapshot, error)
- func (ec *Client) GetStateMap(ctx context.Context, fullNodeId string, opCode string, from common.Address) (*VoteStats, error)
- func (ec *Client) GetStoreContractAddress(ctx context.Context) (string, error)
- func (ec *Client) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error)
- func (ec *Client) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
- func (ec *Client) InitFinish(ctx context.Context, from common.Address) (string, error)
- func (ec *Client) IsAdmin(ctx context.Context, fullNodeId string, from common.Address) (bool, error)
- func (ec *Client) IsNetworkInitFinished(ctx context.Context) (bool, error)
- func (ec *Client) MakeProposalForAdmin(ctx context.Context, fullNodeId string, from common.Address) (string, error)
- func (ec *Client) MakeProposalForCommon(ctx context.Context, fullNodeId string, from common.Address) (string, error)
- func (ec *Client) MakeProposalForExit(ctx context.Context, fullNodeId string, from common.Address) (string, error)
- func (ec *Client) MakeProposalForJoin(ctx context.Context, fullNodeId string, nodeName string, ...) (string, error)
- func (ec *Client) NetworkID(ctx context.Context) (*big.Int, error)
- func (ec *Client) NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (uint64, error)
- func (ec *Client) PendingBalanceAt(ctx context.Context, account common.Address) (*big.Int, error)
- func (ec *Client) PendingBlock(ctx context.Context) (uint64, error)
- func (ec *Client) PendingCallContract(ctx context.Context, msg simplechain.CallMsg) ([]byte, error)
- func (ec *Client) PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error)
- func (ec *Client) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)
- func (ec *Client) PendingStorageAt(ctx context.Context, account common.Address, key common.Hash) ([]byte, error)
- func (ec *Client) PendingTransactionCount(ctx context.Context) (uint, error)
- func (ec *Client) Propose(ctx context.Context, address common.Address, auth bool) error
- func (ec *Client) RejectProposalForAdmin(ctx context.Context, fullNodeId string, from common.Address) (string, error)
- func (ec *Client) RejectProposalForCommon(ctx context.Context, fullNodeId string, from common.Address) (string, error)
- func (ec *Client) RejectProposalForExit(ctx context.Context, fullNodeId string, from common.Address) (string, error)
- func (ec *Client) RejectProposalForJoin(ctx context.Context, fullNodeId string, from common.Address) (string, error)
- func (ec *Client) RemovePeer(ctx context.Context, url string) (bool, error)
- func (ec *Client) SendCertificateRevocationList(ctx context.Context, content, signature []byte) error
- func (ec *Client) SendTransaction(ctx context.Context, tx *types.Transaction) error
- func (ec *Client) SetAdminNode(ctx context.Context, fullNodeId string, nodeName string, ...) (string, error)
- func (ec *Client) SetPermissionContractAddress(ctx context.Context, addr common.Address) (bool, error)
- func (ec *Client) SetStoreContractAddress(ctx context.Context, addr common.Address) (bool, error)
- func (ec *Client) StorageAt(ctx context.Context, account common.Address, key common.Hash, ...) ([]byte, error)
- func (ec *Client) StoreContractAbi(ctx context.Context, contractAddress common.Address, contractName string, ...) (string, error)
- func (ec *Client) SubscribeFilterLogs(ctx context.Context, q simplechain.FilterQuery, ch chan<- types.Log) (simplechain.Subscription, error)
- func (ec *Client) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (simplechain.Subscription, error)
- func (ec *Client) SuggestGasPrice(ctx context.Context) (*big.Int, error)
- func (ec *Client) SuggestGasTipCap(ctx context.Context) (*big.Int, error)
- func (ec *Client) SyncProgress(ctx context.Context) (*simplechain.SyncProgress, error)
- func (ec *Client) TransactionByHash(ctx context.Context, hash common.Hash) (tx *types.Transaction, isPending bool, err error)
- func (ec *Client) TransactionCount(ctx context.Context, blockHash common.Hash) (uint, error)
- func (ec *Client) TransactionInBlock(ctx context.Context, blockHash common.Hash, index uint) (*types.Transaction, error)
- func (ec *Client) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
- func (ec *Client) TransactionSender(ctx context.Context, tx *types.Transaction, block common.Hash, index uint) (common.Address, error)
- func (ec *Client) UpdateNodeInfo(ctx context.Context, from common.Address, ip string, port string) (string, error)
- type NodeInfo
- type VoteStats
Constants ¶
const ( JoinAction string = "join" //加入网络 UpgradeAction string = "upgrade" //升级操作 DemoteAction string = "demote" //降级操作 NetworkExitAction string = "network_exit" //退出网络 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client defines typed wrappers for the Ethereum RPC API.
func DialContext ¶
func (*Client) AcceptProposalForAdmin ¶
func (ec *Client) AcceptProposalForAdmin(ctx context.Context, fullNodeId string, from common.Address) (string, error)
AcceptProposalForAdmin 接受成为管理节点提案
func (*Client) AcceptProposalForCommon ¶
func (ec *Client) AcceptProposalForCommon(ctx context.Context, fullNodeId string, from common.Address) (string, error)
AcceptProposalForCommon 接受成为普通节点提案
func (*Client) AcceptProposalForExit ¶
func (ec *Client) AcceptProposalForExit(ctx context.Context, fullNodeId string, from common.Address) (string, error)
AcceptProposalForExit 接受节点退出联盟提案
func (*Client) AcceptProposalForJoin ¶
func (ec *Client) AcceptProposalForJoin(ctx context.Context, fullNodeId string, from common.Address) (string, error)
AcceptProposalForJoin 接受加入联盟提案
func (*Client) BalanceAt ¶
func (ec *Client) BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error)
BalanceAt returns the wei balance of the given account. The block number can be nil, in which case the balance is taken from the latest known block.
func (*Client) BlockByHash ¶
BlockByHash returns the given full block.
Note that loading full blocks requires two requests. Use HeaderByHash if you don't need all transactions or uncle headers.
func (*Client) BlockByNumber ¶
BlockByNumber returns a block from the current canonical chain. If number is nil, the latest known block is returned.
Note that loading full blocks requires two requests. Use HeaderByNumber if you don't need all transactions or uncle headers.
func (*Client) CallContract ¶
func (ec *Client) CallContract(ctx context.Context, msg simplechain.CallMsg, blockNumber *big.Int) ([]byte, error)
CallContract executes a message call transaction, which is directly executed in the VM of the node, but never mined into the blockchain.
blockNumber selects the block height at which the call runs. It can be nil, in which case the code is taken from the latest known block. Note that state from very old blocks might not be available.
func (*Client) CodeAt ¶
func (ec *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) EstimateGas ¶
EstimateGas tries to estimate the gas needed to execute a specific transaction based on the current pending state of the backend blockchain. There is no guarantee that this is the true gas limit requirement as other transactions may be added or removed by miners, but it should provide a basis for setting a reasonable default.
func (*Client) FilterLogs ¶
FilterLogs executes a filter query.
func (*Client) GetAllStatingRecord ¶
GetAllStatingRecord 获取正在进行的统计记录
func (*Client) GetContractAbi ¶
func (ec *Client) GetContractAbi(ctx context.Context, contractName string, from common.Address) (string, error)
GetContractAbi 根据合约名称获取合约的abi
func (*Client) GetNodeByRole ¶
func (ec *Client) GetNodeByRole(ctx context.Context, role *big.Int, from common.Address) (string, error)
GetNodeByRole 根据角色获取节点 check pass
func (*Client) GetNodeInfo ¶
func (ec *Client) GetNodeInfo(ctx context.Context, fullNodeId string, from common.Address) (*NodeInfo, error)
GetNodeInfo 获取节点信息 check pass
func (*Client) GetNodeInfoByName ¶
func (ec *Client) GetNodeInfoByName(ctx context.Context, nodeName string, from common.Address) (string, error)
GetNodeInfoByName 根据节点名称获取节点信息
func (*Client) GetNodeRole ¶
func (ec *Client) GetNodeRole(ctx context.Context, fullNodeId string, from common.Address) (*big.Int, error)
GetNodeRole 获取节点的角色
func (*Client) GetPermissionContractAddress ¶
GetPermissionContractAddress 获取权限合约地址 check pass
func (*Client) GetPoolNonce ¶
func (*Client) GetSigners ¶
func (*Client) GetSnapshot ¶
func (*Client) GetStateMap ¶
func (ec *Client) GetStateMap(ctx context.Context, fullNodeId string, opCode string, from common.Address) (*VoteStats, error)
GetStateMap 获取节点申请的统计信息
func (*Client) GetStoreContractAddress ¶
GetStoreContractAddress 获取存储abi合约地址 check pass
func (*Client) HeaderByHash ¶
HeaderByHash returns the block header with the given hash.
func (*Client) HeaderByNumber ¶
HeaderByNumber returns a block header from the current canonical chain. If number is nil, the latest known header is returned.
func (*Client) InitFinish ¶
InitFinish 完成联盟网络初始化
func (*Client) IsAdmin ¶
func (ec *Client) IsAdmin(ctx context.Context, fullNodeId string, from common.Address) (bool, error)
IsAdmin 是否是管理节点 check pass
func (*Client) IsNetworkInitFinished ¶
IsNetworkInitFinished 联盟初始化网络是否完成
func (*Client) MakeProposalForAdmin ¶
func (ec *Client) MakeProposalForAdmin(ctx context.Context, fullNodeId string, from common.Address) (string, error)
MakeProposalForAdmin 发起成为管理节点提案
func (*Client) MakeProposalForCommon ¶
func (ec *Client) MakeProposalForCommon(ctx context.Context, fullNodeId string, from common.Address) (string, error)
MakeProposalForCommon 发起成为普通节点提案
func (*Client) MakeProposalForExit ¶
func (ec *Client) MakeProposalForExit(ctx context.Context, fullNodeId string, from common.Address) (string, error)
MakeProposalForExit 发起节点退出联盟提案
func (*Client) MakeProposalForJoin ¶
func (ec *Client) MakeProposalForJoin(ctx context.Context, fullNodeId string, nodeName string, nodeAddress common.Address, from common.Address) (string, error)
MakeProposalForJoin 发起加入联盟提案
func (*Client) NetworkID ¶
NetworkID returns the network ID (also known as the chain ID) for this chain.
func (*Client) NonceAt ¶
func (ec *Client) NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (uint64, error)
NonceAt returns the account nonce of the given account. The block number can be nil, in which case the nonce is taken from the latest known block.
func (*Client) PendingBalanceAt ¶
PendingBalanceAt returns the wei balance of the given account in the pending state.
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) PendingNonceAt ¶
PendingNonceAt returns the account nonce of the given account in the pending state. This is the nonce that should be used for the next transaction.
func (*Client) PendingStorageAt ¶
func (ec *Client) PendingStorageAt(ctx context.Context, account common.Address, key common.Hash) ([]byte, error)
PendingStorageAt returns the value of key in the contract storage of the given account in the pending state.
func (*Client) PendingTransactionCount ¶
PendingTransactionCount returns the total number of transactions in the pending state.
func (*Client) RejectProposalForAdmin ¶
func (ec *Client) RejectProposalForAdmin(ctx context.Context, fullNodeId string, from common.Address) (string, error)
RejectProposalForAdmin 拒绝成为管理节点提案
func (*Client) RejectProposalForCommon ¶
func (ec *Client) RejectProposalForCommon(ctx context.Context, fullNodeId string, from common.Address) (string, error)
RejectProposalForCommon 拒绝成为普通节点提案
func (*Client) RejectProposalForExit ¶
func (ec *Client) RejectProposalForExit(ctx context.Context, fullNodeId string, from common.Address) (string, error)
RejectProposalForExit 拒绝节点退出联盟提案
func (*Client) RejectProposalForJoin ¶
func (ec *Client) RejectProposalForJoin(ctx context.Context, fullNodeId string, from common.Address) (string, error)
RejectProposalForJoin 拒绝加入联盟提案
func (*Client) RemovePeer ¶
RemovePeer 移除节点
func (*Client) SendCertificateRevocationList ¶
func (*Client) SendTransaction ¶
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) SetAdminNode ¶
func (ec *Client) SetAdminNode(ctx context.Context, fullNodeId string, nodeName string, address common.Address, from common.Address) (string, error)
SetAdminNode 设置给定的节点成为管理节点 在联盟网络初始化完成之前进行
func (*Client) SetPermissionContractAddress ¶
func (ec *Client) SetPermissionContractAddress(ctx context.Context, addr common.Address) (bool, error)
SetPermissionContractAddress 设置权限合约地址 check pass
func (*Client) SetStoreContractAddress ¶
SetStoreContractAddress 设置存储合约的地址 check pass
func (*Client) StorageAt ¶
func (ec *Client) StorageAt(ctx context.Context, account common.Address, key common.Hash, blockNumber *big.Int) ([]byte, error)
StorageAt returns the value of key in the contract storage of the given account. The block number can be nil, in which case the value is taken from the latest known block.
func (*Client) StoreContractAbi ¶
func (ec *Client) StoreContractAbi(ctx context.Context, contractAddress common.Address, contractName string, abi string, from common.Address) (string, error)
StoreContractAbi 保存合约的abi
func (*Client) SubscribeFilterLogs ¶
func (ec *Client) SubscribeFilterLogs(ctx context.Context, q simplechain.FilterQuery, ch chan<- types.Log) (simplechain.Subscription, error)
SubscribeFilterLogs subscribes to the results of a streaming filter query.
func (*Client) SubscribeNewHead ¶
func (ec *Client) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (simplechain.Subscription, error)
SubscribeNewHead subscribes to notifications about the current blockchain head on the given channel.
func (*Client) SuggestGasPrice ¶
SuggestGasPrice retrieves the currently suggested gas price to allow a timely execution of a transaction.
func (*Client) SuggestGasTipCap ¶
SuggestGasTipCap retrieves the currently suggested gas tip cap after 1559 to allow a timely execution of a transaction.
func (*Client) SyncProgress ¶
SyncProgress retrieves the current progress of the sync algorithm. If there's no sync currently running, it returns nil.
func (*Client) TransactionByHash ¶
func (ec *Client) TransactionByHash(ctx context.Context, hash common.Hash) (tx *types.Transaction, isPending bool, err error)
TransactionByHash returns the transaction with the given hash.
func (*Client) TransactionCount ¶
TransactionCount returns the total number of transactions in the given block.
func (*Client) TransactionInBlock ¶
func (ec *Client) TransactionInBlock(ctx context.Context, blockHash common.Hash, index uint) (*types.Transaction, error)
TransactionInBlock returns a single transaction at index in the given block.
func (*Client) TransactionReceipt ¶
func (ec *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) TransactionSender ¶
func (ec *Client) TransactionSender(ctx context.Context, tx *types.Transaction, block common.Hash, index uint) (common.Address, error)
TransactionSender returns the sender address of the given transaction. The transaction must be known to the remote node and included in the blockchain at the given block and index. The sender is the one derived by the protocol at the time of inclusion.
There is a fast-path for transactions retrieved by TransactionByHash and TransactionInBlock. Getting their sender address can be done without an RPC interaction.