Skip to content

Commit 1ac7040

Browse files
author
Leonor Boga
committed
ETCM-1058 Simplify code using tap method
1 parent 3a963c2 commit 1ac7040

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/main/scala/io/iohk/ethereum/consensus/ConsensusImpl.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import io.iohk.ethereum.ledger.BlockValidation
3737
import io.iohk.ethereum.mpt.MerklePatriciaTrie.MissingNodeException
3838
import io.iohk.ethereum.utils.BlockchainConfig
3939
import io.iohk.ethereum.utils.ByteStringUtils
40+
import io.iohk.ethereum.utils.FunctorOps._
4041
import io.iohk.ethereum.utils.Logger
4142

4243
class ConsensusImpl(
@@ -100,12 +101,11 @@ class ConsensusImpl(
100101
blockchainConfig: BlockchainConfig
101102
): Task[Either[ValidationBeforeExecError, BlockExecutionSuccess]] =
102103
Task
103-
.evalOnce {
104-
val validationResult = blockValidation.validateBlockBeforeExecution(block)
105-
validationResult.left.foreach { error =>
104+
.evalOnce(blockValidation.validateBlockBeforeExecution(block))
105+
.tap {
106+
case Left(error) =>
106107
log.error("Error while validating block with hash {} before execution: {}", block.hash, error.reason)
107-
}
108-
validationResult
108+
case Right(_) => log.debug("Block with hash {} validated successfully", block.hash)
109109
}
110110
.executeOn(validationScheduler)
111111

0 commit comments

Comments
 (0)