-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[refactor] put all the state in the same place and create a builder f…
…or consensus and ledger
- Loading branch information
Aurélien Richez
committed
May 27, 2021
1 parent
f8dc207
commit 7568191
Showing
10 changed files
with
101 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/main/scala/io/iohk/ethereum/testmode/TestModeComponentsProvider.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package io.iohk.ethereum.testmode | ||
|
||
import io.iohk.ethereum.consensus.difficulty.DifficultyCalculator | ||
import io.iohk.ethereum.consensus.{Consensus, ConsensusConfig} | ||
import io.iohk.ethereum.domain.BlockchainImpl | ||
import io.iohk.ethereum.ledger.Ledger.VMImpl | ||
import io.iohk.ethereum.ledger.{Ledger, LedgerImpl, StxLedger} | ||
import io.iohk.ethereum.utils.BlockchainConfig | ||
import io.iohk.ethereum.utils.Config.SyncConfig | ||
import monix.execution.Scheduler | ||
|
||
/** Provides a ledger instance with modifiable blockchain config (used in test mode). */ | ||
class TestModeComponentsProvider( | ||
blockchain: BlockchainImpl, | ||
syncConfig: SyncConfig, | ||
validationExecutionContext: Scheduler, | ||
consensusConfig: ConsensusConfig, | ||
difficultyCalculator: DifficultyCalculator, | ||
vm: VMImpl | ||
) { | ||
|
||
def ledger(blockchainConfig: BlockchainConfig): Ledger = | ||
new LedgerImpl(blockchain, blockchainConfig, syncConfig, consensus(blockchainConfig), validationExecutionContext) | ||
def stxLedger(blockchainConfig: BlockchainConfig): StxLedger = | ||
new StxLedger(blockchain, blockchainConfig, consensus(blockchainConfig).blockPreparator) | ||
def consensus(blockchainConfig: BlockchainConfig, blockTimestamp: Long = 0): TestmodeConsensus = | ||
new TestmodeConsensus(vm, blockchain, blockchainConfig, consensusConfig, difficultyCalculator, blockTimestamp) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 0 additions & 20 deletions
20
src/main/scala/io/iohk/ethereum/testmode/TestServiceProvider.scala
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters