Skip to content

Commit

Permalink
remove unneeded pass through function
Browse files Browse the repository at this point in the history
  • Loading branch information
nullpointer0x00 committed Aug 23, 2024
1 parent 3ed68ca commit 5861521
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -254,34 +254,28 @@ 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)
BlockTxRetryRecord.insertOrUpdate(blockHeight, e)
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
): TxUpdatedItems {
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)
Expand All @@ -293,6 +287,7 @@ class AsyncCachingV2(
saveNameData(res, txInfo)
groupService.saveGroups(res, txInfo, txUpdate)
saveSignaturesTx(res, txInfo, txUpdate)

return TxUpdatedItems(addrs, markers, txUpdate)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 5861521

Please sign in to comment.