diff options
author | Antoine A <> | 2024-03-16 02:23:06 +0100 |
---|---|---|
committer | Antoine A <> | 2024-03-16 02:23:06 +0100 |
commit | e292fa357724df8695b6110eec6e4a60c7986363 (patch) | |
tree | 417196f539625eeb8b805f8b8d9dc0c5783caf97 /bank/src/main/kotlin/tech/libeufin/bank/db/Database.kt | |
parent | e5e718622da88f8eff5474a3c7092ee51360977e (diff) | |
download | libeufin-e292fa357724df8695b6110eec6e4a60c7986363.tar.gz libeufin-e292fa357724df8695b6110eec6e4a60c7986363.tar.bz2 libeufin-e292fa357724df8695b6110eec6e4a60c7986363.zip |
Simplify error handling for microsecond overflows that never occur in practice
Diffstat (limited to 'bank/src/main/kotlin/tech/libeufin/bank/db/Database.kt')
-rw-r--r-- | bank/src/main/kotlin/tech/libeufin/bank/db/Database.kt | 23 |
1 files changed, 1 insertions, 22 deletions
diff --git a/bank/src/main/kotlin/tech/libeufin/bank/db/Database.kt b/bank/src/main/kotlin/tech/libeufin/bank/db/Database.kt index 1880b67b..19706a7b 100644 --- a/bank/src/main/kotlin/tech/libeufin/bank/db/Database.kt +++ b/bank/src/main/kotlin/tech/libeufin/bank/db/Database.kt @@ -35,25 +35,6 @@ import kotlin.math.abs private val logger: Logger = LoggerFactory.getLogger("libeufin-bank-db") -/** - * This error occurs in case the timestamp took by the bank for some - * event could not be converted in microseconds. Note: timestamp are - * taken via the Instant.now(), then converted to nanos, and then divided - * by 1000 to obtain the micros. - * - * It could be that a legitimate timestamp overflows in the process of - * being converted to micros - as described above. In the case of a timestamp, - * the fault lies to the bank, because legitimate timestamps must (at the - * time of writing!) go through the conversion to micros. - * - * On the other hand (and for the sake of completeness), in the case of a - * timestamp that was calculated after a client-submitted duration, the overflow - * lies to the client, because they must have specified a gigantic amount of time - * that overflew the conversion to micros and should simply have specified "forever". - */ -internal fun faultyTimestampByBank() = internalServerError("Bank took overflowing timestamp") -internal fun faultyDurationByClient() = badRequest("Overflowing duration, please specify 'forever' instead.") - class Database(dbConfig: String, internal val bankCurrency: String, internal val fiatCurrency: String?): DbPool(dbConfig, "libeufin_bank") { internal val notifWatcher: NotificationWatcher = NotificationWatcher(pgSource) @@ -206,7 +187,5 @@ enum class AbortResult { } fun ResultSet.getTalerTimestamp(name: String): TalerProtocolTimestamp{ - return TalerProtocolTimestamp( - getLong(name).microsToJavaInstant() ?: throw faultyTimestampByBank() - ) + return TalerProtocolTimestamp(getLong(name).asInstant()) }
\ No newline at end of file |