getTransactionsByStatusSince method
- TransactionStatus status,
- DateTime since, {
- int limit = 100,
The rows with status last updated at or after since, newest first
(updatedAt descending), at most limit of them (bead libspiffy-5bju).
A bounded feed of recently changed rows, for work that must revisit a terminal state without ever reading its whole history: ARCActor polls recently failed transactions this way, because a transaction ARC reported REJECTED can still be mined (a competing spend loses, or the report was stale) and nothing else would ever ask again. Reading every failed row the wallet ever had, on a timer, is what the window and the cap exist to prevent.
limit must be positive. Rows whose updatedAt was never stored are
read as their createdAt (the backends store it that way).
The default implementation filters getTransactionsByStatus and so is not bounded at the storage layer; the libspiffy backends override it.
Implementation
@override
Future<List<BitcoinTransaction>> getTransactionsByStatusSince(
TransactionStatus status,
DateTime since, {
int limit = 100,
}) async {
if (limit <= 0) return const [];
_ensureInitialized();
// idx_transactions_status_updated (v019): the rows of [status] updated
// in the window, newest first, capped (bead libspiffy-5bju). Rows older
// than the window are never read.
final params = <String, dynamic>{'status': status.name, 'since': since.toUtc(), 'rowLimit': limit};
final sql = '''
SELECT $_transactionColumns
FROM bitcoin_transactions
WHERE status = @status AND updated_at >= @since
ORDER BY updated_at DESC, id DESC
LIMIT @rowLimit
''';
onTransactionLookupQuery?.call(sql, params);
final result = await _pool!.execute(Sql.named(sql), parameters: params);
return result.map(_rowToTransaction).toList();
}