use of co.rsk.core.DifficultyCalculator in project rskj by rsksmart.
the class MinerManagerTest method getMinerServer.
private static MinerServerImpl getMinerServer(Blockchain blockchain) {
SimpleEthereum ethereum = new SimpleEthereum();
ethereum.repository = blockchain.getRepository();
ethereum.blockchain = blockchain;
DifficultyCalculator difficultyCalculator = new DifficultyCalculator(config);
return new MinerServerImpl(config, ethereum, blockchain, null, difficultyCalculator, new ProofOfWorkRule(config).setFallbackMiningEnabled(false), new BlockToMineBuilder(ConfigUtils.getDefaultMiningConfig(), blockchain.getRepository(), blockchain.getBlockStore(), blockchain.getTransactionPool(), difficultyCalculator, new GasLimitCalculator(config), new BlockValidationRuleDummy(), config, null), ConfigUtils.getDefaultMiningConfig());
}
use of co.rsk.core.DifficultyCalculator in project rskj by rsksmart.
the class LocalBasicTest method runDifficultyTest.
@Test
public void runDifficultyTest() throws IOException, ParseException {
config.setGenesisInfo("frontier.json");
config.setBlockchainConfig(new MainNetConfig());
String json = getJSON("difficulty");
DifficultyTestSuite testSuite = new DifficultyTestSuite(json);
for (DifficultyTestCase testCase : testSuite.getTestCases()) {
logger.info("Running {}\n", testCase.getName());
BlockHeader current = testCase.getCurrent();
BlockHeader parent = testCase.getParent();
BlockDifficulty calc = new DifficultyCalculator(config).calcDifficulty(current, parent);
int c = calc.compareTo(parent.getDifficulty());
if (c > 0)
logger.info(" Difficulty increase test\n");
else if (c < 0)
logger.info(" Difficulty decrease test\n");
else
logger.info(" Difficulty without change test\n");
assertEquals(testCase.getExpectedDifficulty(), calc);
}
}
use of co.rsk.core.DifficultyCalculator in project rskj by rsksmart.
the class SimpleAsyncNode method createNode.
public static SimpleAsyncNode createNode(Blockchain blockchain, SyncConfiguration syncConfiguration) {
final BlockStore store = new BlockStore();
BlockNodeInformation nodeInformation = new BlockNodeInformation();
BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration);
NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration);
DummyBlockValidationRule blockValidationRule = new DummyBlockValidationRule();
PeerScoringManager peerScoringManager = RskMockFactory.getPeerScoringManager();
SimpleChannelManager channelManager = new SimpleChannelManager();
SyncProcessor syncProcessor = new SyncProcessor(config, blockchain, blockSyncService, peerScoringManager, channelManager, syncConfiguration, blockValidationRule, new DifficultyCalculator(config));
NodeMessageHandler handler = new NodeMessageHandler(config, processor, syncProcessor, channelManager, null, null, peerScoringManager, blockValidationRule);
return new SimpleAsyncNode(handler, syncProcessor, channelManager);
}
use of co.rsk.core.DifficultyCalculator in project rskj by rsksmart.
the class CommonConfigTest method createParentHeaderValidator.
@Test
public void createParentHeaderValidator() {
CommonConfig config = new CommonConfig();
ParentBlockHeaderValidator result = config.parentHeaderValidator(this.config, new DifficultyCalculator(this.config));
Assert.assertNotNull(result);
}
use of co.rsk.core.DifficultyCalculator in project rskj by rsksmart.
the class MainNetMinerTest method blockToMineBuilder.
private BlockToMineBuilder blockToMineBuilder() {
BlockUnclesValidationRule unclesValidationRule = Mockito.mock(BlockUnclesValidationRule.class);
when(unclesValidationRule.isValid(Mockito.any())).thenReturn(true);
MinerClock clock = new MinerClock(true, Clock.systemUTC());
MiningConfig miningConfig = ConfigUtils.getDefaultMiningConfig();
return new BlockToMineBuilder(config.getActivationConfig(), miningConfig, repositoryLocator, blockStore, transactionPool, new DifficultyCalculator(config.getActivationConfig(), config.getNetworkConstants()), new GasLimitCalculator(config.getNetworkConstants()), new ForkDetectionDataCalculator(), unclesValidationRule, clock, blockFactory, blockExecutor, new MinimumGasPriceCalculator(Coin.valueOf(miningConfig.getMinGasPriceTarget())), new MinerUtils());
}
Aggregations