class WorldDownloadState {

  public synchronized boolean checkCompletion(
      final WorldStateStorage worldStateStorage, final BlockHeader header) {
    if (!internalFuture.isDone() && pendingRequests.allTasksCompleted()) {
      if (rootNodeData == null) {
        enqueueRequest(NodeDataRequest.createAccountDataRequest(header.getStateRoot()));
        return false;
      }
      final Updater updater = worldStateStorage.updater();
      updater.putAccountStateTrieNode(header.getStateRoot(), rootNodeData);
      updater.commit();
      internalFuture.complete(null);
      // THere are no more inputs to process so make sure we wake up any threads waiting to dequeue
      // so they can give up waiting.
      notifyAll();
      LOG.info("Finished downloading world state from peers");
      return true;
    } else {
      return false;
    }
  }

  public  WorldDownloadState(
      final CachingTaskCollection<NodeDataRequest> pendingRequests,
      final int maxRequestsWithoutProgress,
      final long minMillisBeforeStalling,
      final Clock clock);

}