private boolean isInSync(
      final ChainHead localChain,
      final Optional<ChainHeadEstimate> syncTargetChain,
      final Optional<ChainHeadEstimate> bestPeerChain,
      final long syncTolerance) {
    return isInitialSyncPhaseDone
        && reachedTerminalDifficulty.orElse(true)
        // Sync target may be temporarily empty while we switch sync targets during a sync, so
        // check both the sync target and our best peer to determine if we're in sync or not
        && isInSync(localChain, syncTargetChain, syncTolerance)
        && isInSync(localChain, bestPeerChain, syncTolerance);
  }
Add a listener that will be notified when this node's sync status changes. A node is considered
in-sync if the local chain height is no more than {@code syncTolerance} behind the highest
estimated remote chain height.

@param listener The callback to invoke when the sync status changes
@param syncTolerance The tolerance used to determine whether this node is in-sync. A value of
    zero means that the node is considered in-sync only when the local chain height is greater
    than or equal to the best estimated remote chain height.
@return An {@code Unsubscriber} that can be used to stop listening for these events
ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/state/SyncState.java