Puts the ZapValue calculator inside a caching function.

pull/251/head
Vitor Pamplona 2023-03-10 10:15:32 -05:00
rodzic 57ee0ff1ff
commit 78261ccd94
1 zmienionych plików z 7 dodań i 2 usunięć

Wyświetl plik

@ -33,12 +33,17 @@ class LnZapEvent(
}
override fun amount(): BigDecimal? {
return lnInvoice()?.let { LnInvoiceUtil.getAmountInSats(it) }
return amount
}
// Keeps this as a field because it's a heavier function used everywhere.
val amount by lazy {
lnInvoice()?.let { LnInvoiceUtil.getAmountInSats(it) }
try {
lnInvoice()?.let { LnInvoiceUtil.getAmountInSats(it) }
} catch (e: Exception) {
Log.e("LnZapEvent", "Failed to Parse LnInvoice ${description()}", e)
null
}
}
override fun containedPost(): Event? = try {