use of org.ethereum.core.BlockHeader in project rskj by rsksmart.
the class BlockHeaderBuilder method build.
public static BlockHeader build(BlockHeaderTck headerTck) {
BlockHeader header = new BlockHeader(parseData(headerTck.getParentHash()), parseData(headerTck.getUncleHash()), parseData(headerTck.getCoinbase()), parseData(headerTck.getBloom()), parseNumericData(headerTck.getDifficulty()), getPositiveLong(headerTck.getNumber()), parseData(headerTck.getGasLimit()), getPositiveLong(headerTck.getGasUsed()), getPositiveLong(headerTck.getTimestamp()), parseData(headerTck.getExtraData()), null, 0);
header.setReceiptsRoot(parseData(headerTck.getReceiptTrie()));
header.setTransactionsRoot(parseData(headerTck.getTransactionsTrie()));
header.setStateRoot(parseData(headerTck.getStateRoot()));
return header;
}
use of org.ethereum.core.BlockHeader in project rskj by rsksmart.
the class DifficultyRuleTest method parentDifficultyLessHeaderDifficulty.
@Ignore
// pass rule
@Test
public void parentDifficultyLessHeaderDifficulty() {
BlockHeader header = getHeader(10004);
BlockHeader parent = getHeader(10000);
assertTrue(rule.validate(header, parent));
}
use of org.ethereum.core.BlockHeader in project rskj by rsksmart.
the class ParentGasLimitRuleTest method parentGasLimitTooGreaterThanGasLimit.
// no pass rule
@Test
public void parentGasLimitTooGreaterThanGasLimit() {
BlockHeader header = getHeader(9);
BlockHeader parent = getHeader(100);
assertFalse(rule.validate(header, parent));
}
use of org.ethereum.core.BlockHeader in project rskj by rsksmart.
the class ParentGasLimitRuleTest method parentGasLimitTooLessThanGasLimit.
// no pass rule
@Test
public void parentGasLimitTooLessThanGasLimit() {
BlockHeader header = getHeader(100);
BlockHeader parent = getHeader(9);
assertFalse(rule.validate(header, parent));
}
use of org.ethereum.core.BlockHeader in project rskj by rsksmart.
the class FamilyUtils method getUsedUncles.
public static Set<Keccak256> getUsedUncles(BlockStore blockStore, long blockNumber, byte[] parentHash, int limitNum) {
Set<Keccak256> ret = new HashSet<>();
if (blockStore == null) {
return ret;
}
long minNumber = max(0, blockNumber - limitNum);
Block it = blockStore.getBlockByHash(parentHash);
while (it != null && it.getNumber() >= minNumber) {
for (BlockHeader uncle : it.getUncleList()) {
ret.add(uncle.getHash());
}
it = blockStore.getBlockByHash(it.getParentHash().getBytes());
}
return ret;
}
Aggregations