Documentation
¶
Overview ¶
Package transactions is a generated GoMock package.
Index ¶
- Constants
- Variables
- func NotifyOnEnqueue(queuedTx *QueuedTx)
- func NotifyOnReturn(queuedTx *QueuedTx, err error)
- type AddrLocker
- type EthTransactor
- type EthTxClient
- func (ec *EthTxClient) EstimateGas(ctx context.Context, msg ethereum.CallMsg) (uint64, 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 string, account *account.SelectedExtKey) (hash gethcommon.Hash, err error)
- func (m *Manager) DisableNotificactions()
- func (m *Manager) DiscardTransaction(id string) error
- func (m *Manager) NotifyErrored(id string, inputError error) error
- func (m *Manager) QueueTransaction(tx *QueuedTx) error
- func (m *Manager) SendTransactionRPCHandler(ctx context.Context, args ...interface{}) (interface{}, error)
- func (m *Manager) Start(networkID uint64)
- func (m *Manager) Stop()
- func (m *Manager) TransactionQueue() *TxQueue
- func (m *Manager) WaitForTransaction(tx *QueuedTx) Result
- type MocktestRPCClientProvider
- type MocktestRPCClientProviderMockRecorder
- type QueuedTx
- type RPCClientProvider
- type Result
- type ReturnSendTransactionEvent
- type SendTransactionEvent
- type SendTxArgs
- type TxQueue
- func (q *TxQueue) Count() int
- func (q *TxQueue) Done(id string, hash gethcommon.Hash, err error) error
- func (q *TxQueue) Enqueue(tx *QueuedTx) error
- func (q *TxQueue) Get(id string) (*QueuedTx, error)
- func (q *TxQueue) Has(id string) bool
- func (q *TxQueue) LockInprogress(id string) error
- func (q *TxQueue) Remove(id string)
- func (q *TxQueue) Reset()
- func (q *TxQueue) Start()
- func (q *TxQueue) Stop()
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 )
const ( // DefaultTxQueueCap defines how many items can be queued. DefaultTxQueueCap = int(35) )
const ( // MessageIDKey is a key for message ID // This ID is required to track from which chat a given send transaction request is coming. MessageIDKey = contextKey("message_id") )
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") )
var ( // ErrQueuedTxExist - transaction was already enqueued ErrQueuedTxExist = errors.New("transaction already exist in queue") //ErrQueuedTxIDNotFound - error transaction hash not found ErrQueuedTxIDNotFound = errors.New("transaction hash not found") //ErrQueuedTxInProgress - error transaction is in progress ErrQueuedTxInProgress = errors.New("transaction is in progress") //ErrInvalidCompleteTxSender - error transaction with invalid sender ErrInvalidCompleteTxSender = errors.New("transaction can only be completed by the same account which created it") )
var (
ErrInvalidSendTxArgs = errors.New("Transaction arguments are invalid (are both 'input' and 'data' fields used?)")
)
errors
var ErrTxQueueRunFailure = errors.New("error running transaction queue")
ErrTxQueueRunFailure - error running transaction queue
Functions ¶
func NotifyOnEnqueue ¶
func NotifyOnEnqueue(queuedTx *QueuedTx)
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(rpcClientProvider RPCClientProvider) *Manager
NewManager returns a new Manager.
func (*Manager) CompleteTransaction ¶
func (m *Manager) CompleteTransaction(id string, account *account.SelectedExtKey) (hash gethcommon.Hash, err error)
CompleteTransaction instructs backend to complete sending of a given transaction.
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 ¶
DiscardTransaction discards a given transaction from transaction queue
func (*Manager) NotifyErrored ¶
NotifyErrored sends a notification for the given transaction
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) 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 ¶
WaitForTransaction adds a transaction to the queue and blocks until it's completed, discarded or times out.
type MocktestRPCClientProvider ¶
type MocktestRPCClientProvider struct {
// contains filtered or unexported fields
}
MocktestRPCClientProvider is a mock of testRPCClientProvider interface
func NewMocktestRPCClientProvider ¶
func NewMocktestRPCClientProvider(ctrl *gomock.Controller) *MocktestRPCClientProvider
NewMocktestRPCClientProvider creates a new mock instance
func (*MocktestRPCClientProvider) EXPECT ¶
func (m *MocktestRPCClientProvider) EXPECT() *MocktestRPCClientProviderMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MocktestRPCClientProvider) RPCClient ¶
func (m *MocktestRPCClientProvider) RPCClient() *rpc.Client
RPCClient mocks base method
type MocktestRPCClientProviderMockRecorder ¶
type MocktestRPCClientProviderMockRecorder struct {
// contains filtered or unexported fields
}
MocktestRPCClientProviderMockRecorder is the mock recorder for MocktestRPCClientProvider
func (*MocktestRPCClientProviderMockRecorder) RPCClient ¶
func (mr *MocktestRPCClientProviderMockRecorder) RPCClient() *gomock.Call
RPCClient indicates an expected call of RPCClient
type QueuedTx ¶
type QueuedTx struct { ID string Context context.Context Args SendTxArgs Result chan Result }
QueuedTx holds enough information to complete the queued transaction.
type RPCClientProvider ¶
RPCClientProvider is an interface that provides a way to obtain an rpc.Client.
type ReturnSendTransactionEvent ¶
type ReturnSendTransactionEvent struct { ID string `json:"id"` Args 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 SendTxArgs `json:"args"` MessageID string `json:"message_id"` }
SendTransactionEvent is a signal sent on a send transaction request
type SendTxArgs ¶
type SendTxArgs struct { From common.Address `json:"from"` To *common.Address `json:"to"` Gas *hexutil.Uint64 `json:"gas"` GasPrice *hexutil.Big `json:"gasPrice"` Value *hexutil.Big `json:"value"` Nonce *hexutil.Uint64 `json:"nonce"` // We keep both "input" and "data" for backward compatibility. // "input" is a preferred field. // see `vendor/github.com/ethereum/go-ethereum/internal/ethapi/api.go:1107` Input hexutil.Bytes `json:"input"` Data hexutil.Bytes `json:"data"` }
SendTxArgs represents the arguments to submit a new transaction into the transaction pool. This struct is based on go-ethereum's type in internal/ethapi/api.go, but we have freedom over the exact layout of this struct.
func (SendTxArgs) GetInput ¶
func (args SendTxArgs) GetInput() hexutil.Bytes
GetInput returns either Input or Data field's value dependent on what is filled.
func (SendTxArgs) Valid ¶
func (args SendTxArgs) Valid() bool
Valid checks whether this structure is filled in correctly.
type TxQueue ¶
type TxQueue struct {
// contains filtered or unexported fields
}
TxQueue is capped container that holds pending transactions
func (*TxQueue) Done ¶
Done removes transaction from queue if no error or error is not transient and notify subscribers
func (*TxQueue) LockInprogress ¶
LockInprogress returns error if transaction is already inprogress.