本文整理汇总了Java中org.ethereum.facade.Ethereum类的典型用法代码示例。如果您正苦于以下问题:Java Ethereum类的具体用法?Java Ethereum怎么用?Java Ethereum使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Ethereum类属于org.ethereum.facade包,在下文中一共展示了Ethereum类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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());
}
示例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());
}
示例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());
}
示例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();
}
}
}
示例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();
}
}
示例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();
}
}
示例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");
}
示例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);
}
示例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.");
}
}
示例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;
}
示例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;
}
示例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);
}
示例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"));
}
示例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();
}