Documentation
¶
Index ¶
- type SafeEthClient
- func (c *SafeEthClient) BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error)
- func (c *SafeEthClient) BlockByHash(ctx context.Context, hash common.Hash) (r1 *types.Block, err error)
- func (c *SafeEthClient) BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error)
- func (c *SafeEthClient) CallContract(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)
- func (c *SafeEthClient) Close()
- func (c *SafeEthClient) CodeAt(ctx context.Context, account common.Address, blockNumber *big.Int) ([]byte, error)
- func (c *SafeEthClient) EstimateGas(ctx context.Context, msg ethereum.CallMsg) (uint64, error)
- func (c *SafeEthClient) FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]types.Log, error)
- func (c *SafeEthClient) GenesisBlockHash(ctx context.Context) (genesisBlockHash common.Hash, err error)
- func (c *SafeEthClient) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error)
- func (c *SafeEthClient) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
- func (c *SafeEthClient) IsConnected() bool
- func (c *SafeEthClient) NetworkID(ctx context.Context) (*big.Int, error)
- func (c *SafeEthClient) NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (uint64, error)
- func (c *SafeEthClient) PendingBalanceAt(ctx context.Context, account common.Address) (*big.Int, error)
- func (c *SafeEthClient) PendingCallContract(ctx context.Context, msg ethereum.CallMsg) ([]byte, error)
- func (c *SafeEthClient) PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error)
- func (c *SafeEthClient) PendingNonceAt(ctx context.Context, account common.Address) (nonce uint64, err error)
- func (c *SafeEthClient) PendingStorageAt(ctx context.Context, account common.Address, key common.Hash) ([]byte, error)
- func (c *SafeEthClient) PendingTransactionCount(ctx context.Context) (uint, error)
- func (c *SafeEthClient) RecoverDisconnect()
- func (c *SafeEthClient) RegisterReConnectNotify(name string) <-chan struct{}
- func (c *SafeEthClient) SendTransaction(ctx context.Context, tx *types.Transaction) error
- func (c *SafeEthClient) StorageAt(ctx context.Context, account common.Address, key common.Hash, ...) ([]byte, error)
- func (c *SafeEthClient) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)
- func (c *SafeEthClient) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (ethereum.Subscription, error)
- func (c *SafeEthClient) SuggestGasPrice(ctx context.Context) (*big.Int, error)
- func (c *SafeEthClient) SyncProgress(ctx context.Context) (*ethereum.SyncProgress, error)
- func (c *SafeEthClient) TransactionByHash(ctx context.Context, hash common.Hash) (tx *types.Transaction, isPending bool, err error)
- func (c *SafeEthClient) TransactionCount(ctx context.Context, blockHash common.Hash) (uint, error)
- func (c *SafeEthClient) TransactionInBlock(ctx context.Context, blockHash common.Hash, index uint) (*types.Transaction, error)
- func (c *SafeEthClient) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
- func (c *SafeEthClient) TransactionSender(ctx context.Context, tx *types.Transaction, block common.Hash, index uint) (common.Address, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SafeEthClient ¶
type SafeEthClient struct { *ethclient.Client ReConnect map[string]chan struct{} Status netshare.Status StatusChan chan netshare.Status // contains filtered or unexported fields }
SafeEthClient how to recover from a restart of geth
func NewSafeClient ¶
func NewSafeClient(rawurl string) (*SafeEthClient, error)
NewSafeClient create safeclient
func (*SafeEthClient) BalanceAt ¶
func (c *SafeEthClient) BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error)
BalanceAt wrapper of BalanceAt
func (*SafeEthClient) BlockByHash ¶
func (c *SafeEthClient) BlockByHash(ctx context.Context, hash common.Hash) (r1 *types.Block, err error)
BlockByHash wrapper of BlockByHash
func (*SafeEthClient) BlockByNumber ¶
BlockByNumber wrapper of BlockByNumber
func (*SafeEthClient) CallContract ¶
func (c *SafeEthClient) CallContract(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)
CallContract wrapper of CallContract
func (*SafeEthClient) Close ¶
func (c *SafeEthClient) Close()
Close connection when destroy photon service
func (*SafeEthClient) CodeAt ¶
func (c *SafeEthClient) CodeAt(ctx context.Context, account common.Address, blockNumber *big.Int) ([]byte, error)
CodeAt wrapper of CodeAt
func (*SafeEthClient) EstimateGas ¶
func (c *SafeEthClient) EstimateGas(ctx context.Context, msg ethereum.CallMsg) (uint64, error)
EstimateGas wrapper of EstimateGas
func (*SafeEthClient) FilterLogs ¶
func (c *SafeEthClient) FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]types.Log, error)
FilterLogs wrapper of FilterLogs
func (*SafeEthClient) GenesisBlockHash ¶
func (c *SafeEthClient) GenesisBlockHash(ctx context.Context) (genesisBlockHash common.Hash, err error)
GenesisBlockHash :
func (*SafeEthClient) HeaderByHash ¶
HeaderByHash returns the block header with the given hash.
func (*SafeEthClient) HeaderByNumber ¶
HeaderByNumber returns a block header from the current canonical chain. If number is nil, the latest known header is returned.
func (*SafeEthClient) IsConnected ¶
func (c *SafeEthClient) IsConnected() bool
IsConnected return true when connected to eth rpc server
func (*SafeEthClient) NonceAt ¶
func (c *SafeEthClient) NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (uint64, error)
NonceAt wrapper of NonceAt
func (*SafeEthClient) PendingBalanceAt ¶
func (c *SafeEthClient) PendingBalanceAt(ctx context.Context, account common.Address) (*big.Int, error)
PendingBalanceAt wrapper of PendingBalanceAt
func (*SafeEthClient) PendingCallContract ¶
func (c *SafeEthClient) PendingCallContract(ctx context.Context, msg ethereum.CallMsg) ([]byte, error)
PendingCallContract wrapper of PendingCallContract
func (*SafeEthClient) PendingCodeAt ¶
PendingCodeAt wrapper of PendingCodeAt
func (*SafeEthClient) PendingNonceAt ¶
func (c *SafeEthClient) PendingNonceAt(ctx context.Context, account common.Address) (nonce uint64, err error)
PendingNonceAt wrapper of PendingNonceAt 考虑到短时间内并发调用合约出现nonce相同导致调用失败的问题,在这里获取可用nonce的时候,加入了缓冲机制
func (*SafeEthClient) PendingStorageAt ¶
func (c *SafeEthClient) PendingStorageAt(ctx context.Context, account common.Address, key common.Hash) ([]byte, error)
PendingStorageAt wrapper of PendingStorageAt
func (*SafeEthClient) PendingTransactionCount ¶
func (c *SafeEthClient) PendingTransactionCount(ctx context.Context) (uint, error)
PendingTransactionCount returns the total number of transactions in the pending state.
func (*SafeEthClient) RecoverDisconnect ¶
func (c *SafeEthClient) RecoverDisconnect()
RecoverDisconnect try to reconnect with geth after a restart of geth
func (*SafeEthClient) RegisterReConnectNotify ¶
func (c *SafeEthClient) RegisterReConnectNotify(name string) <-chan struct{}
RegisterReConnectNotify register notify when reconnect
func (*SafeEthClient) SendTransaction ¶
func (c *SafeEthClient) SendTransaction(ctx context.Context, tx *types.Transaction) error
SendTransaction wrapper of SendTransaction
func (*SafeEthClient) StorageAt ¶
func (c *SafeEthClient) StorageAt(ctx context.Context, account common.Address, key common.Hash, blockNumber *big.Int) ([]byte, error)
StorageAt wrapper of StorageAt
func (*SafeEthClient) SubscribeFilterLogs ¶
func (c *SafeEthClient) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)
SubscribeFilterLogs wrapper of SubscribeFilterLogs
func (*SafeEthClient) SubscribeNewHead ¶
func (c *SafeEthClient) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (ethereum.Subscription, error)
SubscribeNewHead wrapper of SubscribeNewHead
func (*SafeEthClient) SuggestGasPrice ¶
SuggestGasPrice wrapper of SuggestGasPrice
func (*SafeEthClient) SyncProgress ¶
func (c *SafeEthClient) SyncProgress(ctx context.Context) (*ethereum.SyncProgress, error)
SyncProgress wrapper of SyncProgress
func (*SafeEthClient) TransactionByHash ¶
func (c *SafeEthClient) TransactionByHash(ctx context.Context, hash common.Hash) (tx *types.Transaction, isPending bool, err error)
TransactionByHash wrapper of TransactionByHash
func (*SafeEthClient) TransactionCount ¶
TransactionCount returns the total number of transactions in the given block.
func (*SafeEthClient) TransactionInBlock ¶
func (c *SafeEthClient) TransactionInBlock(ctx context.Context, blockHash common.Hash, index uint) (*types.Transaction, error)
TransactionInBlock wrapper of TransactionInBlock
func (*SafeEthClient) TransactionReceipt ¶
func (c *SafeEthClient) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
TransactionReceipt wrappper of TransactionReceipt
func (*SafeEthClient) TransactionSender ¶
func (c *SafeEthClient) TransactionSender(ctx context.Context, tx *types.Transaction, block common.Hash, index uint) (common.Address, error)
TransactionSender wrapper of TransactionSender