• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Ethereum类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Web3RskImpl

import org.ethereum.facade.Ethereum; //导入依赖的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: eth_mining

import org.ethereum.facade.Ethereum; //导入依赖的package包/类
@Test
public void eth_mining()  {
    Ethereum ethMock = Web3Mocks.getMockEthereum();
    WorldManager worldManager = Web3Mocks.getMockWorldManager();
    RskSystemProperties mockProperties = Web3Mocks.getMockProperties();
    MinerClient minerClient = new SimpleMinerClient();
    PersonalModule personalModule = new PersonalModuleWalletDisabled();
    Web3 web3 = new Web3Impl(ethMock, worldManager, mockProperties, minerClient, null, personalModule, null, Web3Mocks.getMockChannelManager(), Web3Mocks.getMockRepository(), null, null);

    Assert.assertTrue("Node is not mining", !web3.eth_mining());
try {
minerClient.mine();

Assert.assertTrue("Node is mining", web3.eth_mining());

} finally {
    minerClient.stop();
}
    Assert.assertTrue("Node is not mining", !web3.eth_mining());
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:21,代码来源:Web3ImplTest.java


示例3: eth_compileSolidity

import org.ethereum.facade.Ethereum; //导入依赖的package包/类
@Test
@Ignore
public void eth_compileSolidity() throws Exception {
    RskSystemProperties systemProperties = Mockito.mock(RskSystemProperties.class);
    String solc = System.getProperty("solc");
    if(StringUtils.isEmpty(solc))
        solc = "/usr/bin/solc";

    Mockito.when(systemProperties.customSolcPath()).thenReturn(solc);
    Ethereum eth = Mockito.mock(Ethereum.class);
    EthModule ethModule = new EthModule(ConfigHelper.CONFIG, eth, new EthModuleSolidityEnabled(new SolidityCompiler(systemProperties)), null);
    PersonalModule personalModule = new PersonalModuleWalletDisabled();
    Web3Impl web3 = new Web3RskImpl(eth, null, systemProperties, null, null, personalModule, ethModule, Web3Mocks.getMockChannelManager(), Web3Mocks.getMockRepository(), null, null, null, null);
    String contract = "pragma solidity ^0.4.1; contract rsk { function multiply(uint a) returns(uint d) {   return a * 7;   } }";

    Map<String, CompilationResultDTO> result = web3.eth_compileSolidity(contract);

    org.junit.Assert.assertNotNull(result);

    CompilationResultDTO dto = result.get("rsk");

    if (dto == null)
        dto = result.get("<stdin>:rsk");

    org.junit.Assert.assertEquals(contract , dto.info.getSource());
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:27,代码来源:Web3ImplTest.java


示例4: eth_compileSolidityWithoutSolidity

import org.ethereum.facade.Ethereum; //导入依赖的package包/类
@Test
public void eth_compileSolidityWithoutSolidity() throws Exception {
    SystemProperties systemProperties = Mockito.mock(SystemProperties.class);
    String solc = System.getProperty("solc");
    if(StringUtils.isEmpty(solc))
        solc = "/usr/bin/solc";

    Mockito.when(systemProperties.customSolcPath()).thenReturn(solc);

    Wallet wallet = WalletFactory.createWallet();
    Ethereum eth = Web3Mocks.getMockEthereum();
    WorldManager worldManager = Web3Mocks.getMockWorldManager();
    EthModule ethModule = new EthModule(ConfigHelper.CONFIG, eth, new EthModuleSolidityDisabled(), new EthModuleWalletEnabled(ConfigHelper.CONFIG, eth, wallet, null));
    Web3Impl web3 = new Web3RskImpl(eth, worldManager, ConfigHelper.CONFIG, null, null, new PersonalModuleWalletDisabled(), ethModule, Web3Mocks.getMockChannelManager(), Web3Mocks.getMockRepository(), null, null, null, null);

    String contract = "pragma solidity ^0.4.1; contract rsk { function multiply(uint a) returns(uint d) {   return a * 7;   } }";

    Map<String, CompilationResultDTO> result = web3.eth_compileSolidity(contract);

    org.junit.Assert.assertNotNull(result);
    org.junit.Assert.assertEquals(0, result.size());
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:23,代码来源:Web3ImplTest.java


示例5: main

import org.ethereum.facade.Ethereum; //导入依赖的package包/类
public static void main(String args[]) throws IOException, URISyntaxException {
    CLIInterface.call(args);

    final SystemProperties config = SystemProperties.getDefault();
    final boolean actionBlocksLoader = !config.blocksLoader().equals("");
    final boolean actionGenerateDag = !StringUtils.isEmpty(System.getProperty("ethash.blockNumber"));

    if (actionBlocksLoader || actionGenerateDag) {
        config.setSyncEnabled(false);
        config.setDiscoveryEnabled(false);
    }

    if (actionGenerateDag) {
        new Ethash(config, Long.parseLong(System.getProperty("ethash.blockNumber"))).getFullDataset();
        // DAG file has been created, lets exit
        System.exit(0);
    } else {
        Ethereum ethereum = EthereumFactory.createEthereum();

        if (actionBlocksLoader) {
            ethereum.getBlockLoader().loadBlocks();
        }
    }
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:25,代码来源:Start.java


示例6: checkHeaders

import org.ethereum.facade.Ethereum; //导入依赖的package包/类
public static void checkHeaders(Ethereum ethereum, AtomicInteger fatalErrors) {
    int blockNumber = (int) ethereum.getBlockchain().getBestBlock().getHeader().getNumber();
    byte[] lastParentHash = null;
    testLogger.info("Checking headers from best block: {}", blockNumber);

    try {
        while (blockNumber >= 0) {
            Block currentBlock = ethereum.getBlockchain().getBlockByNumber(blockNumber);
            if (lastParentHash != null) {
                assert FastByteComparisons.equal(currentBlock.getHash(), lastParentHash);
            }
            lastParentHash = currentBlock.getHeader().getParentHash();
            assert lastParentHash != null;
            blockNumber--;
        }

        testLogger.info("Checking headers successful, ended on block: {}", blockNumber + 1);
    } catch (Exception | AssertionError ex) {
        testLogger.error(String.format("Block header validation error on block #%s", blockNumber), ex);
        fatalErrors.incrementAndGet();
    }
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:23,代码来源:BlockchainValidation.java


示例7: checkFastHeaders

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


示例8: fullCheck

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


示例9: test

import org.ethereum.facade.Ethereum; //导入依赖的package包/类
@Test
    public void test() throws Exception {
//        remoteJsonRpc = new URL("http://whisper-1.ether.camp:8545");
//        Node node = new Node("enode://52994910050f13cbd7848f02709f2f5ebccc363f13dafc4ec201e405e2f143ebc9c440935b3217073f6ec47f613220e0bc6b7b34274b7d2de125b82a2acd34ee" +
//                "@whisper-1.ether.camp:30303");

        remoteJsonRpc = new URL("http://localhost:8545");
        Node node = new Node("enode://6ed738b650ac2b771838506172447dc683b7e9dae7b91d699a48a0f94651b1a0d2e2ef01c6fffa22f762aaa553286047f0b0bb39f2e3a24b2a18fe1b9637dcbe" +
                "@localhost:10003");

        Ethereum ethereum = EthereumFactory.createEthereum(Config.class);
        ethereum.connect(
                node.getHost(),
                node.getPort(),
                Hex.toHexString(node.getId()));
        Thread.sleep(1000000000);
    }
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:18,代码来源:ShhLongRun.java


示例10: relaunchTest

import org.ethereum.facade.Ethereum; //导入依赖的package包/类
@Ignore
@Test
public void relaunchTest() throws InterruptedException {

    while (true) {
        Ethereum ethereum = EthereumFactory.createEthereum();
        Block bestBlock = ethereum.getBlockchain().getBestBlock();
        Assert.assertNotNull(bestBlock);
        final CountDownLatch latch = new CountDownLatch(1);
        ethereum.addListener(new EthereumListenerAdapter() {
            int counter = 0;
            @Override
            public void onBlock(Block block, List<TransactionReceipt> receipts) {
                counter++;
                if (counter > 1100) latch.countDown();
            }
        });
        System.out.println("### Waiting for some blocks to be imported...");
        latch.await();
        System.out.println("### Closing Ethereum instance");
        ethereum.close();
        Thread.sleep(5000);
        System.out.println("### Closed.");
    }
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:26,代码来源:CloseTest.java


示例11: EthModule

import org.ethereum.facade.Ethereum; //导入依赖的package包/类
@Autowired
public EthModule(RskSystemProperties config, Ethereum eth, EthModuleSolidity ethModuleSolidity, EthModuleWallet ethModuleWallet) {
    this.config = config;
    this.eth = eth;
    this.ethModuleSolidity = ethModuleSolidity;
    this.ethModuleWallet = ethModuleWallet;
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:8,代码来源:EthModule.java


示例12: TxBuilderEx

import org.ethereum.facade.Ethereum; //导入依赖的package包/类
public TxBuilderEx(RskSystemProperties config,
                   Ethereum ethereum,
                   Repository repository,
                   BlockProcessor nodeBlockProcessor,
                   PendingState pendingState) {
    this.config = config;
    this.ethereum = ethereum;
    this.repository = repository;
    this.nodeBlockProcessor = nodeBlockProcessor;
    this.pendingState = pendingState;
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:12,代码来源:TxBuilderEx.java


示例13: Web3Impl

import org.ethereum.facade.Ethereum; //导入依赖的package包/类
protected Web3Impl(Ethereum eth,
                   WorldManager worldManager,
                   RskSystemProperties config,
                   MinerClient minerClient,
                   MinerServer minerServer,
                   PersonalModule personalModule,
                   EthModule ethModule,
                   ChannelManager channelManager,
                   org.ethereum.facade.Repository repository,
                   PeerScoringManager peerScoringManager,
                   PeerServer peerServer) {
    this.eth = eth;
    this.repository = repository;
    this.minerClient = minerClient;
    this.minerServer = minerServer;
    this.personalModule = personalModule;
    this.ethModule = ethModule;
    this.channelManager = channelManager;
    this.peerScoringManager = peerScoringManager;
    this.peerServer = peerServer;
    this.blockchain = worldManager.getBlockchain();
    this.nodeBlockProcessor = worldManager.getNodeBlockProcessor();
    this.hashRateCalculator = worldManager.getHashRateCalculator();
    this.configCapabilities = worldManager.getConfigCapabilities();
    this.blockStore = worldManager.getBlockStore();
    this.pendingState = worldManager.getPendingState();
    this.config = config;
    initialBlockNumber = this.blockchain.getBestBlock().getNumber();

    compositeEthereumListener = new CompositeEthereumListener();

    compositeEthereumListener.addListener(this.setupListener());

    this.eth.addListener(compositeEthereumListener);
    personalModule.init(this.config);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:37,代码来源:Web3Impl.java


示例14: getRpcModules

import org.ethereum.facade.Ethereum; //导入依赖的package包/类
@Test
public void getRpcModules() {
    Ethereum eth = Web3Mocks.getMockEthereum();
    WorldManager worldManager = Web3Mocks.getMockWorldManager();
    PersonalModule pm = new PersonalModuleWalletDisabled();
    Repository repository = Web3Mocks.getMockRepository();
    Web3Impl web3 = new Web3RskImpl(eth, worldManager, ConfigHelper.CONFIG, null, null, pm, null, null, repository, null, null, null, null);

    Map<String, String> result = web3.rpc_modules();

    Assert.assertNotNull(result);
    Assert.assertFalse(result.isEmpty());
    Assert.assertTrue(result.containsKey("eth"));
    Assert.assertEquals("1.0", result.get("eth"));
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:16,代码来源:Web3ImplRpcTest.java


示例15: eth_coinbase

import org.ethereum.facade.Ethereum; //导入依赖的package包/类
@Test
public void eth_coinbase()  {
    String originalCoinbase = "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347";
    MinerServer minerServerMock = Mockito.mock(MinerServer.class);
    Mockito.when(minerServerMock.getCoinbaseAddress()).thenReturn(Hex.decode(originalCoinbase));

    Ethereum ethMock = Web3Mocks.getMockEthereum();
    WorldManager wmMock = Web3Mocks.getMockWorldManager();
    RskSystemProperties mockProperties = Web3Mocks.getMockProperties();
    PersonalModule personalModule = new PersonalModuleWalletDisabled();
    Web3 web3 = new Web3Impl(ethMock, wmMock, mockProperties, null, minerServerMock, personalModule, null, Web3Mocks.getMockChannelManager(), Web3Mocks.getMockRepository(), null, null);

    Assert.assertEquals("0x" + originalCoinbase, web3.eth_coinbase());
    Mockito.verify(minerServerMock, Mockito.times(1)).getCoinbaseAddress();
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:16,代码来源:Web3ImplTest.java


示例16: createWeb3Mocked

import org.ethereum.facade.Ethereum; //导入依赖的package包/类
private Web3Impl createWeb3Mocked(World world, Block block1) {
    SimpleWorldManager worldManager = new SimpleWorldManager();
    worldManager.setBlockchain(world.getBlockChain());
    PendingState pendingState = new PendingStateImpl(ConfigHelper.CONFIG, world.getBlockChain(), world.getRepository(), world.getBlockChain().getBlockStore(), null, null, 10, 100);
    worldManager.setPendingState(pendingState);
    Ethereum ethMock = Mockito.mock(Ethereum.class);
    ProgramResult res = new ProgramResult();
    res.setHReturn(TypeConverter.stringHexToByteArray("0x0000000000000000000000000000000000000000000000000000000064617665"));
    Mockito.when(ethMock.callConstant(Matchers.any())).thenReturn(res);
    return createWeb3(ethMock, worldManager);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:12,代码来源:Web3ImplTest.java


示例17: createWeb3

import org.ethereum.facade.Ethereum; //导入依赖的package包/类
private Web3Impl createWeb3(Ethereum eth, WorldManager worldManager) {
    wallet = WalletFactory.createWallet();
    PersonalModuleWalletEnabled personalModule = new PersonalModuleWalletEnabled(ConfigHelper.CONFIG, eth, wallet, worldManager.getPendingState());
    EthModule ethModule = new EthModule(ConfigHelper.CONFIG, eth, new EthModuleSolidityDisabled(), new EthModuleWalletEnabled(ConfigHelper.CONFIG, eth, wallet, worldManager.getPendingState()));
    MinerClient minerClient = new SimpleMinerClient();
    ChannelManager channelManager = new SimpleChannelManager();
    return new Web3RskImpl(eth, worldManager, ConfigHelper.CONFIG, minerClient, Web3Mocks.getMockMinerServer(), personalModule, ethModule, channelManager, Web3Mocks.getMockRepository(), null, null, null, null);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:9,代码来源:Web3ImplTest.java


示例18: main

import org.ethereum.facade.Ethereum; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    sLogger.info("Starting EthereumJ!");

    class SampleConfig extends MordenSampleConfig {
        @Bean
        public MordenSample sampleBean() {
            return new MordenSample();
        }
    }

    Ethereum ethereum = EthereumFactory.createEthereum(SampleConfig.class);
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:13,代码来源:MordenSample.java


示例19: main

import org.ethereum.facade.Ethereum; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    sLogger.info("Starting EthereumJ!");

    class SampleConfig extends RopstenSampleConfig {
        @Bean
        public RopstenSample sampleBean() {
            return new RopstenSample();
        }
    }

    Ethereum ethereum = EthereumFactory.createEthereum(SampleConfig.class);
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:13,代码来源:RopstenSample.java


示例20: GenerateTransactionOnBlockMinedListener

import org.ethereum.facade.Ethereum; //导入依赖的package包/类
public GenerateTransactionOnBlockMinedListener(Logger logger, Ethereum ethereum, AptoideAccounts
				.Account source, AptoideAccounts.Account dest) {
	this.logger = logger;
	this.ethereum = ethereum;
	this.source = source;
	this.dest = dest;
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:8,代码来源:GenerateTransactionOnBlockMinedListener.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Subject类代码示例发布时间:2022-05-22
下一篇:
Java HTTP2CServerConnectionFactory类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap