Skip to content

Commit 23cad31

Browse files
committed
Merge remote-tracking branch 'origin/develop' into fix/fix-retry-config-option
2 parents 69861ad + c4737ea commit 23cad31

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/main/scala/io/iohk/ethereum/ledger/BlockImport.scala

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@ import io.iohk.ethereum.consensus.validators.BlockHeaderError.HeaderParentNotFou
55
import io.iohk.ethereum.domain._
66
import io.iohk.ethereum.ledger.BlockExecutionError.ValidationBeforeExecError
77
import io.iohk.ethereum.ledger.BlockQueue.Leaf
8-
import io.iohk.ethereum.utils.{BlockchainConfig, ByteStringUtils, Logger}
8+
import io.iohk.ethereum.utils.{ByteStringUtils, Logger}
99
import org.bouncycastle.util.encoders.Hex
1010

1111
import scala.concurrent.{ExecutionContext, Future}
1212

1313
class BlockImport(
1414
blockchain: BlockchainImpl,
1515
blockQueue: BlockQueue,
16-
blockchainConfig: BlockchainConfig,
1716
blockValidation: BlockValidation,
1817
blockExecution: BlockExecution,
1918
validationContext: ExecutionContext // Can't be implicit because of importToTop method and ambiguous of executionContext
@@ -34,7 +33,10 @@ class BlockImport(
3433
} yield {
3534
validationResult.fold(
3635
error => handleImportTopValidationError(error, block, importResult),
37-
_ => importResult
36+
_ => {
37+
measureBlockMetrics(importResult)
38+
importResult
39+
}
3840
)
3941
}
4042
}
@@ -72,17 +74,21 @@ class BlockImport(
7274
}
7375
)
7476

75-
if (importedBlocks.nonEmpty) {
76-
importedBlocks.foreach(blockData => BlockMetrics.measure(blockData.block, blockchain.getBlockByHash))
77-
}
78-
7977
result
8078

8179
case None =>
8280
BlockImportFailed(s"Newly enqueued block with hash: ${block.header.hash} is not part of a known branch")
8381
}
8482
}
8583

84+
private def measureBlockMetrics(importResult: BlockImportResult): Unit = {
85+
importResult match {
86+
case BlockImportedToTop(blockImportData) =>
87+
blockImportData.foreach(blockData => BlockMetrics.measure(blockData.block, blockchain.getBlockByHash))
88+
case _ => ()
89+
}
90+
}
91+
8692
private def handleImportTopValidationError(
8793
error: ValidationBeforeExecError,
8894
block: Block,

src/main/scala/io/iohk/ethereum/ledger/Ledger.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ class LedgerImpl(
100100
new BlockImport(
101101
blockchain,
102102
blockQueue,
103-
blockchainConfig,
104103
blockValidation,
105104
blockExecution,
106105
validationContext

0 commit comments

Comments
 (0)