use of co.rsk.peg.simples.SimpleRskTransaction in project rskj by rsksmart.
the class BlockGenerator method getBlockChain.
public List<Block> getBlockChain(Block parent, int size, int ntxs, boolean withUncles, boolean withMining, Long difficulty) {
List<Block> chain = new ArrayList<Block>();
List<BlockHeader> uncles = new ArrayList<>();
int chainSize = 0;
while (chainSize < size) {
List<Transaction> txs = new ArrayList<>();
for (int ntx = 0; ntx < ntxs; ntx++) {
txs.add(new SimpleRskTransaction(null));
}
if (difficulty == null) {
difficulty = 0l;
}
Block newblock = createChildBlock(parent, txs, uncles, difficulty, null);
if (withMining) {
newblock = BlockMiner.mineBlock(newblock);
}
chain.add(newblock);
if (withUncles) {
uncles = new ArrayList<>();
Block newuncle = createChildBlock(parent, ntxs);
chain.add(newuncle);
uncles.add(newuncle.getHeader());
newuncle = createChildBlock(parent, ntxs);
chain.add(newuncle);
uncles.add(newuncle.getHeader());
}
parent = newblock;
chainSize++;
}
return chain;
}
use of co.rsk.peg.simples.SimpleRskTransaction in project rskj by rsksmart.
the class BlockGenerator method createSimpleChildBlock.
public Block createSimpleChildBlock(Block parent, int ntxs) {
Bloom logBloom = new Bloom();
List<Transaction> txs = new ArrayList<>();
for (int ntx = 0; ntx < ntxs; ntx++) {
txs.add(new SimpleRskTransaction(PegTestUtils.createHash3().getBytes()));
}
return new SimpleBlock(// parent hash
parent.getHash().getBytes(), // uncle hash
EMPTY_LIST_HASH, // coinbase
parent.getCoinbase().getBytes(), // logs bloom
logBloom.getData(), // difficulty
parent.getDifficulty().getBytes(), parent.getNumber() + 1, parent.getGasLimit(), parent.getGasUsed(), parent.getTimestamp() + ++count, // extraData
EMPTY_BYTE_ARRAY, // mixHash
EMPTY_BYTE_ARRAY, // provisory nonce
BigInteger.ZERO.toByteArray(), // receipts root
EMPTY_TRIE_HASH, // transaction receipts
EMPTY_TRIE_HASH, // state root
EMPTY_TRIE_HASH, // transaction list
txs, // uncle list
null);
}
use of co.rsk.peg.simples.SimpleRskTransaction in project rskj by rsksmart.
the class BlockGenerator method createBlock.
public Block createBlock(int number, int ntxs) {
Bloom logBloom = new Bloom();
Block parent = getGenesisBlock();
List<Transaction> txs = new ArrayList<>();
for (int ntx = 0; ntx < ntxs; ntx++) {
txs.add(new SimpleRskTransaction(null));
}
Coin previousMGP = parent.getMinimumGasPrice() != null ? parent.getMinimumGasPrice() : Coin.valueOf(10L);
Coin minimumGasPrice = new MinimumGasPriceCalculator().calculate(previousMGP, Coin.valueOf(100L));
return new Block(// parent hash
parent.getHash().getBytes(), // uncle hash
EMPTY_LIST_HASH, // coinbase
parent.getCoinbase().getBytes(), // logs bloom
logBloom.getData(), // difficulty
parent.getDifficulty().getBytes(), number, parent.getGasLimit(), parent.getGasUsed(), parent.getTimestamp() + ++count, // extraData
EMPTY_BYTE_ARRAY, // mixHash
EMPTY_BYTE_ARRAY, // provisory nonce
BigInteger.ZERO.toByteArray(), // receipts root
EMPTY_TRIE_HASH, // transaction receipts
EMPTY_TRIE_HASH, // state root
EMPTY_TRIE_HASH, // transaction list
txs, // uncle list
null, minimumGasPrice.getBytes(), Coin.ZERO);
}
use of co.rsk.peg.simples.SimpleRskTransaction in project rskj by rsksmart.
the class BlockGenerator method createChildBlock.
public Block createChildBlock(Block parent, int ntxs, long difficulty) {
List<Transaction> txs = new ArrayList<>();
for (int ntx = 0; ntx < ntxs; ntx++) {
txs.add(new SimpleRskTransaction(null));
}
List<BlockHeader> uncles = new ArrayList<>();
return createChildBlock(parent, txs, uncles, difficulty, null);
}
Aggregations