Skip to content

Commit 29ca2af

Browse files
committed
[ETCM-135] Revert lazy vals in favor of vals
1 parent 47960a4 commit 29ca2af

File tree

6 files changed

+40
-15
lines changed

6 files changed

+40
-15
lines changed

src/it/scala/io/iohk/ethereum/sync/util/CommonFakePeer.scala

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,14 @@ import io.iohk.ethereum.network.p2p.EthereumMessageDecoder
2525
import io.iohk.ethereum.network.p2p.messages.CommonMessages.NewBlock
2626
import io.iohk.ethereum.network.rlpx.AuthHandshaker
2727
import io.iohk.ethereum.network.rlpx.RLPxConnectionHandler.RLPxConfiguration
28-
import io.iohk.ethereum.network.{EtcPeerManagerActor, ForkResolver, KnownNodesManager, PeerEventBusActor, PeerManagerActor, ServerActor}
28+
import io.iohk.ethereum.network.{
29+
EtcPeerManagerActor,
30+
ForkResolver,
31+
KnownNodesManager,
32+
PeerEventBusActor,
33+
PeerManagerActor,
34+
ServerActor
35+
}
2936
import io.iohk.ethereum.nodebuilder.{PruningConfigBuilder, SecureRandomBuilder}
3037
import io.iohk.ethereum.sync.util.SyncCommonItSpec._
3138
import io.iohk.ethereum.sync.util.SyncCommonItSpecUtils._

src/main/scala/io/iohk/ethereum/nodebuilder/NodeBuilder.scala

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,14 @@ object PendingTransactionsManagerBuilder {
280280
}
281281

282282
trait TransactionHistoryServiceBuilder {
283-
self: BlockchainBuilder with PendingTransactionsManagerBuilder with TxPoolConfigBuilder =>
284-
lazy val transactionHistoryService =
285-
new TransactionHistoryService(blockchain, pendingTransactionsManager, txPoolConfig.getTransactionFromPoolTimeout)
283+
def transactionHistoryService: TransactionHistoryService
284+
}
285+
object TransactionHistoryServiceBuilder {
286+
trait Default extends TransactionHistoryServiceBuilder {
287+
self: BlockchainBuilder with PendingTransactionsManagerBuilder with TxPoolConfigBuilder =>
288+
val transactionHistoryService =
289+
new TransactionHistoryService(blockchain, pendingTransactionsManager, txPoolConfig.getTransactionFromPoolTimeout)
290+
}
286291
}
287292

288293
trait FilterManagerBuilder {
@@ -346,7 +351,7 @@ trait EthServiceBuilder {
346351
with JSONRpcConfigBuilder
347352
with AsyncConfigBuilder =>
348353

349-
lazy val ethService = new EthService(
354+
val ethService = new EthService(
350355
blockchain,
351356
ledger,
352357
stxLedger,
@@ -685,4 +690,4 @@ trait Node
685690
with KeyStoreConfigBuilder
686691
with AsyncConfigBuilder
687692
with CheckpointBlockGeneratorBuilder
688-
with TransactionHistoryServiceBuilder
693+
with TransactionHistoryServiceBuilder.Default

src/test/scala/io/iohk/ethereum/blockchain/sync/StateSyncSpec.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@ import akka.testkit.{TestKit, TestProbe}
99
import akka.util.ByteString
1010
import io.iohk.ethereum.blockchain.sync.StateSyncUtils.{MptNodeData, TrieProvider}
1111
import io.iohk.ethereum.blockchain.sync.fast.{SyncStateScheduler, SyncStateSchedulerActor}
12-
import io.iohk.ethereum.blockchain.sync.fast.SyncStateSchedulerActor.{RestartRequested, StartSyncingTo, StateSyncFinished, StateSyncStats, WaitingForNewTargetBlock}
12+
import io.iohk.ethereum.blockchain.sync.fast.SyncStateSchedulerActor.{
13+
RestartRequested,
14+
StartSyncingTo,
15+
StateSyncFinished,
16+
StateSyncStats,
17+
WaitingForNewTargetBlock
18+
}
1319
import io.iohk.ethereum.db.dataSource.RocksDbDataSource.IterationError
1420
import io.iohk.ethereum.domain.{Address, BlockchainImpl, ChainWeight}
1521
import io.iohk.ethereum.network.EtcPeerManagerActor.{GetHandshakedPeers, HandshakedPeers, PeerInfo, SendMessage}

src/test/scala/io/iohk/ethereum/domain/BlockchainSpec.scala

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,15 +154,17 @@ class BlockchainSpec extends AnyFlatSpec with Matchers with ScalaCheckPropertyCh
154154
}
155155

156156
blockchainWithStubPersisting.getBestBlockNumber() shouldBe blocksToImport.last.number
157-
blockchainStoragesWithStubPersisting.appStateStorage.getBestBlockNumber() shouldBe blockImportToPersist.fold(0: BigInt)(_.number)
158-
157+
blockchainStoragesWithStubPersisting.appStateStorage.getBestBlockNumber() shouldBe blockImportToPersist.fold(
158+
0: BigInt
159+
)(_.number)
159160

160161
// Rollback blocks
161162
val numberBlocksToRollback = intGen(0, numberBlocksToImport).sample.get
162163
val (blocksNotRollbacked, blocksToRollback) = blocksToImport.splitAt(numberBlocksToRollback)
163164

164165
// Randomly select the block rollback to persist (empty means no persistance)
165-
val blockRollbackToPersist = if (blocksToRollback.isEmpty) None else Gen.option(Gen.oneOf(blocksToRollback)).sample.get
166+
val blockRollbackToPersist =
167+
if (blocksToRollback.isEmpty) None else Gen.option(Gen.oneOf(blocksToRollback)).sample.get
166168
(stubStateStorage
167169
.onBlockRollback(_: BigInt, _: BigInt)(_: () => Unit))
168170
.when(*, *, *)
@@ -188,14 +190,18 @@ class BlockchainSpec extends AnyFlatSpec with Matchers with ScalaCheckPropertyCh
188190
trait TestSetup extends MockFactory {
189191
val maxNumberBlocksToImport: Int = 30
190192

191-
def calculatePersistedBestBlock(blockImportPersisted: Option[BigInt], blockRollbackPersisted: Option[BigInt], blocksRollbacked: Seq[BigInt]): BigInt = {
193+
def calculatePersistedBestBlock(
194+
blockImportPersisted: Option[BigInt],
195+
blockRollbackPersisted: Option[BigInt],
196+
blocksRollbacked: Seq[BigInt]
197+
): BigInt = {
192198
(blocksRollbacked, blockImportPersisted) match {
193199
case (Nil, Some(bi)) =>
194200
// No blocks rollbacked, last persist was the persist during import
195201
bi
196202
case (nonEmptyRollbackedBlocks, Some(bi)) =>
197203
// Last forced persist during apply/rollback
198-
val maxForcedPersist = blockRollbackPersisted.fold(bi){ br => (br - 1).max(bi)}
204+
val maxForcedPersist = blockRollbackPersisted.fold(bi) { br => (br - 1).max(bi) }
199205

200206
// The above number would have been decreased by any rollbacked blocks
201207
(nonEmptyRollbackedBlocks.head - 1).min(maxForcedPersist)

src/test/scala/io/iohk/ethereum/jsonrpc/MantisServiceSpec.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class MantisServiceSpec
2828
with SpecFixtures
2929
with WithActorSystemShutDown {
3030
class Fixture
31-
extends TransactionHistoryServiceBuilder
31+
extends TransactionHistoryServiceBuilder.Default
3232
with EphemBlockchainTestSetup
3333
with PendingTransactionsManagerBuilder
3434
with TxPoolConfigBuilder
@@ -67,7 +67,7 @@ class MantisServiceSpec
6767
)
6868
)
6969

70-
override lazy val transactionHistoryService: TransactionHistoryService =
70+
override val transactionHistoryService: TransactionHistoryService =
7171
new TransactionHistoryService(
7272
blockchain,
7373
pendingTransactionsManager,

src/test/scala/io/iohk/ethereum/utils/VersionInfoSpec.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ class VersionInfoSpec extends AnyFlatSpec with Matchers {
77
behavior of "nodeName"
88

99
it should "match ethstats expected structure and preserve major and minor Java version" in {
10-
VersionInfo.nodeName() should fullyMatch regex """mantis/v\d(\.\d+)*-[a-z0-9]{7}/[^/]+-[^/]+/[^/]+-.[^/]+-java-\d+\.\d+[._0-9]*"""
10+
VersionInfo
11+
.nodeName() should fullyMatch regex """mantis/v\d(\.\d+)*-[a-z0-9]{7}/[^/]+-[^/]+/[^/]+-.[^/]+-java-\d+\.\d+[._0-9]*"""
1112
}
1213

1314
it should "augment the name with an identity" in {

0 commit comments

Comments
 (0)