本文整理汇总了Java中org.ethereum.util.ByteUtil.longToBytesNoLeadZeroes方法的典型用法代码示例。如果您正苦于以下问题:Java ByteUtil.longToBytesNoLeadZeroes方法的具体用法?Java ByteUtil.longToBytesNoLeadZeroes怎么用?Java ByteUtil.longToBytesNoLeadZeroes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.ethereum.util.ByteUtil
的用法示例。
在下文中一共展示了ByteUtil.longToBytesNoLeadZeroes方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createFakePendingBlock
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
private Block createFakePendingBlock(Block best) {
Trie txsTrie = new TrieImpl();
// creating fake lightweight calculated block with no hashes calculations
return new Block(best.getHash(),
emptyUncleHashList, // uncleHash
new byte[32], //coinbase
new byte[32], // log bloom - from tx receipts
best.getDifficulty(), // difficulty
best.getNumber() + 1, //number
ByteUtil.longToBytesNoLeadZeroes(Long.MAX_VALUE), // max Gas Limit
0, // gas used
best.getTimestamp() + 1, // block time
new byte[0], // extra data
new byte[0], // mixHash (to mine)
new byte[0], // nonce (to mine)
new byte[0],
new byte[0],
new byte[0],
new byte[32], // receiptsRoot
txsTrie.getHash(), // TransactionsRoot-
new byte[32], // stateRoot
Collections.<Transaction>emptyList(), // tx list
Collections.<BlockHeader>emptyList(), // uncle list
ByteUtil.bigIntegerToBytes(BigInteger.ZERO)); //minimum gas price
}
示例2: sendTxAndWait
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
private TransactionReceipt sendTxAndWait(byte[] receiveAddress, byte[] data) throws InterruptedException {
byte[] senderPrivateKey = Hex.decode("");
byte[] fromAddress = ECKey.fromPrivate(senderPrivateKey).getAddress();
BigInteger nonce = ethereum.getRepository().getNonce(fromAddress);
Transaction tx = new Transaction(
ByteUtil.bigIntegerToBytes(nonce),
ByteUtil.longToBytesNoLeadZeroes(ethereum.getGasPrice()),
ByteUtil.longToBytesNoLeadZeroes(200000),
receiveAddress,
ByteUtil.bigIntegerToBytes(BigInteger.valueOf(1)), // 1_000_000_000 gwei, 1_000_000_000_000L szabo, 1_000_000_000_000_000L finney, 1_000_000_000_000_000_000L ether
data,
ethereum.getChainIdForNextBlock());
tx.sign(ECKey.fromPrivate(senderPrivateKey));
logger.info("<=== Sending transaction: " + tx);
ethereum.submitTransaction(tx);
return waitForTx(tx.getHash());
}
示例3: createFakePendingBlock
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
private Block createFakePendingBlock() {
// creating fake lightweight calculated block with no hashes calculations
Block block = new Block(best.getHash(),
BlockchainImpl.EMPTY_LIST_HASH, // uncleHash
new byte[32],
new byte[32], // log bloom - from tx receipts
new byte[0], // difficulty computed right after block creation
best.getNumber() + 1,
ByteUtil.longToBytesNoLeadZeroes(Long.MAX_VALUE), // max Gas Limit
0, // gas used
best.getTimestamp() + 1, // block time
new byte[0], // extra data
new byte[0], // mixHash (to mine)
new byte[0], // nonce (to mine)
new byte[32], // receiptsRoot
new byte[32], // TransactionsRoot
new byte[32], // stateRoot
Collections.<Transaction>emptyList(), // tx list
Collections.<BlockHeader>emptyList()); // uncle list
return block;
}
示例4: RemascTransaction
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
public RemascTransaction(long blockNumber) {
super(ByteUtil.longToBytesNoLeadZeroes(blockNumber - 1),
ZERO_BYTE_ARRAY,
ZERO_BYTE_ARRAY,
PrecompiledContracts.REMASC_ADDR.getBytes(),
ZERO_BYTE_ARRAY,
null,
(byte) 0);
}
示例5: Genesis
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
public Genesis(byte[] parentHash, byte[] unclesHash, byte[] coinbase, byte[] logsBloom,
byte[] difficulty, long number, long gasLimit,
long gasUsed, long timestamp,
byte[] extraData, byte[] mixHash, byte[] nonce,
byte[] bitcoinMergedMiningHeader, byte[] bitcoinMergedMiningMerkleProof,
byte[] bitcoinMergedMiningCoinbaseTransaction, byte[] minimumGasPrice){
super(parentHash, unclesHash, coinbase, logsBloom, difficulty,
number, ByteUtil.longToBytesNoLeadZeroes(gasLimit), gasUsed, timestamp, extraData,
mixHash, nonce, bitcoinMergedMiningHeader, bitcoinMergedMiningMerkleProof,
bitcoinMergedMiningCoinbaseTransaction, EMPTY_TRIE_HASH, EMPTY_TRIE_HASH, EMPTY_TRIE_HASH, null, null, minimumGasPrice);
}
示例6: createTransaction
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
public Transaction createTransaction(ECKey sender, long nonce, byte[] toAddress, BigInteger value, byte[] data) {
Transaction transaction = new Transaction(ByteUtil.longToBytesNoLeadZeroes(nonce),
ByteUtil.longToBytesNoLeadZeroes(gasPrice),
ByteUtil.longToBytesNoLeadZeroes(gasLimit),
toAddress, ByteUtil.bigIntegerToBytes(value),
data,
null);
transaction.sign(sender);
return transaction;
}
示例7: Genesis
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
public Genesis(byte[] parentHash, byte[] unclesHash, byte[] coinbase, byte[] logsBloom,
byte[] difficulty, long number, long gasLimit,
long gasUsed, long timestamp,
byte[] extraData, byte[] mixHash, byte[] nonce){
super(parentHash, unclesHash, coinbase, logsBloom, difficulty,
number, ByteUtil.longToBytesNoLeadZeroes(gasLimit), gasUsed, timestamp, extraData,
mixHash, nonce, null, null);
}
示例8: mine1
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
@Test
public void mine1() throws Exception {
blockchain.setMinerCoinbase(Hex.decode("ee0250c19ad59305b2bdb61f34b45b72fe37154f"));
Block parent = blockchain.getBestBlock();
List<Transaction> pendingTx = new ArrayList<>();
ECKey senderKey = ECKey.fromPrivate(Hex.decode("3ec771c31cac8c0dba77a69e503765701d3c2bb62435888d4ffa38fed60c445c"));
byte[] receiverAddr = Hex.decode("31e2e1ed11951c7091dfba62cd4b7145e947219c");
Transaction tx = new Transaction(new byte[] {0}, new byte[] {1}, ByteUtil.longToBytesNoLeadZeroes(0xfffff),
receiverAddr, new byte[] {77}, new byte[0]);
tx.sign(senderKey);
pendingTx.add(tx);
Block b = blockchain.createNewBlock(parent, pendingTx, Collections.EMPTY_LIST);
System.out.println("Mining...");
Ethash.getForBlock(SystemProperties.getDefault(), b.getNumber()).mineLight(b).get();
System.out.println("Validating...");
boolean valid = Ethash.getForBlock(SystemProperties.getDefault(), b.getNumber()).validate(b.getHeader());
Assert.assertTrue(valid);
System.out.println("Connecting...");
ImportResult importResult = blockchain.tryToConnect(b);
Assert.assertTrue(importResult == ImportResult.IMPORTED_BEST);
System.out.println(Hex.toHexString(blockchain.getRepository().getRoot()));
}
示例9: getTransaction
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
private Transaction getTransaction(final String recipientWalletAddress, final long value,
final byte[] data, final BigInteger nonce) {
return new Transaction(
ByteUtil.bigIntegerToBytes(nonce),
ByteUtil.longToBytesNoLeadZeroes(getEthereum().getGasPrice()),
ByteUtil.longToBytesNoLeadZeroes(GAS_LIMIT),
recipientWalletAddress == null ? new byte[0] : decode(recipientWalletAddress),
ByteUtil.longToBytesNoLeadZeroes(value),
data,
getEthereum().getChainIdForNextBlock());
}