TransactionWorker

class TransactionWorker(scope: CoroutineScope, sequenceManager: AccountSequenceManager, capacity: Int = DEFAULT_CAPACITY, submitTransaction: suspend (UnsignedTransaction) -> AptosResult<PendingTransactionResponse>, isSequenceMismatch: (AptosError) -> Boolean = ::defaultSequenceMismatch)

Bounded, single-sender transaction pipeline.

The worker reserves sequence numbers only after dequeuing work, retries once after a recognized sequence mismatch, and never blocks callers from observing an individual submission result.

Constructors

Link copied to clipboard
constructor(scope: CoroutineScope, sequenceManager: AccountSequenceManager, capacity: Int = DEFAULT_CAPACITY, submitTransaction: suspend (UnsignedTransaction) -> AptosResult<PendingTransactionResponse>, isSequenceMismatch: (AptosError) -> Boolean = ::defaultSequenceMismatch)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Hot stream of queue, build, submit, failure, cancellation, and drain events.

Functions

Link copied to clipboard
suspend fun shutdown(mode: TransactionWorkerShutdown = TransactionWorkerShutdown.Drain)

Drains queued submissions or cancels them immediately, then waits for termination.

Link copied to clipboard
suspend fun submit(build: suspend (sequenceNumber: ULong) -> AptosResult<UnsignedTransaction>): Deferred<AptosResult<PendingTransactionResponse>>

Queues a transaction factory and returns its independently awaitable result.