Skip to content

Commit

Permalink
server: Remove unnecessary timing logs
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexITC committed Jan 29, 2019
1 parent 2e45d79 commit 56963b2
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class LedgerPostgresDataHandler @Inject() (
block: Block,
transactions: List[Transaction]): ApplicationResult[Unit] = {

val start = System.currentTimeMillis()
val result = withTransaction { implicit conn =>
val result = for {
_ <- upsertBlockCascade(block.copy(nextBlockhash = None), transactions)
Expand All @@ -51,8 +50,6 @@ class LedgerPostgresDataHandler @Inject() (
case _ => e
}

val took = System.currentTimeMillis() - start
logger.info(s"Pushing block = ${block.hash}, took $took ms")
result.badMap { _.map(fromError) }
}

Expand Down Expand Up @@ -119,13 +116,7 @@ class LedgerPostgresDataHandler @Inject() (
}

private def insertBalanceBatch(balanceList: Iterable[Balance])(implicit conn: Connection) = {
val start = System.currentTimeMillis()
val result = balanceList.map { b => balancePostgresDAO.upsert(b) }

val took = System.currentTimeMillis() - start
logger.info(s"Inserting balance batch, size = ${balanceList.size}, took = $took ms")

result
balanceList.map { b => balancePostgresDAO.upsert(b) }
}

private def spendMap(transactions: List[Transaction]): Map[Address, BigDecimal] = {
Expand All @@ -151,7 +142,6 @@ class LedgerPostgresDataHandler @Inject() (
}

private def balances(transactions: List[Transaction]) = {
val start = System.currentTimeMillis()
val spentList = spendMap(transactions).map { case (address, spent) =>
Balance(address, spent = spent)
}
Expand All @@ -165,8 +155,6 @@ class LedgerPostgresDataHandler @Inject() (
.mapValues { _.reduce(mergeBalances) }
.values

val took = System.currentTimeMillis() - start
logger.info(s"Computing balances for transaction batch, size = ${transactions.size}, took = $took ms")
result
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ class TransactionInputPostgresDAO {
case Nil => Some(inputs)

case _ =>

val start = System.currentTimeMillis()
val params = inputs.map { case (txid, input) =>
List(
'txid -> txid.string: NamedParameter,
Expand All @@ -43,10 +41,6 @@ class TransactionInputPostgresDAO {
)

val success = batch.execute().forall(_ == 1)

val took = System.currentTimeMillis() - start
logger.info(s"Inserting input batch, size = ${inputs.size}, took = $took ms")

if (success) {
Some(inputs)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class TransactionOutputPostgresDAO {
outputs match {
case Nil => Some(outputs)
case _ =>
val start = System.currentTimeMillis()
val params = outputs.map { output =>
List(
'txid -> output.txid.string: NamedParameter,
Expand All @@ -56,9 +55,6 @@ class TransactionOutputPostgresDAO {
)

val success = batch.execute().forall(_ == 1)

val took = System.currentTimeMillis() - start
logger.info(s"Inserting output batch, size = ${outputs.size}, took = $took ms")
if (success) {
Some(outputs)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,13 @@ class TransactionPostgresDAO @Inject() (
}

private def insertDetails(transactions: List[Transaction])(implicit conn: Connection): Unit = {
val start = System.currentTimeMillis()
val detailsResult = transactions.map(addressTransactionDetailsDAO.batchInsertDetails)
val took = System.currentTimeMillis() - start

logger.info(s"Inserting address details batch, size = ${transactions.size}, took = $took ms")

assert(detailsResult.forall(_.isDefined), "Inserting address details batch failed")
}

private def spend(transactions: List[Transaction])(implicit conn: Connection): Unit = {
val start = System.currentTimeMillis()
val spendResult = transactions.map { tx => transactionOutputDAO.batchSpend(tx.id, tx.inputs) }
val took = System.currentTimeMillis() - start

logger.info(s"Spending transaction batch, size = ${transactions.size}, took = $took ms")

assert(spendResult.forall(_.isDefined), "Spending inputs batch failed")
}
Expand All @@ -73,7 +65,6 @@ class TransactionPostgresDAO @Inject() (
transactions match {
case Nil => Some(transactions)
case _ =>
val start = System.currentTimeMillis()
val params = transactions.zipWithIndex.map { case (transaction, index) =>
List(
'txid -> transaction.id.string: NamedParameter,
Expand All @@ -95,9 +86,6 @@ class TransactionPostgresDAO @Inject() (
)

val success = batch.execute().forall(_ == 1)

val took = System.currentTimeMillis() - start
logger.info(s"Inserting transaction batch, size = ${transactions.size}, took = $took ms")
if (success) {
Some(transactions)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,9 @@ class LedgerSynchronizerService @Inject() (
}

private def getRPCBlock(blockhash: Blockhash): FutureApplicationResult[(Block, List[Transaction])] = {
val start = System.currentTimeMillis()
val result = for {
block <- xsnService.getBlock(blockhash).toFutureOr
transactions <- transactionRPCService.getTransactions(block.transactions).toFutureOr
took = System.currentTimeMillis() - start
_ = logger.info(s"Retrieving block = $blockhash, took $took ms")
} yield (block, transactions)

result.toFuture
Expand Down

0 comments on commit 56963b2

Please sign in to comment.