expirePendingTransactions method

void expirePendingTransactions (
  1. int height
)

If a pending Transaction expires, delete it and return the Transaction.amount.

Implementation

void expirePendingTransactions(int height) async {
  if (!opened) return;
  var finder = sembast.Finder(
    filter: sembast.Filter.lessThanOrEquals('expires', height),
    sortOrders: [sembast.SortOrder('expires')],
  );
  var records = await pendingStore.find(storage, finder: finder);
  for (var record in records) {
    Transaction transaction =
        transactions.find(currency.fromTransactionJson(record.value));
    if (transaction != null &&
        (transaction.height == null || transaction.height == 0)) {
      await _updateBalance(addresses[transaction.from.toJson()],
          transaction.amount + transaction.fee);
    }
    await _removePendingTransaction(record.key);
    pendingCount--;
  }
}