src/rpc/core_rpc_server.cpp
/// All the common (untemplated) code for use_bootstrap_daemon_if_necessary.  Returns a held lock
/// if we need to bootstrap, an unheld one if we don't.
All the common (untemplated) code for use_bootstrap_daemon_if_necessary.  Returns a held lock
if we need to bootstrap, an unheld one if we don't.
All the common ( untemplated ) code for use_bootstrap_daemon_if_necessary . Returns a held lock if we need to bootstrap an unheld one if we don ' t .
std::unique_lock<std::shared_mutex> core_rpc_server::should_bootstrap_lock()
  {
    if (!m_should_use_bootstrap_daemon)
        return {};
    std::unique_lock lock{m_bootstrap_daemon_mutex};
    if (!m_bootstrap_daemon)
    {
      lock.unlock();
      return lock;
    }
    auto current_time = std::chrono::system_clock::now();
    if (!m_p2p.get_payload_object().no_sync() &&
        current_time - m_bootstrap_height_check_time > 30s)  
    {
      m_bootstrap_height_check_time = current_time;
      std::optional<uint64_t> bootstrap_daemon_height = m_bootstrap_daemon->get_height();
      if (!bootstrap_daemon_height)
      {
        MERROR("Failed to fetch bootstrap daemon height");
        lock.unlock();
        return lock;
      }
      uint64_t target_height = m_core.get_target_blockchain_height();
      if (bootstrap_daemon_height < target_height)
      {
        MINFO("Bootstrap daemon is out of sync");
        lock.unlock();
        m_bootstrap_daemon->set_failed();
        return lock;
      }
      uint64_t top_height           = m_core.get_current_blockchain_height();
      m_should_use_bootstrap_daemon = top_height + 10 < bootstrap_daemon_height;
      MINFO((m_should_use_bootstrap_daemon ? "Using" : "Not using") << " the bootstrap daemon (our height: " << top_height << ", bootstrap daemon's height: " << *bootstrap_daemon_height << ")");
    }
    if (!m_should_use_bootstrap_daemon)
    {
      MINFO("The local daemon is fully synced; disabling bootstrap daemon requests");
      lock.unlock();
    }
    return lock;
  }
std :: unique_lock < std :: shared_mutex > core_rpc_server :: should_bootstrap_lock ( ) { if ( ! m_should_use_bootstrap_daemon ) return { } ; std :: unique_lock lock { m_bootstrap_daemon_mutex } ; if ( ! m_bootstrap_daemon ) { lock . unlock ( ) ; return lock ; } auto current_time = std :: chrono :: system_clock :: now ( ) ; if ( ! m_p2p . get_payload_object ( ) . no_sync ( ) && current_time - m_bootstrap_height_check_time > 30 s ) { m_bootstrap_height_check_time = current_time ; std :: optional < uint64_t > bootstrap_daemon_height = m_bootstrap_daemon -> get_height ( ) ; if ( ! bootstrap_daemon_height ) { MERROR ( " " ) ; lock . unlock ( ) ; return lock ; } uint64_t target_height = m_core . get_target_blockchain_height ( ) ; if ( bootstrap_daemon_height < target_height ) { MINFO ( " " ) ; lock . unlock ( ) ; m_bootstrap_daemon -> set_failed ( ) ; return lock ; } uint64_t top_height = m_core . get_current_blockchain_height ( ) ; m_should_use_bootstrap_daemon = top_height + 10 < bootstrap_daemon_height ; MINFO ( ( m_should_use_bootstrap_daemon ? " " : " " ) << " " << top_height << " " << * bootstrap_daemon_height << " " ) ; } if ( ! m_should_use_bootstrap_daemon ) { MINFO ( " " ) ; lock . unlock ( ) ; } return lock ; }
All the common (untemplated) code for use_bootstrap_daemon_if_necessary.
All the common ( untemplated ) code for use_bootstrap_daemon_if_necessary .
// TODO - support bootstrapping via a remote LMQ RPC; requires some argument fiddling // update every 30s