use of org.web3j.protocol.core.methods.response.EthBlock.Block in project teku by ConsenSys.
the class BlockBasedEth1HeadTrackerTest method block.
private Block block(final long blockNumber) {
final Block block = new Block();
block.setNumber("0x" + Long.toHexString(blockNumber));
return block;
}
use of org.web3j.protocol.core.methods.response.EthBlock.Block in project teku by ConsenSys.
the class Eth1DepositManagerTest method notifyHeadBlock.
private void notifyHeadBlock(final BigInteger blockNumber, final long timestamp) {
final Block latestBlock = block(blockNumber, timestamp);
when(eth1Provider.getGuaranteedEth1Block(UInt64.valueOf(blockNumber))).thenReturn(SafeFuture.completedFuture(latestBlock));
final ArgumentCaptor<HeadUpdatedSubscriber> captor = ArgumentCaptor.forClass(HeadUpdatedSubscriber.class);
verify(eth1HeadTracker, atLeastOnce()).subscribe(captor.capture());
captor.getValue().onHeadUpdated(UInt64.valueOf(blockNumber));
}
use of org.web3j.protocol.core.methods.response.EthBlock.Block in project teku by ConsenSys.
the class Eth1DepositManagerTest method block.
private Block block(final BigInteger number, final long timestamp) {
final Block block = mock(Block.class);
when(block.getNumber()).thenReturn(number);
when(block.getTimestamp()).thenReturn(BigInteger.valueOf(timestamp));
when(block.getHash()).thenReturn(Bytes32.ZERO.toHexString());
return block;
}
use of org.web3j.protocol.core.methods.response.EthBlock.Block in project teku by ConsenSys.
the class BlockBasedEth1HeadTracker method onLatestBlockHead.
private void onLatestBlockHead(final Block headBlock) {
final UInt64 headBlockNumber = UInt64.valueOf(headBlock.getNumber());
if (headBlockNumber.compareTo(config.getEth1FollowDistance()) < 0) {
LOG.debug("Not processing Eth1 blocks because chain has not reached minimum follow distance");
return;
}
final UInt64 newHeadAtFollowDistance = headBlockNumber.minus(config.getEth1FollowDistance());
if (headAtFollowDistance.map(current -> current.compareTo(newHeadAtFollowDistance) < 0).orElse(true)) {
if (reachedHead.compareAndSet(false, true)) {
reachedHead.set(true);
}
headAtFollowDistance = Optional.of(newHeadAtFollowDistance);
LOG.debug("ETH1 block at follow distance updated to {}", newHeadAtFollowDistance);
subscribers.deliver(HeadUpdatedSubscriber::onHeadUpdated, newHeadAtFollowDistance);
}
}
use of org.web3j.protocol.core.methods.response.EthBlock.Block in project teku by ConsenSys.
the class Eth1BlockFetcherTest method block.
private Block block(final int blockNumber, final UInt64 blockTimestamp, final Bytes32 blockHash) {
final Block block = new Block();
block.setNumber("0x" + Integer.toHexString(blockNumber));
block.setTimestamp("0x" + Long.toHexString(blockTimestamp.longValue()));
block.setHash(blockHash.toHexString());
return block;
}
Aggregations