本文整理汇总了Java中org.ethereum.config.CommonConfig类的典型用法代码示例。如果您正苦于以下问题:Java CommonConfig类的具体用法?Java CommonConfig怎么用?Java CommonConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommonConfig类属于org.ethereum.config包,在下文中一共展示了CommonConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TransactionExecutor
import org.ethereum.config.CommonConfig; //导入依赖的package包/类
public TransactionExecutor(Transaction tx, byte[] coinbase, Repository track, BlockStore blockStore,
ProgramInvokeFactory programInvokeFactory, Block currentBlock,
EthereumListener listener, long gasUsedInTheBlock) {
this.tx = tx;
this.coinbase = coinbase;
this.track = track;
this.cacheTrack = track.startTracking();
this.blockStore = blockStore;
this.programInvokeFactory = programInvokeFactory;
this.currentBlock = currentBlock;
this.listener = listener;
this.gasUsedInTheBlock = gasUsedInTheBlock;
this.m_endGas = toBI(tx.getGasLimit());
withCommonConfig(CommonConfig.getDefault());
}
示例2: checkFastHeaders
import org.ethereum.config.CommonConfig; //导入依赖的package包/类
public static void checkFastHeaders(Ethereum ethereum, CommonConfig commonConfig, AtomicInteger fatalErrors) {
DataSourceArray<BlockHeader> headerStore = commonConfig.headerSource();
int blockNumber = headerStore.size() - 1;
byte[] lastParentHash = null;
try {
testLogger.info("Checking fast headers from best block: {}", blockNumber);
while (blockNumber > 0) {
BlockHeader header = headerStore.get(blockNumber);
if (lastParentHash != null) {
assert FastByteComparisons.equal(header.getHash(), lastParentHash);
}
lastParentHash = header.getParentHash();
assert lastParentHash != null;
blockNumber--;
}
Block genesis = ethereum.getBlockchain().getBlockByNumber(0);
assert FastByteComparisons.equal(genesis.getHash(), lastParentHash);
testLogger.info("Checking fast headers successful, ended on block: {}", blockNumber + 1);
} catch (Exception | AssertionError ex) {
testLogger.error(String.format("Fast header validation error on block #%s", blockNumber), ex);
fatalErrors.incrementAndGet();
}
}
示例3: fullCheck
import org.ethereum.config.CommonConfig; //导入依赖的package包/类
public static void fullCheck(Ethereum ethereum, CommonConfig commonConfig, AtomicInteger fatalErrors) {
// nodes
testLogger.info("Validating nodes: Start");
BlockchainValidation.checkNodes(ethereum, commonConfig, fatalErrors);
testLogger.info("Validating nodes: End");
// headers
testLogger.info("Validating block headers: Start");
BlockchainValidation.checkHeaders(ethereum, fatalErrors);
testLogger.info("Validating block headers: End");
// blocks
testLogger.info("Validating blocks: Start");
BlockchainValidation.checkBlocks(ethereum, fatalErrors);
testLogger.info("Validating blocks: End");
// receipts
testLogger.info("Validating transaction receipts: Start");
BlockchainValidation.checkTransactions(ethereum, fatalErrors);
testLogger.info("Validating transaction receipts: End");
}
示例4: createRepositoryUsingNewRepository
import org.ethereum.config.CommonConfig; //导入依赖的package包/类
@Test
public void createRepositoryUsingNewRepository() {
CommonConfig config = new CommonConfig();
Repository repository = config.repository(ConfigHelper.CONFIG);
Assert.assertNotNull(repository);
Assert.assertTrue(repository instanceof RepositoryImpl);
}
示例5: createPendingStateTransactions
import org.ethereum.config.CommonConfig; //导入依赖的package包/类
@Test
public void createPendingStateTransactions() {
CommonConfig config = new CommonConfig();
List<Transaction> result = config.pendingStateTransactions();
Assert.assertNotNull(result);
Assert.assertTrue(result.isEmpty());
}
示例6: createParentHeaderValidator
import org.ethereum.config.CommonConfig; //导入依赖的package包/类
@Test
public void createParentHeaderValidator() {
CommonConfig config = new CommonConfig();
ParentBlockHeaderValidator result = config.parentHeaderValidator(ConfigHelper.CONFIG, new DifficultyCalculator(ConfigHelper.CONFIG));
Assert.assertNotNull(result);
}
示例7: fullSanityCheck
import org.ethereum.config.CommonConfig; //导入依赖的package包/类
private static void fullSanityCheck(Ethereum ethereum, CommonConfig commonConfig) {
BlockchainValidation.fullCheck(ethereum, commonConfig, fatalErrors);
logStats();
if (!firstRun.get()) {
allChecksAreOver.set(true);
statTimer.shutdownNow();
}
firstRun.set(false);
}
示例8: checkNodes
import org.ethereum.config.CommonConfig; //导入依赖的package包/类
public static void checkNodes(Ethereum ethereum, CommonConfig commonConfig, AtomicInteger fatalErrors) {
try {
Source<byte[], byte[]> stateDS = commonConfig.stateSource();
byte[] stateRoot = ethereum.getBlockchain().getBestBlock().getHeader().getStateRoot();
Integer rootsSize = getReferencedTrieNodes(stateDS, true, stateRoot);
testLogger.info("Node validation successful");
testLogger.info("Non-unique node size: {}", rootsSize);
} catch (Exception | AssertionError ex) {
testLogger.error("Node validation error", ex);
fatalErrors.incrementAndGet();
}
}
示例9: withCommonConfig
import org.ethereum.config.CommonConfig; //导入依赖的package包/类
public Program withCommonConfig(CommonConfig commonConfig) {
this.commonConfig = commonConfig;
return this;
}
示例10: setCommonConfig
import org.ethereum.config.CommonConfig; //导入依赖的package包/类
@Autowired
public void setCommonConfig(CommonConfig commonConfig) {
if (journalSource != null) {
journalSource.setJournalStore(commonConfig.cachedDbSource("journal"));
}
}
示例11: withCommonConfig
import org.ethereum.config.CommonConfig; //导入依赖的package包/类
public TransactionExecutor withCommonConfig(CommonConfig commonConfig) {
this.commonConfig = commonConfig;
this.config = commonConfig.systemProperties();
this.blockchainConfig = config.getBlockchainConfig().getConfigForBlock(currentBlock.getNumber());
return this;
}
示例12: fullSanityCheck
import org.ethereum.config.CommonConfig; //导入依赖的package包/类
private static void fullSanityCheck(Ethereum ethereum, CommonConfig commonConfig) {
BlockchainValidation.fullCheck(ethereum, commonConfig, fatalErrors);
logStats();
allChecksAreOver.set(true);
statTimer.shutdownNow();
}
示例13: fullSanityCheck
import org.ethereum.config.CommonConfig; //导入依赖的package包/类
private static void fullSanityCheck(Ethereum ethereum, CommonConfig commonConfig) {
BlockchainValidation.fullCheck(ethereum, commonConfig, fatalErrors);
logStats();
firstRun.set(false);
}
示例14: createBlockchain
import org.ethereum.config.CommonConfig; //导入依赖的package包/类
private Blockchain createBlockchain(Genesis genesis) {
IndexedBlockStore blockStore = new IndexedBlockStore();
blockStore.init(new HashMapDB<byte[]>(), new HashMapDB<byte[]>());
Repository repository = new RepositoryRoot(new HashMapDB());
ProgramInvokeFactoryImpl programInvokeFactory = new ProgramInvokeFactoryImpl();
BlockchainImpl blockchain = new BlockchainImpl(blockStore, repository)
.withParentBlockHeaderValidator(new CommonConfig().parentHeaderValidator());
blockchain.setParentHeaderValidator(new DependentBlockHeaderRuleAdapter());
blockchain.setProgramInvokeFactory(programInvokeFactory);
blockchain.byTest = true;
PendingStateImpl pendingState = new PendingStateImpl(new EthereumListenerAdapter(), blockchain);
pendingState.setBlockchain(blockchain);
blockchain.setPendingState(pendingState);
Repository track = repository.startTracking();
Genesis.populateRepository(track, genesis);
track.commit();
blockStore.saveBlock(Genesis.getInstance(), Genesis.getInstance().getCumulativeDifficulty(), true);
blockchain.setBestBlock(Genesis.getInstance());
blockchain.setTotalDifficulty(Genesis.getInstance().getCumulativeDifficulty());
return blockchain;
}
示例15: createBlockchain
import org.ethereum.config.CommonConfig; //导入依赖的package包/类
public static BlockchainImpl createBlockchain(Genesis genesis) {
IndexedBlockStore blockStore = new IndexedBlockStore();
blockStore.init(new HashMapDB<byte[]>(), new HashMapDB<byte[]>());
RepositoryRoot repository = new RepositoryRoot(new NoDeleteSource<>(new HashMapDB<byte[]>()));
ProgramInvokeFactoryImpl programInvokeFactory = new ProgramInvokeFactoryImpl();
EthereumListenerAdapter listener = new EthereumListenerAdapter();
BlockchainImpl blockchain = new BlockchainImpl(blockStore, repository)
.withParentBlockHeaderValidator(new CommonConfig().parentHeaderValidator());
blockchain.setParentHeaderValidator(new DependentBlockHeaderRuleAdapter());
blockchain.setProgramInvokeFactory(programInvokeFactory);
blockchain.byTest = true;
PendingStateImpl pendingState = new PendingStateImpl(listener, blockchain);
pendingState.setBlockchain(blockchain);
blockchain.setPendingState(pendingState);
Repository track = repository.startTracking();
Genesis.populateRepository(track, genesis);
track.commit();
repository.commit();
blockStore.saveBlock(genesis, genesis.getCumulativeDifficulty(), true);
blockchain.setBestBlock(genesis);
blockchain.setTotalDifficulty(genesis.getCumulativeDifficulty());
return blockchain;
}