当前位置: 首页>>代码示例>>Java>>正文


Java BlockStore类代码示例

本文整理汇总了Java中org.ethereum.db.BlockStore的典型用法代码示例。如果您正苦于以下问题:Java BlockStore类的具体用法?Java BlockStore怎么用?Java BlockStore使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BlockStore类属于org.ethereum.db包,在下文中一共展示了BlockStore类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: Web3RskImpl

import org.ethereum.db.BlockStore; //导入依赖的package包/类
public Web3RskImpl(Ethereum eth,
                   WorldManager worldManager,
                   RskSystemProperties properties,
                   MinerClient minerClient,
                   MinerServer minerServer,
                   PersonalModule personalModule,
                   EthModule ethModule,
                   ChannelManager channelManager,
                   Repository repository,
                   PeerScoringManager peerScoringManager,
                   NetworkStateExporter networkStateExporter,
                   BlockStore blockStore,
                   PeerServer peerServer) {
    super(eth, worldManager, properties, minerClient, minerServer, personalModule, ethModule, channelManager, repository, peerScoringManager, peerServer);
    this.networkStateExporter = networkStateExporter;
    this.blockStore = blockStore;
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:18,代码来源:Web3RskImpl.java

示例2: TransactionExecutor

import org.ethereum.db.BlockStore; //导入依赖的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());
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:17,代码来源:TransactionExecutor.java

示例3: BlockChainImpl

import org.ethereum.db.BlockStore; //导入依赖的package包/类
public BlockChainImpl(RskSystemProperties config,
                      Repository repository,
                      BlockStore blockStore,
                      ReceiptStore receiptStore,
                      PendingState pendingState,
                      EthereumListener listener,
                      AdminInfo adminInfo,
                      BlockValidator blockValidator) {
    this.config = config;
    this.repository = repository;
    this.blockStore = blockStore;
    this.receiptStore = receiptStore;
    this.listener = listener;
    this.adminInfo = adminInfo;
    this.blockValidator = blockValidator;
    this.blockExecutor = new BlockExecutor(config, repository, this, blockStore, listener);

    setPendingState(pendingState);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:20,代码来源:BlockChainImpl.java

示例4: PendingStateImpl

import org.ethereum.db.BlockStore; //导入依赖的package包/类
public PendingStateImpl(RskSystemProperties config,
                        Blockchain blockChain,
                        Repository repository,
                        BlockStore blockStore,
                        ProgramInvokeFactory programInvokeFactory,
                        EthereumListener listener,
                        int outdatedThreshold,
                        int outdatedTimeout) {
    this.config = config;
    this.blockChain = blockChain;
    this.blockStore = blockStore;
    this.repository = repository;
    this.programInvokeFactory = programInvokeFactory;
    this.listener = listener;
    this.outdatedThreshold = outdatedThreshold;
    this.outdatedTimeout = outdatedTimeout;

    this.pendingStateRepository = repository.startTracking();
    this.bestBlock = blockChain.getBestBlock();

    if (this.outdatedTimeout > 0) {
        this.cleanerTimer = Executors.newSingleThreadScheduledExecutor(r -> new Thread(r, "PendingStateCleanerTimer"));
    }
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:25,代码来源:PendingStateImpl.java

示例5: getAncestors

import org.ethereum.db.BlockStore; //导入依赖的package包/类
public static Set<ByteArrayWrapper> getAncestors(BlockStore blockStore, long blockNumber, byte[] parentHash, int limitNum) {
    Set<ByteArrayWrapper> ret = new HashSet<>();

    if (blockStore == null) {
        return ret;
    }

    int limit = (int) max(0, blockNumber - limitNum);
    Block it = blockStore.getBlockByHash(parentHash);

    while(it != null && it.getNumber() >= limit) {
        ret.add(new ByteArrayWrapper(it.getHash()));
        it = blockStore.getBlockByHash(it.getParentHash());
    }

    return ret;
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:18,代码来源:FamilyUtils.java

示例6: getUsedUncles

import org.ethereum.db.BlockStore; //导入依赖的package包/类
public static Set<ByteArrayWrapper> getUsedUncles(BlockStore blockStore, long blockNumber, byte[] parentHash, int limitNum) {
    Set<ByteArrayWrapper> ret = new HashSet<>();

    if (blockStore == null) {
        return ret;
    }

    long minNumber = max(0, blockNumber - limitNum);
    Block it = blockStore.getBlockByHash(parentHash);

    while(it != null && it.getNumber() >= minNumber) {
        for (BlockHeader uncle : it.getUncleList()) {
            ret.add(new ByteArrayWrapper(uncle.getHash()));
        }
        it = blockStore.getBlockByHash(it.getParentHash());
    }

    return ret;
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:20,代码来源:FamilyUtils.java

示例7: executeTransaction

import org.ethereum.db.BlockStore; //导入依赖的package包/类
public static TransactionExecutor executeTransaction(RskSystemProperties config,
                                                     Repository track,
                                                     BlockStore blockStore,
                                                     ReceiptStore receiptStore,
                                                     ProgramInvokeFactory programInvokeFactory,
                                                     Block executionBlock,
                                                     byte[] coinbase,
                                                     byte[] gasPrice,
                                                     byte[] gasLimit,
                                                     byte[] toAddress,
                                                     byte[] value,
                                                     byte[] data,
                                                     byte[] fromAddress) {
    Repository repository = track.getSnapshotTo(executionBlock.getStateRoot()).startTracking();

    byte[] nonce = repository.getNonce(fromAddress).toByteArray();
    UnsignedTransaction tx = new UnsignedTransaction(nonce, gasPrice, gasLimit, toAddress, value, data, fromAddress);

    ReversibleTransactionExecutor executor = new ReversibleTransactionExecutor(config, tx, coinbase, repository, blockStore, receiptStore, programInvokeFactory, executionBlock);
    return executor.executeTransaction();
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:22,代码来源:ReversibleTransactionExecutor.java

示例8: WorldManagerImpl

import org.ethereum.db.BlockStore; //导入依赖的package包/类
@Autowired
public WorldManagerImpl(RskSystemProperties config,
                        Blockchain blockchain,
                        BlockStore blockStore,
                        PendingState pendingState,
                        Repository repository,
                        NetworkStateExporter networkStateExporter,
                        HashRateCalculator hashRateCalculator,
                        ConfigCapabilities configCapabilities,
                        ChannelManager channelManager,
                        EthereumListener listener,
                        BlockProcessor nodeBlockProcessor) {
    this.blockchain = blockchain;
    this.blockStore = blockStore;
    this.pendingState = pendingState;
    this.repository = repository;
    this.hashRateCalculator = hashRateCalculator;
    this.configCapabilities = configCapabilities;
    this.listener = listener;
    this.nodeBlockProcessor = nodeBlockProcessor;

    BlockChainLoader loader = new BlockChainLoader(config, this.blockchain, this.blockStore, this.repository, this.listener);
    loader.loadBlockchain();
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:25,代码来源:WorldManagerImpl.java

示例9: TransactionExecutor

import org.ethereum.db.BlockStore; //导入依赖的package包/类
public TransactionExecutor(RskSystemProperties config, Transaction tx, int txindex, byte[] coinbase, Repository track, BlockStore blockStore, ReceiptStore receiptStore,
                           ProgramInvokeFactory programInvokeFactory, Block executionBlock,
                           EthereumListener listener, long gasUsedInTheBlock) {
    this.config = config;
    this.tx = tx;
    this.txindex = txindex;
    this.coinbase = coinbase;
    this.track = track;
    this.cacheTrack = track.startTracking();
    this.blockStore = blockStore;
    this.receiptStore = receiptStore;
    this.programInvokeFactory = programInvokeFactory;
    this.executionBlock = executionBlock;
    this.listener = listener;
    this.gasUsedInTheBlock = gasUsedInTheBlock;
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:17,代码来源:TransactionExecutor.java

示例10: web3_ext_dumpState

import org.ethereum.db.BlockStore; //导入依赖的package包/类
@Test
public void web3_ext_dumpState() throws Exception {
    Rsk rsk = Mockito.mock(Rsk.class);
    WorldManager worldManager = Mockito.mock(WorldManager.class);
    Blockchain blockchain = Mockito.mock(Blockchain.class);

    NetworkStateExporter networkStateExporter = Mockito.mock(NetworkStateExporter.class);
    Mockito.when(networkStateExporter.exportStatus(Mockito.anyString())).thenReturn(true);

    Block block = Mockito.mock(Block.class);
    Mockito.when(block.getHash()).thenReturn(PegTestUtils.createHash3().getBytes());
    Mockito.when(block.getNumber()).thenReturn(1L);

    BlockStore blockStore = Mockito.mock(BlockStore.class);
    Mockito.when(blockStore.getBestBlock()).thenReturn(block);
    Mockito.when(networkStateExporter.exportStatus(Mockito.anyString())).thenReturn(true);

    Mockito.when(worldManager.getBlockchain()).thenReturn(blockchain);
    Mockito.when(blockchain.getBestBlock()).thenReturn(block);

    Wallet wallet = WalletFactory.createWallet();
    PersonalModule pm = new PersonalModuleWalletEnabled(ConfigHelper.CONFIG, rsk, wallet, null);
    EthModule em = new EthModule(ConfigHelper.CONFIG, rsk, new EthModuleSolidityDisabled(), new EthModuleWalletEnabled(ConfigHelper.CONFIG, rsk, wallet, null));
    Web3RskImpl web3 = new Web3RskImpl(rsk, worldManager, ConfigHelper.CONFIG, Web3Mocks.getMockMinerClient(), Web3Mocks.getMockMinerServer(), pm, em, Web3Mocks.getMockChannelManager(), Web3Mocks.getMockRepository(), null, networkStateExporter, blockStore, null);
    web3.ext_dumpState();
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:27,代码来源:Web3RskImplTest.java

示例11: init

import org.ethereum.db.BlockStore; //导入依赖的package包/类
@Before
public void init() {
    blockStore = Mockito.mock(BlockStore.class);
    block = Mockito.mock(Block.class);
    blockHeader = Mockito.mock(BlockHeader.class);

    Mockito.when(block.getHeader()).thenReturn(blockHeader);
    Mockito.when(block.getHash()).thenReturn(FAKE_GENERIC_HASH);
    Mockito.when(blockHeader.getParentHash()).thenReturn(FAKE_GENERIC_HASH)
            .thenReturn(OHTER_FAKE_GENERIC_HASH)
            .thenReturn(FAKE_GENERIC_HASH)
            .thenReturn(null);

    Mockito.when(blockHeader.getHash()).thenReturn(FAKE_GENERIC_HASH);

    Mockito.when(blockStore.getBlockByHash(Mockito.any())).thenReturn(block)
            .thenReturn(block).thenReturn(block).thenReturn(null);

    Mockito.when(blockStore.getBestBlock()).thenReturn(block);
    Mockito.when(blockStore.getBlockByHash(Mockito.any())).thenReturn(block);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:22,代码来源:HashRateCalculatorTest.java

示例12: rejectBlockWithSiblingUncle

import org.ethereum.db.BlockStore; //导入依赖的package包/类
@Test
public void rejectBlockWithSiblingUncle() {
    Block genesis = BlockGenerator.getInstance().getGenesisBlock();

    Block block1 = BlockGenerator.getInstance().createChildBlock(genesis);
    Block uncle = BlockGenerator.getInstance().createChildBlock(block1);
    List<BlockHeader> uncles = new ArrayList<>();
    uncles.add(uncle.getHeader());

    Block block = BlockGenerator.getInstance().createChildBlock(block1, null, uncles, 1, null);

    BlockChainImpl blockChain = BlockChainImplTest.createBlockChain();
    BlockStore store = blockChain.getBlockStore();

    store.saveBlock(genesis, BigInteger.valueOf(1), true);
    store.saveBlock(block1, BigInteger.valueOf(2), true);

    BlockUnclesValidationRule rule = new BlockUnclesValidationRule(ConfigHelper.CONFIG, store, 10, 10, new BlockCompositeRule(), new BlockParentCompositeRule());

    Assert.assertFalse(rule.isValid(block));
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:22,代码来源:BlockUnclesValidationRuleTest.java

示例13: rejectBlockWithUncleHavingHigherNumber

import org.ethereum.db.BlockStore; //导入依赖的package包/类
@Test
public void rejectBlockWithUncleHavingHigherNumber() {
    Block genesis = BlockGenerator.getInstance().getGenesisBlock();

    Block block1 = BlockGenerator.getInstance().createChildBlock(genesis);
    Block uncle1 = BlockGenerator.getInstance().createChildBlock(block1);
    Block uncle2 = BlockGenerator.getInstance().createChildBlock(uncle1);
    List<BlockHeader> uncles = new ArrayList<>();
    uncles.add(uncle2.getHeader());

    Block block = BlockGenerator.getInstance().createChildBlock(block1, null, uncles, 1, null);

    BlockChainImpl blockChain = BlockChainImplTest.createBlockChain();
    BlockStore store = blockChain.getBlockStore();

    store.saveBlock(genesis, BigInteger.valueOf(1), true);
    store.saveBlock(block1, BigInteger.valueOf(2), true);

    BlockUnclesValidationRule rule = new BlockUnclesValidationRule(ConfigHelper.CONFIG, store, 10, 10, new BlockCompositeRule(), new BlockParentCompositeRule());

    Assert.assertFalse(rule.isValid(block));
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:23,代码来源:BlockUnclesValidationRuleTest.java

示例14: calculateParentChild

import org.ethereum.db.BlockStore; //导入依赖的package包/类
@Test
public void calculateParentChild() {
    BlockStore store = createBlockStore();
    Block genesis = BlockGenerator.getInstance().getGenesisBlock();
    Block block = BlockGenerator.getInstance().createChildBlock(genesis);

    store.saveBlock(genesis, BigInteger.ONE, true);
    store.saveBlock(block, BigInteger.ONE, true);

    BlockFork fork = new BlockFork();

    fork.calculate(genesis, block, store);

    Assert.assertSame(genesis, fork.getCommonAncestor());
    Assert.assertTrue(fork.getOldBlocks().isEmpty());
    Assert.assertFalse(fork.getNewBlocks().isEmpty());
    Assert.assertEquals(1, fork.getNewBlocks().size());
    Assert.assertSame(block, fork.getNewBlocks().get(0));
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:20,代码来源:BlockForkTest.java

示例15: processBlockWithInvalidPrevMGP

import org.ethereum.db.BlockStore; //导入依赖的package包/类
@Test
public void processBlockWithInvalidPrevMGP() {
    BlockStore blockStore = Mockito.mock(org.ethereum.db.BlockStore.class);
    Repository repository = Mockito.mock(Repository.class);

    Mockito.when(repository.getSnapshotTo(Mockito.any())).thenReturn(repository);
    Mockito.when(repository.getNonce(Mockito.any())).thenReturn(BigInteger.ZERO);

    Block parent = new BlockBuilder().minGasPrice(BigInteger.ZERO)
            .parent(new BlockGenerator().getGenesisBlock()).build();

    Block block = new BlockBuilder().minGasPrice(BigInteger.TEN)
            .parent(parent).build();

    Mockito.when(blockStore.getBlockByHash(block.getParentHash())).thenReturn(parent);

    BlockValidatorImpl validator = new BlockValidatorBuilder()
            .addPrevMinGasPriceRule()
            .blockStore(blockStore)
            .build();

    Assert.assertFalse(validator.isValid(block));
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:24,代码来源:BlockValidatorTest.java


注:本文中的org.ethereum.db.BlockStore类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。