Clean up and changelog update

This commit is contained in:
Lukas Korba 2025-02-17 09:05:29 +01:00
parent c6a234ff6e
commit fb093cd04f
2 changed files with 26 additions and 16 deletions

View File

@ -6,6 +6,9 @@ and this library adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
# Unreleased
## Updated
- Methods returning an array of `ZcashTransaction.Overview` try to evaluate transaction's missing blockTime. This typically applies to an expired transaction.
# 2.2.8 - 2025-01-10
## Added

View File

@ -47,6 +47,26 @@ class TransactionSQLDAO: TransactionRepository {
true
}
func resolveMissingBlockTimes(for transactions: [ZcashTransaction.Overview]) async throws -> [ZcashTransaction.Overview] {
var transactionsCopy = transactions
for i in 0..<transactions.count {
let transaction = transactions[i]
guard transaction.blockTime == nil else {
continue
}
if let expiryHeight = transaction.expiryHeight {
if let block = try await blockForHeight(expiryHeight) {
transactionsCopy[i].blockTime = TimeInterval(block.time)
}
}
}
return transactionsCopy
}
@DBActor
func fetchTxidsWithMemoContaining(searchTerm: String) async throws -> [Data] {
let query = transactionsView
@ -101,22 +121,9 @@ class TransactionSQLDAO: TransactionRepository {
.filterQueryFor(kind: kind)
.limit(limit, offset: offset)
var transactions: [ZcashTransaction.Overview] = try await execute(query) { try ZcashTransaction.Overview(row: $0) }
// Enhance the timestamp for unmined & expired transactions
for i in 0..<transactions.count {
let transaction = transactions[i]
if transaction.minedHeight == nil {
if let expiryHeight = transaction.expiryHeight {
if let block = try await blockForHeight(expiryHeight) {
transactions[i].blockTime = TimeInterval(block.time)
}
}
}
}
return transactions
let transactions: [ZcashTransaction.Overview] = try await execute(query) { try ZcashTransaction.Overview(row: $0) }
return try await resolveMissingBlockTimes(for: transactions)
}
func find(in range: CompactBlockRange, limit: Int, kind: TransactionKind) async throws -> [ZcashTransaction.Overview] {