-
Notifications
You must be signed in to change notification settings - Fork 111
Queue and persist pending blockchain interaction #2006
Comments
The concept has undergone many changes and this description is no longer accurate. My current idea goes as follows: The queue implements the // TransactionProcessor represents a queue for transactions sent from a single ethereum account
// its purpose is to ensure there are no nonce issues and that transaction initiators are notified of the result
// notifications are guaranteed to happen even across restarts and disconnects from the ethereum backend
type TransactionProcessor interface {
// Start starts processing transactions if it is not already doing so
Start()
// Stop stops processing transactions if it is running
// It will block until processing has terminated
Stop()
// QueueRequest adds a new request to be processed
QueueRequest(request TransactionRequest)
// SetSubscriber sets subscriber as the subscriber for the specified type
SetSubscriber(ty reflect.Type, subscriber TransactionRequestSubscriber)
}
// TransactionRequest is the interface for different types of transactions
type TransactionRequest interface {
// SendTransaction should send the transaction using the backend and opts provided
// opts may be modified, however From, Nonce and Signer must be left untouched
// if the transaction is sent through other means opts.Nonce must be respected (if set to nil, the "pending" nonce must be used)
SendTransaction(backend contract.Backend, opts *bind.TransactOpts) (common.Hash, error)
} To get notified of the outcome of // TransactionRequestSubscriber needs to be implemented by structs which want to be notified for a specific TransactionRequest
// If the handler returns an error the notification does not count as delivered
type TransactionRequestSubscriber interface {
// NotifyMined gets called when the transaction was detected as successfully mined for the first time
NotifyMined(request TransactionRequest, receipt *types.Receipt) error
// NotifySendFailed gets called if sending the transaction to the network failed
NotifySendFailed(request TransactionRequest, err error) error
// NotifyTimeout gets called if the transaction did not get confirmed within the timeout
// The transaction might still get mined in the future (in that case NotifyMined will still be called) or it might be replaced by another
NotifyTimeout(request TransactionRequest) error
} To ensure requests and notifications don't get lost over restarts all requests in the queue, the status of the current transaction as well as all pending notifications are saved to the state store on any change (This implies that the |
Related: #2005 |
see #2005 (comment) |
To ensure that there are no nonce issues we want to allow at most one pending blockchain transaction at a time. This means transactions will have to be queued if another one is still pending. This queue should also be persisted, so it can resume after restarts.
Requirements:
Swap
should be able to push a transaction requests into the (FIFO) queue.Swap
should be notified somehow.Requirements that are part of other issues:
Design goals:
Swap
and theCashoutProcessor
)Related to #2005, #1929 and #1633.
The text was updated successfully, but these errors were encountered: