diff --git a/service/src/main/kotlin/io/provenance/explorer/service/async/BlockAndTxProcessor.kt b/service/src/main/kotlin/io/provenance/explorer/service/async/BlockAndTxProcessor.kt index b632670c..2f98f509 100644 --- a/service/src/main/kotlin/io/provenance/explorer/service/async/BlockAndTxProcessor.kt +++ b/service/src/main/kotlin/io/provenance/explorer/service/async/BlockAndTxProcessor.kt @@ -254,11 +254,11 @@ class AsyncCachingV2( if (pullFromDb) { transaction { TxCacheRecord.findByHeight(blockHeight) - .map { addTxToCacheWithTimestamp(it.txV2, blockTime, proposerRec) } + .map { processAndSaveTransactionData(it.txV2, blockTime.toDateTime(), proposerRec) } } } else { runBlocking { txClient.getTxsByHeight(blockHeight, txCount) } - .map { addTxToCacheWithTimestamp(it, blockTime, proposerRec) } + .map { processAndSaveTransactionData(it, blockTime.toDateTime(), proposerRec) } } } catch (e: Exception) { logger.error("Failed to retrieve transactions at block: $blockHeight error: ${e.message}", e) @@ -266,15 +266,8 @@ class AsyncCachingV2( listOf() } - fun addTxToCacheWithTimestamp( - res: ServiceOuterClass.GetTxResponse, - blockTime: Timestamp, - proposerRec: BlockProposer - ) = - addTxToCache(res, blockTime.toDateTime(), proposerRec) - // Function that saves all the things under a transaction - fun addTxToCache( + fun processAndSaveTransactionData( res: ServiceOuterClass.GetTxResponse, blockTime: DateTime, proposerRec: BlockProposer @@ -282,6 +275,7 @@ class AsyncCachingV2( val tx = TxCacheRecord.buildInsert(res, blockTime) val txUpdate = TxUpdate(tx) val txInfo = TxData(proposerRec.blockHeight, null, res.txResponse.txhash, blockTime) + saveMessages(txInfo, res, txUpdate) saveTxFees(res, txInfo, txUpdate, proposerRec) val addrs = saveAddresses(txInfo, res, txUpdate) @@ -293,6 +287,7 @@ class AsyncCachingV2( saveNameData(res, txInfo) groupService.saveGroups(res, txInfo, txUpdate) saveSignaturesTx(res, txInfo, txUpdate) + return TxUpdatedItems(addrs, markers, txUpdate) } diff --git a/service/src/main/kotlin/io/provenance/explorer/service/utility/UtilityService.kt b/service/src/main/kotlin/io/provenance/explorer/service/utility/UtilityService.kt index e4323bf9..f9d8a58b 100644 --- a/service/src/main/kotlin/io/provenance/explorer/service/utility/UtilityService.kt +++ b/service/src/main/kotlin/io/provenance/explorer/service/utility/UtilityService.kt @@ -96,7 +96,7 @@ class UtilityService( fun parseRawTxJson(rawJson: String, blockHeight: Int = 1, timestamp: DateTime = DateTime.now()) = transaction { val builder = ServiceOuterClass.GetTxResponse.newBuilder() protoParser.ignoringUnknownFields().merge(rawJson, builder) - async.addTxToCache(builder.build(), DateTime.now(), BlockProposer(blockHeight, "", timestamp)) + async.processAndSaveTransactionData(builder.build(), DateTime.now(), BlockProposer(blockHeight, "", timestamp)) } fun saveRawTxJson(rawJson: String, blockHeight: Int = 1, timestamp: DateTime = DateTime.now()) = transaction {