helper

package
v0.0.0-...-9f791b1 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

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

func (c *SafeEthClient) BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error)

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

func (c *SafeEthClient) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error)

HeaderByHash returns the block header with the given hash.

func (*SafeEthClient) HeaderByNumber

func (c *SafeEthClient) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)

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) NetworkID

func (c *SafeEthClient) NetworkID(ctx context.Context) (*big.Int, error)

NetworkID wrapper of NetworkID

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

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

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

func (c *SafeEthClient) SuggestGasPrice(ctx context.Context) (*big.Int, error)

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

func (c *SafeEthClient) TransactionCount(ctx context.Context, blockHash common.Hash) (uint, error)

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

Jump to

Keyboard shortcuts

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