use of co.rsk.config.MiningConfig in project rskj by rsksmart.
the class Web3ImplSnapshotTest method getMinerServerForTest.
private MinerServer getMinerServerForTest(SimpleEthereum ethereum, MinerClock clock) {
BlockValidationRule rule = new MinerManagerTest.BlockValidationRuleDummy();
DifficultyCalculator difficultyCalculator = new DifficultyCalculator(config.getActivationConfig(), config.getNetworkConstants());
MiningConfig miningConfig = ConfigUtils.getDefaultMiningConfig();
return new MinerServerImpl(config, ethereum, mainchainView, factory.getNodeBlockProcessor(), new ProofOfWorkRule(config).setFallbackMiningEnabled(false), new BlockToMineBuilder(config.getActivationConfig(), miningConfig, factory.getRepositoryLocator(), factory.getBlockStore(), factory.getTransactionPool(), difficultyCalculator, new GasLimitCalculator(config.getNetworkConstants()), new ForkDetectionDataCalculator(), rule, clock, blockFactory, factory.getBlockExecutor(), new MinimumGasPriceCalculator(Coin.valueOf(miningConfig.getMinGasPriceTarget())), new MinerUtils()), clock, blockFactory, new BuildInfo("cb7f28e", "master"), miningConfig);
}
use of co.rsk.config.MiningConfig in project rskj by rsksmart.
the class TransactionModuleTest method internalCreateEnvironment.
private Web3Impl internalCreateEnvironment(Blockchain blockchain, MiningMainchainView mainchainView, ReceiptStore receiptStore, TransactionPool transactionPool, BlockStore blockStore, boolean mineInstant, StateRootHandler stateRootHandler, RepositoryLocator repositoryLocator, TransactionGateway transactionGateway, TransactionExecutorFactory transactionExecutorFactory) {
transactionPool.processBest(blockchain.getBestBlock());
ConfigCapabilities configCapabilities = new SimpleConfigCapabilities();
CompositeEthereumListener compositeEthereumListener = new CompositeEthereumListener();
Ethereum eth = new EthereumImpl(new ChannelManagerImpl(config, new SyncPool(compositeEthereumListener, blockchain, config, null, null, null)), transactionGateway, compositeEthereumListener, blockchain);
MinerClock minerClock = new MinerClock(true, Clock.systemUTC());
this.transactionExecutorFactory = transactionExecutorFactory;
MiningConfig miningConfig = ConfigUtils.getDefaultMiningConfig();
BlockExecutor blockExecutor = new BlockExecutor(config.getActivationConfig(), repositoryLocator, // stateRootHandler,
this.transactionExecutorFactory);
MinerServer minerServer = new MinerServerImpl(config, eth, mainchainView, null, new ProofOfWorkRule(config).setFallbackMiningEnabled(false), new BlockToMineBuilder(config.getActivationConfig(), miningConfig, repositoryLocator, blockStore, transactionPool, new DifficultyCalculator(config.getActivationConfig(), config.getNetworkConstants()), new GasLimitCalculator(config.getNetworkConstants()), new ForkDetectionDataCalculator(), mock(BlockUnclesValidationRule.class), minerClock, blockFactory, blockExecutor, new MinimumGasPriceCalculator(Coin.valueOf(miningConfig.getMinGasPriceTarget())), new MinerUtils()), minerClock, blockFactory, new BuildInfo("cb7f28e", "master"), miningConfig);
Wallet wallet = WalletFactory.createWallet();
PersonalModuleWalletEnabled personalModule = new PersonalModuleWalletEnabled(config, eth, wallet, transactionPool);
MinerClient minerClient = new MinerClientImpl(null, minerServer, config.minerClientDelayBetweenBlocks(), config.minerClientDelayBetweenRefreshes());
EthModuleTransaction transactionModule;
ReversibleTransactionExecutor reversibleTransactionExecutor1 = new ReversibleTransactionExecutor(repositoryLocator, this.transactionExecutorFactory);
if (mineInstant) {
transactionModule = new EthModuleTransactionInstant(config.getNetworkConstants(), wallet, transactionPool, minerServer, minerClient, blockchain, transactionGateway, blockExecutor);
} else {
transactionModule = new EthModuleTransactionBase(config.getNetworkConstants(), wallet, transactionPool, transactionGateway);
}
final RepositoryBtcBlockStoreWithCache.Factory btcBlockStoreFactory = new RepositoryBtcBlockStoreWithCache.Factory(config.getNetworkConstants().getBridgeConstants().getBtcParams());
EthModule ethModule = new EthModule(config.getNetworkConstants().getBridgeConstants(), config.getNetworkConstants().getChainId(), blockchain, transactionPool, reversibleTransactionExecutor1, new ExecutionBlockRetriever(mainchainView, blockchain, null, null), repositoryLocator, new EthModuleWalletEnabled(wallet), transactionModule, new BridgeSupportFactory(btcBlockStoreFactory, config.getNetworkConstants().getBridgeConstants(), config.getActivationConfig()), config.getGasEstimationCap());
TxPoolModule txPoolModule = new TxPoolModuleImpl(transactionPool);
DebugModule debugModule = new DebugModuleImpl(null, null, Web3Mocks.getMockMessageHandler(), null);
ChannelManager channelManager = new SimpleChannelManager();
return new Web3RskImpl(eth, blockchain, config, minerClient, Web3Mocks.getMockMinerServer(), personalModule, ethModule, null, txPoolModule, null, debugModule, null, null, channelManager, null, null, blockStore, receiptStore, null, null, null, configCapabilities, null, null, null, null);
}
use of co.rsk.config.MiningConfig in project rskj by rsksmart.
the class SubmissionRateLimitHandlerTest method ofMiningConfig_WhenRateLimitIsZero_ThenHandlerShouldBeDisabled.
@Test
public void ofMiningConfig_WhenRateLimitIsZero_ThenHandlerShouldBeDisabled() {
MiningConfig miningConfig = mock(MiningConfig.class);
doReturn(0L).when(miningConfig).getWorkSubmissionRateLimitInMills();
assertFalse(SubmissionRateLimitHandler.ofMiningConfig(miningConfig).isEnabled());
}
Aggregations