Documentation ¶
Index ¶
- Constants
- Variables
- func NotifyOnEnqueue(queuedTx *common.QueuedTx)
- func NotifyOnReturn(queuedTx *common.QueuedTx, err error)
- type AddrLocker
- type EthTransactor
- type EthTxClient
- func (ec *EthTxClient) EstimateGas(ctx context.Context, msg ethereum.CallMsg) (*big.Int, error)
- func (ec *EthTxClient) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)
- func (ec *EthTxClient) SendTransaction(ctx context.Context, tx *types.Transaction) error
- func (ec *EthTxClient) SuggestGasPrice(ctx context.Context) (*big.Int, error)
- type Manager
- func (m *Manager) CompleteTransaction(id common.QueuedTxID, password string) (hash gethcommon.Hash, err error)
- func (m *Manager) CompleteTransactions(ids []common.QueuedTxID, password string) map[common.QueuedTxID]common.TransactionResult
- func (m *Manager) DisableNotificactions()
- func (m *Manager) DiscardTransaction(id common.QueuedTxID) error
- func (m *Manager) DiscardTransactions(ids []common.QueuedTxID) map[common.QueuedTxID]common.RawDiscardTransactionResult
- func (m *Manager) QueueTransaction(tx *common.QueuedTx) error
- func (m *Manager) SendTransactionRPCHandler(ctx context.Context, args ...interface{}) (interface{}, error)
- func (m *Manager) Start()
- func (m *Manager) Stop()
- func (m *Manager) TransactionQueue() *queue.TxQueue
- func (m *Manager) WaitForTransaction(tx *common.QueuedTx) common.TransactionResult
- type ReturnSendTransactionEvent
- type SendTransactionEvent
Constants ¶
const ( // EventTransactionQueued is triggered when send transaction request is queued EventTransactionQueued = "transaction.queued" // EventTransactionFailed is triggered when send transaction request fails EventTransactionFailed = "transaction.failed" )
const ( // SendTransactionNoErrorCode is sent when no error occurred. SendTransactionNoErrorCode = iota // SendTransactionDefaultErrorCode is every case when there is no special tx return code. SendTransactionDefaultErrorCode // SendTransactionPasswordErrorCode is sent when account failed verification. SendTransactionPasswordErrorCode // SendTransactionTimeoutErrorCode is sent when tx is timed out. SendTransactionTimeoutErrorCode // SendTransactionDiscardedErrorCode is sent when tx was discarded. SendTransactionDiscardedErrorCode )
const ( // SendTxDefaultErrorCode is sent by default, when error is not nil, but type is unknown/unexpected. SendTxDefaultErrorCode = SendTransactionDefaultErrorCode // DefaultTxSendCompletionTimeout defines how many seconds to wait before returning result in sentTransaction(). DefaultTxSendCompletionTimeout = 300 * time.Second )
Variables ¶
var ( //ErrQueuedTxTimedOut - error transaction sending timed out ErrQueuedTxTimedOut = errors.New("transaction sending timed out") //ErrQueuedTxDiscarded - error transaction discarded ErrQueuedTxDiscarded = errors.New("transaction has been discarded") )
Functions ¶
func NotifyOnEnqueue ¶
NotifyOnEnqueue returns handler that processes incoming tx queue requests
func NotifyOnReturn ¶
NotifyOnReturn returns handler that processes responses from internal tx manager
Types ¶
type AddrLocker ¶
type AddrLocker struct {
// contains filtered or unexported fields
}
AddrLocker provides locks for addresses
func (*AddrLocker) LockAddr ¶
func (l *AddrLocker) LockAddr(address common.Address)
LockAddr locks an account's mutex. This is used to prevent another tx getting the same nonce until the lock is released. The mutex prevents the (an identical nonce) from being read again during the time that the first transaction is being signed.
func (*AddrLocker) UnlockAddr ¶
func (l *AddrLocker) UnlockAddr(address common.Address)
UnlockAddr unlocks the mutex of the given account.
type EthTransactor ¶
type EthTransactor interface { PendingNonceAt(ctx context.Context, account common.Address) (uint64, error) ethereum.GasEstimator ethereum.GasPricer ethereum.TransactionSender }
EthTransactor provides methods to create transactions for ethereum network.
type EthTxClient ¶
type EthTxClient struct {
// contains filtered or unexported fields
}
EthTxClient wraps common API methods that are used to send transaction.
func NewEthTxClient ¶
func NewEthTxClient(client *rpc.Client) *EthTxClient
NewEthTxClient returns a new EthTxClient for client
func (*EthTxClient) 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 (*EthTxClient) 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 (*EthTxClient) SendTransaction ¶
func (ec *EthTxClient) SendTransaction(ctx context.Context, tx *types.Transaction) 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 (*EthTxClient) SuggestGasPrice ¶
SuggestGasPrice retrieves the currently suggested gas price to allow a timely execution of a transaction.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager provides means to manage internal Status Backend (injected into LES)
func NewManager ¶
func NewManager(nodeManager common.NodeManager, accountManager common.AccountManager) *Manager
NewManager returns a new Manager.
func (*Manager) CompleteTransaction ¶
func (m *Manager) CompleteTransaction(id common.QueuedTxID, password string) (hash gethcommon.Hash, err error)
CompleteTransaction instructs backend to complete sending of a given transaction.
func (*Manager) CompleteTransactions ¶
func (m *Manager) CompleteTransactions(ids []common.QueuedTxID, password string) map[common.QueuedTxID]common.TransactionResult
CompleteTransactions instructs backend to complete sending of multiple transactions
func (*Manager) DisableNotificactions ¶
func (m *Manager) DisableNotificactions()
DisableNotificactions turns off notifications on enqueue and return of tx. It is not thread safe and must be called only before manager is started.
func (*Manager) DiscardTransaction ¶
func (m *Manager) DiscardTransaction(id common.QueuedTxID) error
DiscardTransaction discards a given transaction from transaction queue
func (*Manager) DiscardTransactions ¶
func (m *Manager) DiscardTransactions(ids []common.QueuedTxID) map[common.QueuedTxID]common.RawDiscardTransactionResult
DiscardTransactions discards given multiple transactions from transaction queue
func (*Manager) QueueTransaction ¶
QueueTransaction puts a transaction into the queue.
func (*Manager) SendTransactionRPCHandler ¶
func (m *Manager) SendTransactionRPCHandler(ctx context.Context, args ...interface{}) (interface{}, error)
SendTransactionRPCHandler is a handler for eth_sendTransaction method. It accepts one param which is a slice with a map of transaction params.
func (*Manager) Start ¶
func (m *Manager) Start()
Start starts accepting new transactions into the queue.
func (*Manager) Stop ¶
func (m *Manager) Stop()
Stop stops accepting new transactions into the queue.
func (*Manager) TransactionQueue ¶
TransactionQueue returns a reference to the queue.
func (*Manager) WaitForTransaction ¶
func (m *Manager) WaitForTransaction(tx *common.QueuedTx) common.TransactionResult
WaitForTransaction adds a transaction to the queue and blocks until it's completed, discarded or times out.
type ReturnSendTransactionEvent ¶
type ReturnSendTransactionEvent struct { ID string `json:"id"` Args common.SendTxArgs `json:"args"` MessageID string `json:"message_id"` ErrorMessage string `json:"error_message"` ErrorCode int `json:"error_code,string"` }
ReturnSendTransactionEvent is a JSON returned whenever transaction send is returned
type SendTransactionEvent ¶
type SendTransactionEvent struct { ID string `json:"id"` Args common.SendTxArgs `json:"args"` MessageID string `json:"message_id"` }
SendTransactionEvent is a signal sent on a send transaction request