@Test public void ignoreKnownBlock() { final Bytes32 root = dataStructureUtil.randomBytes32(); when(pendingBlocksPool.contains(root)).thenReturn(true); recentBlockFetcher.requestRecentBlock(root); assertTaskCounts(0, 0, 0); assertThat(importedBlocks).isEmpty(); }
public void requestRecentBlock(final Bytes32 blockRoot) { if (pendingBlocksPool.contains(blockRoot)) { return; } final FetchBlockTask task = fetchBlockTaskFactory.create(eth2Network, blockRoot); if (allTasks.putIfAbsent(blockRoot, task) != null) { task.cancel(); return; } LOG.trace("Queue block to be fetched: {}", blockRoot); queueTask(task); }
FetchRecentBlocksService extends Service { public void requestRecentBlock(final Bytes32 blockRoot) { if (pendingBlocksPool.contains(blockRoot)) { return; } final FetchBlockTask task = fetchBlockTaskFactory.create(eth2Network, blockRoot); if (allTasks.putIfAbsent(blockRoot, task) != null) { task.cancel(); return; } LOG.trace("Queue block to be fetched: {}", blockRoot); queueTask(task); } }
FetchRecentBlocksService extends Service { public void requestRecentBlock(final Bytes32 blockRoot) { if (pendingBlocksPool.contains(blockRoot)) { return; } final FetchBlockTask task = fetchBlockTaskFactory.create(eth2Network, blockRoot); if (allTasks.putIfAbsent(blockRoot, task) != null) { task.cancel(); return; } LOG.trace("Queue block to be fetched: {}", blockRoot); queueTask(task); } FetchRecentBlocksService(
      final AsyncRunner asyncRunner,
      final P2PNetwork<Eth2Peer> eth2Network,
      final PendingPool<SignedBeaconBlock> pendingBlocksPool,
      final FetchBlockTaskFactory fetchBlockTaskFactory,
      final int maxConcurrentRequests); }
FetchRecentBlocksService extends Service { public void requestRecentBlock(final Bytes32 blockRoot) { if (pendingBlocksPool.contains(blockRoot)) { return; } final FetchBlockTask task = fetchBlockTaskFactory.create(eth2Network, blockRoot); if (allTasks.putIfAbsent(blockRoot, task) != null) { task.cancel(); return; } LOG.trace("Queue block to be fetched: {}", blockRoot); queueTask(task); } FetchRecentBlocksService(
      final AsyncRunner asyncRunner,
      final P2PNetwork<Eth2Peer> eth2Network,
      final PendingPool<SignedBeaconBlock> pendingBlocksPool,
      final FetchBlockTaskFactory fetchBlockTaskFactory,
      final int maxConcurrentRequests); static FetchRecentBlocksService create(
      final AsyncRunner asyncRunner,
      final P2PNetwork<Eth2Peer> eth2Network,
      final PendingPool<SignedBeaconBlock> pendingBlocksPool); long subscribeBlockFetched(final BlockSubscriber subscriber); void unsubscribeBlockFetched(final int subscriberId); void requestRecentBlock(final Bytes32 blockRoot); void cancelRecentBlockRequest(final Bytes32 blockRoot); }
FetchRecentBlocksService extends Service { public void requestRecentBlock(final Bytes32 blockRoot) { if (pendingBlocksPool.contains(blockRoot)) { return; } final FetchBlockTask task = fetchBlockTaskFactory.create(eth2Network, blockRoot); if (allTasks.putIfAbsent(blockRoot, task) != null) { task.cancel(); return; } LOG.trace("Queue block to be fetched: {}", blockRoot); queueTask(task); } FetchRecentBlocksService(
      final AsyncRunner asyncRunner,
      final P2PNetwork<Eth2Peer> eth2Network,
      final PendingPool<SignedBeaconBlock> pendingBlocksPool,
      final FetchBlockTaskFactory fetchBlockTaskFactory,
      final int maxConcurrentRequests); static FetchRecentBlocksService create(
      final AsyncRunner asyncRunner,
      final P2PNetwork<Eth2Peer> eth2Network,
      final PendingPool<SignedBeaconBlock> pendingBlocksPool); long subscribeBlockFetched(final BlockSubscriber subscriber); void unsubscribeBlockFetched(final int subscriberId); void requestRecentBlock(final Bytes32 blockRoot); void cancelRecentBlockRequest(final Bytes32 blockRoot);  }