From 96da0a9beaa92597bd4abdd74dce7c3098fbb86d Mon Sep 17 00:00:00 2001 From: Kevin Gorham Date: Thu, 29 Jul 2021 13:18:55 -0400 Subject: [PATCH] New: Squelch a few noisy logs. --- .../cash/z/ecc/android/sdk/tool/SaplingParamTool.kt | 6 +++--- .../sdk/transaction/PersistentTransactionManager.kt | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/cash/z/ecc/android/sdk/tool/SaplingParamTool.kt b/src/main/java/cash/z/ecc/android/sdk/tool/SaplingParamTool.kt index b016fd24..582fd0bd 100644 --- a/src/main/java/cash/z/ecc/android/sdk/tool/SaplingParamTool.kt +++ b/src/main/java/cash/z/ecc/android/sdk/tool/SaplingParamTool.kt @@ -28,7 +28,7 @@ class SaplingParamTool { ZcashSdk.OUTPUT_PARAM_FILE_NAME ).forEach { paramFileName -> if (!File(destinationDir, paramFileName).exists()) { - twig("ERROR: $paramFileName not found at location: $destinationDir") + twig("WARNING: $paramFileName not found at location: $destinationDir") hadError = true } } @@ -63,10 +63,10 @@ class SaplingParamTool { val request = Request.Builder().url(url).build() val response = client.newCall(request).execute() if (response.isSuccessful) { - twig("fetch succeeded") + twig("fetch succeeded", -1) val file = File(destinationDir, paramFileName) if (file.parentFile.exists()) { - twig("directory exists!") + twig("directory exists!", -1) } else { twig("directory did not exist attempting to make it") file.parentFile.mkdirs() diff --git a/src/main/java/cash/z/ecc/android/sdk/transaction/PersistentTransactionManager.kt b/src/main/java/cash/z/ecc/android/sdk/transaction/PersistentTransactionManager.kt index eb902979..74fe43ed 100644 --- a/src/main/java/cash/z/ecc/android/sdk/transaction/PersistentTransactionManager.kt +++ b/src/main/java/cash/z/ecc/android/sdk/transaction/PersistentTransactionManager.kt @@ -120,7 +120,7 @@ class PersistentTransactionManager( tx.accountIndex ) twig("successfully encoded transaction!") - safeUpdate("updating transaction encoding") { + safeUpdate("updating transaction encoding", -1) { updateEncoding(tx.id, encodedTx.raw, encodedTx.txId, encodedTx.expiryHeight) } } catch (t: Throwable) { @@ -131,7 +131,7 @@ class PersistentTransactionManager( updateError(tx.id, message, ERROR_ENCODING) } } finally { - safeUpdate("incrementing transaction encodeAttempts (from: ${tx.encodeAttempts})") { + safeUpdate("incrementing transaction encodeAttempts (from: ${tx.encodeAttempts})", -1) { updateEncodeAttempts(tx.id, max(1, tx.encodeAttempts + 1)) tx = findById(tx.id)!! } @@ -189,7 +189,7 @@ class PersistentTransactionManager( tx.isFailedEncoding() -> twig("Warning: this transaction will not be submitted because it failed to be encoded.") tx.isCancelled() -> twig("Warning: ignoring cancelled transaction with id ${tx.id}. We will not submit it to the network because it has been cancelled.") else -> { - twig("submitting transaction with memo: ${tx.memo} amount: ${tx.value}") + twig("submitting transaction with memo: ${tx.memo} amount: ${tx.value}", -1) val response = service.submitTransaction(tx.raw) val error = response.errorCode < 0 twig( @@ -197,7 +197,7 @@ class PersistentTransactionManager( " response: ${response.errorCode}: ${response.errorMessage}" ) - safeUpdate("updating submitted transaction (hadError: $error)") { + safeUpdate("updating submitted transaction (hadError: $error)", -1) { updateError(tx.id, if (error) response.errorMessage else null, response.errorCode) updateSubmitAttempts(tx.id, max(1, tx.submitAttempts + 1)) } @@ -214,7 +214,7 @@ class PersistentTransactionManager( updateSubmitAttempts(tx.id, max(1, tx.submitAttempts + 1)) } } finally { - safeUpdate("fetching latest tx info") { + safeUpdate("fetching latest tx info", -1) { tx = findById(tx.id)!! } } @@ -281,7 +281,7 @@ class PersistentTransactionManager( * happen within a try/catch block, surrounded by logging. So this helps with that while also * ensuring that no other coroutines are concurrently interacting with the DAO. */ - private suspend fun safeUpdate(logMessage: String = "", block: suspend PendingTransactionDao.() -> R): R? { + private suspend fun safeUpdate(logMessage: String = "", priority: Int = 0, block: suspend PendingTransactionDao.() -> R): R? { return try { twig(logMessage) pendingTransactionDao { block() }