mirror of
https://github.com/oxen-io/lokinet
synced 2023-12-14 06:53:00 +01:00
bootstrap tweaking
This commit is contained in:
parent
d6e5aca572
commit
08c2c26c29
|
@ -126,7 +126,7 @@ namespace llarp
|
||||||
LinkManager::register_commands(std::shared_ptr<oxen::quic::BTRequestStream>& s)
|
LinkManager::register_commands(std::shared_ptr<oxen::quic::BTRequestStream>& s)
|
||||||
{
|
{
|
||||||
log::critical(logcat, "{} called", __PRETTY_FUNCTION__);
|
log::critical(logcat, "{} called", __PRETTY_FUNCTION__);
|
||||||
const RouterID& router_id {s->conn.remote_key()};
|
const RouterID& router_id{s->conn.remote_key()};
|
||||||
|
|
||||||
log::critical(logcat, "Registering commands (RID:{})", router_id);
|
log::critical(logcat, "Registering commands (RID:{})", router_id);
|
||||||
|
|
||||||
|
@ -209,7 +209,7 @@ namespace llarp
|
||||||
|
|
||||||
if (_router.is_bootstrap_seed())
|
if (_router.is_bootstrap_seed())
|
||||||
{
|
{
|
||||||
// FIXME: remove "|| true", this is just for local testing!
|
// FIXME: remove "|| true", this is just for local testing!
|
||||||
if (node_db->whitelist().count(other) || true)
|
if (node_db->whitelist().count(other) || true)
|
||||||
{
|
{
|
||||||
log::critical(logcat, "Saving bootstrap seed requester...");
|
log::critical(logcat, "Saving bootstrap seed requester...");
|
||||||
|
@ -218,8 +218,10 @@ namespace llarp
|
||||||
}
|
}
|
||||||
log::critical(
|
log::critical(
|
||||||
logcat,
|
logcat,
|
||||||
"Bootstrap seed node was {} to confirm fetch requester is white-listed; {}successfully saved RID",
|
"Bootstrap seed node was {} to confirm fetch requester is white-listed; {}successfully "
|
||||||
result ? "able" : "unable", result ? "" : "un");
|
"saved RID",
|
||||||
|
result ? "able" : "unable",
|
||||||
|
result ? "" : "un");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,7 +238,6 @@ namespace llarp
|
||||||
[&](oxen::quic::Connection& c,
|
[&](oxen::quic::Connection& c,
|
||||||
oxen::quic::Endpoint& e,
|
oxen::quic::Endpoint& e,
|
||||||
std::optional<int64_t> id) -> std::shared_ptr<oxen::quic::Stream> {
|
std::optional<int64_t> id) -> std::shared_ptr<oxen::quic::Stream> {
|
||||||
|
|
||||||
if (id && *id == 0)
|
if (id && *id == 0)
|
||||||
{
|
{
|
||||||
log::critical(logcat, "Stream constructor constructing BTStream (ID:{})", id);
|
log::critical(logcat, "Stream constructor constructing BTStream (ID:{})", id);
|
||||||
|
@ -378,7 +379,6 @@ namespace llarp
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
LinkManager::send_control_message(
|
LinkManager::send_control_message(
|
||||||
const RouterID& remote,
|
const RouterID& remote,
|
||||||
|
@ -421,23 +421,24 @@ namespace llarp
|
||||||
body = std::move(body),
|
body = std::move(body),
|
||||||
f = std::move(func)]() {
|
f = std::move(func)]() {
|
||||||
auto pending = PendingMessage(std::move(body), std::move(endpoint), std::move(f));
|
auto pending = PendingMessage(std::move(body), std::move(endpoint), std::move(f));
|
||||||
|
|
||||||
if (auto it1 = ep.pending_conns.find(remote); it1 != ep.pending_conns.end())
|
if (auto it1 = ep.pending_conns.find(remote); it1 != ep.pending_conns.end())
|
||||||
{
|
{
|
||||||
if (auto it2 = pending_conn_msg_queue.find(remote); it2 != pending_conn_msg_queue.end())
|
if (auto it2 = pending_conn_msg_queue.find(remote); it2 != pending_conn_msg_queue.end())
|
||||||
{
|
{
|
||||||
it2->second.push_back(std::move(pending));
|
it2->second.push_back(std::move(pending));
|
||||||
log::critical(logcat, "Connection (RID:{}) is pending; message appended to send queue!", remote);
|
log::critical(
|
||||||
|
logcat, "Connection (RID:{}) is pending; message appended to send queue!", remote);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log::critical(logcat, "Connection (RID:{}) not found in pending conns; creating send queue!", remote);
|
log::critical(
|
||||||
|
logcat, "Connection (RID:{}) not found in pending conns; creating send queue!", remote);
|
||||||
auto [itr, b] = pending_conn_msg_queue.emplace(remote, MessageQueue());
|
auto [itr, b] = pending_conn_msg_queue.emplace(remote, MessageQueue());
|
||||||
itr->second.push_back(std::move(pending));
|
itr->second.push_back(std::move(pending));
|
||||||
connect_to(remote);
|
connect_to(remote);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -339,9 +339,11 @@ namespace llarp
|
||||||
void
|
void
|
||||||
NodeDB::fetch_initial()
|
NodeDB::fetch_initial()
|
||||||
{
|
{
|
||||||
if (known_rids.empty())
|
auto sz = num_rcs();
|
||||||
|
|
||||||
|
if (num_rcs() < MIN_ACTIVE_RCS)
|
||||||
{
|
{
|
||||||
log::critical(logcat, "No RouterID's held locally... BOOTSTRAP TIME");
|
log::critical(logcat, "{}/{} RCs held locally... BOOTSTRAP TIME", sz, MIN_ACTIVE_RCS);
|
||||||
fallback_to_bootstrap();
|
fallback_to_bootstrap();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -728,7 +730,12 @@ namespace llarp
|
||||||
|
|
||||||
// const auto& num = rids.size();
|
// const auto& num = rids.size();
|
||||||
|
|
||||||
log::critical(logcat, "BootstrapRC fetch response from {} returned {}/{} needed RCs", fetch_source, num, BOOTSTRAP_SOURCE_COUNT);
|
log::critical(
|
||||||
|
logcat,
|
||||||
|
"BootstrapRC fetch response from {} returned {}/{} needed RCs",
|
||||||
|
fetch_source,
|
||||||
|
num,
|
||||||
|
BOOTSTRAP_SOURCE_COUNT);
|
||||||
// known_rids.merge(rids);
|
// known_rids.merge(rids);
|
||||||
fetch_initial();
|
fetch_initial();
|
||||||
|
|
||||||
|
@ -964,6 +971,9 @@ namespace llarp
|
||||||
{
|
{
|
||||||
const auto& rid = rc.router_id();
|
const auto& rid = rc.router_id();
|
||||||
|
|
||||||
|
if (rid == _router.local_rid())
|
||||||
|
return false;
|
||||||
|
|
||||||
known_rcs.erase(rc);
|
known_rcs.erase(rc);
|
||||||
rc_lookup.erase(rid);
|
rc_lookup.erase(rid);
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ namespace llarp
|
||||||
struct Router;
|
struct Router;
|
||||||
|
|
||||||
/* RC Fetch Constants */
|
/* RC Fetch Constants */
|
||||||
|
inline constexpr size_t MIN_ACTIVE_RCS{6};
|
||||||
// max number of attempts we make in non-bootstrap fetch requests
|
// max number of attempts we make in non-bootstrap fetch requests
|
||||||
inline constexpr int MAX_FETCH_ATTEMPTS{10};
|
inline constexpr int MAX_FETCH_ATTEMPTS{10};
|
||||||
// the total number of returned rcs that are held locally should be at least this
|
// the total number of returned rcs that are held locally should be at least this
|
||||||
|
|
|
@ -158,6 +158,12 @@ namespace llarp
|
||||||
std::chrono::system_clock::time_point next_bootstrap_attempt{last_rc_gossip};
|
std::chrono::system_clock::time_point next_bootstrap_attempt{last_rc_gossip};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
bool
|
||||||
|
testnet() const
|
||||||
|
{
|
||||||
|
return _testnet;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
is_bootstrap_seed() const
|
is_bootstrap_seed() const
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue