List of usage examples for org.bouncycastle.pqc.math.linearalgebra ByteUtils clone
public static byte[] clone(byte[] array)
From source file:co.rsk.blockchain.utils.BlockGenerator.java
License:Open Source License
public Block createChildBlock(Block parent, long fees, List<BlockHeader> uncles, byte[] difficulty) { List<Transaction> txs = new ArrayList<>(); byte[] unclesListHash = HashUtil.keccak256(BlockHeader.getUnclesEncodedEx(uncles)); return new Block(parent.getHash().getBytes(), // parent hash unclesListHash, // uncle hash parent.getCoinbase().getBytes(), ByteUtils.clone(new Bloom().getData()), difficulty, // difficulty parent.getNumber() + 1, parent.getGasLimit(), parent.getGasUsed(), parent.getTimestamp() + ++count, EMPTY_BYTE_ARRAY, // extraData EMPTY_BYTE_ARRAY, // mixHash BigInteger.ZERO.toByteArray(), // provisory nonce EMPTY_TRIE_HASH, // receipts root BlockChainImpl.calcTxTrie(txs), // transaction root ByteUtils.clone(parent.getStateRoot()), //EMPTY_TRIE_HASH, // state root txs, // transaction list uncles, // uncle list null, Coin.valueOf(fees));// w ww. ja va2 s . c om // return createChildBlock(parent, 0); }
From source file:co.rsk.blockchain.utils.BlockGenerator.java
License:Open Source License
public Block createChildBlock(Block parent, List<Transaction> txs, List<BlockHeader> uncles, long difficulty, BigInteger minGasPrice, byte[] gasLimit) { if (txs == null) { txs = new ArrayList<>(); }//from ww w . j av a 2 s.c o m if (uncles == null) { uncles = new ArrayList<>(); } byte[] unclesListHash = HashUtil.keccak256(BlockHeader.getUnclesEncodedEx(uncles)); BlockHeader newHeader = new BlockHeader(parent.getHash().getBytes(), unclesListHash, parent.getCoinbase().getBytes(), ByteUtils.clone(new Bloom().getData()), new byte[] { 1 }, parent.getNumber() + 1, gasLimit, 0, parent.getTimestamp() + ++count, new byte[] {}, new byte[] {}, new byte[] {}, new byte[] {}, (minGasPrice != null) ? minGasPrice.toByteArray() : null, CollectionUtils.size(uncles)); if (difficulty == 0) { newHeader.setDifficulty(difficultyCalculator.calcDifficulty(newHeader, parent.getHeader())); } else { newHeader.setDifficulty(new BlockDifficulty(BigInteger.valueOf(difficulty))); } newHeader.setTransactionsRoot(Block.getTxTrie(txs).getHash().getBytes()); newHeader.setStateRoot(ByteUtils.clone(parent.getStateRoot())); Block newBlock = new Block(newHeader, txs, uncles); return newBlock; }
From source file:co.rsk.db.ContractDetailsImpl.java
License:Open Source License
public ContractDetailsImpl(byte[] address, Trie trie, byte[] code, TrieStore.Pool trieStorePool, int memoryStorageLimit) { this.address = ByteUtils.clone(address); this.trie = trie; this.code = ByteUtils.clone(code); this.codeHash = getCodeHash(code); this.trieStorePool = trieStorePool; this.memoryStorageLimit = memoryStorageLimit; if (this.trie == null) { this.trie = this.newTrie(); }/*from ww w .jav a2 s. c o m*/ }
From source file:co.rsk.db.ContractDetailsImpl.java
License:Open Source License
@Override public byte[] getCode() { return ByteUtils.clone(this.code); }
From source file:co.rsk.db.ContractDetailsImpl.java
License:Open Source License
@Override public void setCode(byte[] code) { this.code = ByteUtils.clone(code); this.codeHash = getCodeHash(code); }
From source file:co.rsk.db.ContractDetailsImpl.java
License:Open Source License
@Override public byte[] getAddress() { return ByteUtils.clone(this.address); }
From source file:co.rsk.db.ContractDetailsImpl.java
License:Open Source License
@Override public void setAddress(byte[] address) { this.address = ByteUtils.clone(address); }
From source file:com.raphfrk.craftproxyclient.net.types.values.BulkData.java
License:Open Source License
public BulkData(byte[] chunkData, int[] chunkX, int[] chunkZ, boolean skylight, short[] bitmap, short[] add) { this.chunkData = ByteUtils.clone(chunkData); this.chunkX = Arrays.copyOf(chunkX, chunkX.length); this.chunkZ = Arrays.copyOf(chunkZ, chunkZ.length); this.skylight = skylight; this.bitmap = new short[bitmap.length]; System.arraycopy(bitmap, 0, this.bitmap, 0, bitmap.length); this.add = new short[add.length]; System.arraycopy(add, 0, this.add, 0, add.length); }
From source file:org.ethereum.core.BlockHeader.java
License:Open Source License
public BlockHeader(byte[] parentHash, byte[] unclesHash, byte[] coinbase, byte[] logsBloom, byte[] difficulty, long number, byte[] gasLimit, long gasUsed, long timestamp, byte[] extraData, byte[] bitcoinMergedMiningHeader, byte[] bitcoinMergedMiningMerkleProof, byte[] bitcoinMergedMiningCoinbaseTransaction, byte[] minimumGasPrice, int uncleCount) { this.parentHash = parentHash; this.unclesHash = unclesHash; this.coinbase = new RskAddress(coinbase); this.logsBloom = logsBloom; this.difficulty = RLP.parseBlockDifficulty(difficulty); this.number = number; this.gasLimit = gasLimit; this.gasUsed = gasUsed; this.timestamp = timestamp; this.extraData = extraData; this.stateRoot = ByteUtils.clone(EMPTY_TRIE_HASH); this.minimumGasPrice = RLP.parseSignedCoinNonNullZero(minimumGasPrice); this.receiptTrieRoot = ByteUtils.clone(EMPTY_TRIE_HASH); this.uncleCount = uncleCount; this.paidFees = Coin.ZERO; this.bitcoinMergedMiningHeader = bitcoinMergedMiningHeader; this.bitcoinMergedMiningMerkleProof = bitcoinMergedMiningMerkleProof; this.bitcoinMergedMiningCoinbaseTransaction = bitcoinMergedMiningCoinbaseTransaction; }