Search in sources :

Example 1 with MinimumGasPriceCalculator

use of co.rsk.mine.MinimumGasPriceCalculator 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);
}
Also used : Coin(co.rsk.core.Coin) SimpleRskTransaction(co.rsk.peg.simples.SimpleRskTransaction) SimpleRskTransaction(co.rsk.peg.simples.SimpleRskTransaction) MinimumGasPriceCalculator(co.rsk.mine.MinimumGasPriceCalculator) ArrayList(java.util.ArrayList) SimpleBlock(co.rsk.peg.simples.SimpleBlock)

Aggregations

Coin (co.rsk.core.Coin)1 MinimumGasPriceCalculator (co.rsk.mine.MinimumGasPriceCalculator)1 SimpleBlock (co.rsk.peg.simples.SimpleBlock)1 SimpleRskTransaction (co.rsk.peg.simples.SimpleRskTransaction)1 ArrayList (java.util.ArrayList)1