diff options
Diffstat (limited to 'nexus')
3 files changed, 10 insertions, 20 deletions
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Log.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Log.kt index 1367c97c..fa74c791 100644 --- a/nexus/src/main/kotlin/tech/libeufin/nexus/Log.kt +++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Log.kt @@ -58,7 +58,7 @@ class FileLogger(path: String?) { // Subdir based on current day. val now = Instant.now() val asUtcDate = LocalDate.ofInstant(now, ZoneId.of("UTC")) - val nowMs = now.toDbMicros() + val nowMs = now.micros() // Creating the combined dir. val subDir = dir.resolve("${asUtcDate.year}-${asUtcDate.monthValue}-${asUtcDate.dayOfMonth}").resolve("fetch") subDir.createDirectories() @@ -86,7 +86,7 @@ class FileLogger(path: String?) { // Subdir based on current day. val now = Instant.now() val asUtcDate = LocalDate.ofInstant(now, ZoneId.of("UTC")) - val nowMs = now.toDbMicros() + val nowMs = now.micros() // Creating the combined dir. val subDir = dir.resolve("${asUtcDate.year}-${asUtcDate.monthValue}-${asUtcDate.dayOfMonth}").resolve("submit") subDir.createDirectories() diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/db/InitiatedDAO.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/db/InitiatedDAO.kt index eba3c78a..162fddee 100644 --- a/nexus/src/main/kotlin/tech/libeufin/nexus/db/InitiatedDAO.kt +++ b/nexus/src/main/kotlin/tech/libeufin/nexus/db/InitiatedDAO.kt @@ -48,10 +48,7 @@ class InitiatedDAO(private val db: Database) { stmt.setInt(2, paymentData.amount.frac) stmt.setString(3, paymentData.wireTransferSubject) stmt.setString(4, paymentData.creditPaytoUri.toString()) - val initiationTime = paymentData.initiationTime.toDbMicros() ?: run { - throw Exception("Initiation time could not be converted to microseconds for the database.") - } - stmt.setLong(5, initiationTime) + stmt.setLong(5, paymentData.initiationTime.micros()) stmt.setString(6, paymentData.requestUid) if (stmt.executeUpdateViolation()) return@conn PaymentInitiationResult.SUCCESS @@ -73,7 +70,7 @@ class InitiatedDAO(private val db: Database) { ,submission_counter = submission_counter + 1 WHERE initiated_outgoing_transaction_id = ? """) - stmt.setLong(1, now.toDbMicros()!!) + stmt.setLong(1, now.micros()) stmt.setString(2, orderId) stmt.setLong(3, id) stmt.execute() @@ -93,7 +90,7 @@ class InitiatedDAO(private val db: Database) { ,submission_counter = submission_counter + 1 WHERE initiated_outgoing_transaction_id = ? """) - stmt.setLong(1, now.toDbMicros()!!) + stmt.setLong(1, now.micros()) stmt.setString(2, msg) stmt.setLong(3, id) stmt.execute() @@ -174,10 +171,7 @@ class InitiatedDAO(private val db: Database) { suspend fun submittable(currency: String): List<InitiatedPayment> = db.conn { conn -> fun extract(it: ResultSet): InitiatedPayment { val rowId = it.getLong("initiated_outgoing_transaction_id") - val initiationTime = it.getLong("initiation_time").microsToJavaInstant() - if (initiationTime == null) { // nexus fault - throw Exception("Found invalid timestamp at initiated payment with ID: $rowId") - } + val initiationTime = it.getLong("initiation_time").asInstant() return InitiatedPayment( id = it.getLong("initiated_outgoing_transaction_id"), amount = it.getAmount("amount", currency), diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/db/PaymentDAO.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/db/PaymentDAO.kt index 2e315f38..2730a437 100644 --- a/nexus/src/main/kotlin/tech/libeufin/nexus/db/PaymentDAO.kt +++ b/nexus/src/main/kotlin/tech/libeufin/nexus/db/PaymentDAO.kt @@ -38,8 +38,7 @@ class PaymentDAO(private val db: Database) { SELECT out_tx_id, out_initiated, out_found FROM register_outgoing((?,?)::taler_amount,?,?,?,?) """) - val executionTime = paymentData.executionTime.toDbMicros() - ?: throw Exception("Could not convert outgoing payment execution_time to microseconds") + val executionTime = paymentData.executionTime.micros() stmt.setLong(1, paymentData.amount.value) stmt.setInt(2, paymentData.amount.frac) stmt.setString(3, paymentData.wireTransferSubject) @@ -72,10 +71,8 @@ class PaymentDAO(private val db: Database) { SELECT out_found, out_tx_id, out_bounce_id FROM register_incoming_and_bounce((?,?)::taler_amount,?,?,?,?,(?,?)::taler_amount,?) """) - val refundTimestamp = now.toDbMicros() - ?: throw Exception("Could not convert refund execution time from Instant.now() to microsends.") - val executionTime = paymentData.executionTime.toDbMicros() - ?: throw Exception("Could not convert payment execution time from Instant to microseconds.") + val refundTimestamp = now.micros() + val executionTime = paymentData.executionTime.micros() stmt.setLong(1, paymentData.amount.value) stmt.setInt(2, paymentData.amount.frac) stmt.setString(3, paymentData.wireTransferSubject) @@ -109,8 +106,7 @@ class PaymentDAO(private val db: Database) { SELECT out_found, out_tx_id FROM register_incoming_and_talerable((?,?)::taler_amount,?,?,?,?,?) """) - val executionTime = paymentData.executionTime.toDbMicros() - ?: throw Exception("Could not convert payment execution time from Instant to microseconds.") + val executionTime = paymentData.executionTime.micros() stmt.setLong(1, paymentData.amount.value) stmt.setInt(2, paymentData.amount.frac) stmt.setString(3, paymentData.wireTransferSubject) |