code: func (b *blockManager) BlockHeadersSynced() bool {
  	b.syncPeerMutex.RLock()
  	defer b.syncPeerMutex.RUnlock()
  
  	// Figure out the latest block we know.
  	header, height, err := b.server.BlockHeaders.ChainTip()
  	if err != nil {
  		return false
  	}
  
  	// There is no last checkpoint if checkpoints are disabled or there are
  	// none for this current network.
  	checkpoints := b.server.chainParams.Checkpoints
  	if len(checkpoints) != 0 {
  		// We aren't current if the newest block we know of isn't ahead
  		// of all checkpoints.
  		if checkpoints[len(checkpoints)-1].Height >= int32(height) {
  			return false
  		}
  	}
  
  	// If we have a syncPeer and are below the block we are syncing to, we
  	// are not current.
  	if b.syncPeer != nil && int32(height) < b.syncPeer.LastBlock() {
  		return false
  	}
  
  	// If our time source (median times of all the connected peers) is at
  	// least 24 hours ahead of our best known block, we aren't current.
  	minus24Hours := b.server.timeSource.AdjustedTime().Add(-24 * time.Hour)
  	if header.Timestamp.Before(minus24Hours) {
  		return false
  	}
  
  	// If we have no sync peer, we can assume we're current for now.
  	if b.syncPeer == nil {
  		return true
  	}
  
  	// If we have a syncPeer and the peer reported a higher known block
  	// height on connect than we know the peer already has, we're probably
  	// not current. If the peer is lying to us, other code will disconnect
  	// it and then we'll re-check and notice that we're actually current.
  	return b.syncPeer.LastBlock() >= b.syncPeer.StartingHeight()
  }
docs: // BlockHeadersSynced returns whether or not the block manager believes its
  // block headers are synced with the connected peers.