From f812d5471b1cd02a25b4500cdc285183c8343cb5 Mon Sep 17 00:00:00 2001 From: dr7ana Date: Mon, 11 Dec 2023 12:06:16 -0800 Subject: [PATCH] send localrc, receive as remoterc --- llarp/bootstrap.cpp | 2 +- llarp/messages/fetch.hpp | 6 ++++-- llarp/nodedb.cpp | 6 +++--- llarp/router_contact.hpp | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/llarp/bootstrap.cpp b/llarp/bootstrap.cpp index 23b7c034e..3100eada6 100644 --- a/llarp/bootstrap.cpp +++ b/llarp/bootstrap.cpp @@ -14,7 +14,7 @@ namespace llarp oxenc::bt_list_consumer btlc{buf}; while (not btlc.is_finished()) - emplace(btlc.consume_dict_consumer()); + emplace(btlc.consume_dict_data()); } catch (...) { diff --git a/llarp/messages/fetch.hpp b/llarp/messages/fetch.hpp index 839a5d458..859603759 100644 --- a/llarp/messages/fetch.hpp +++ b/llarp/messages/fetch.hpp @@ -1,6 +1,7 @@ #pragma once #include "common.hpp" +#include namespace llarp { @@ -39,10 +40,11 @@ namespace llarp { // the LocalRC is converted to a RemoteRC type to send to the bootstrap seed inline static std::string - serialize(const RemoteRC& local_rc, size_t quantity) + serialize(const LocalRC& local_rc, size_t quantity) { oxenc::bt_dict_producer btdp; - btdp.append_encoded("local", local_rc.view()); + btdp.append_encoded("local", oxen::quic::to_sv(local_rc.view())); + log::critical(logcat, "Serializing localRC: {}", buffer_printer{local_rc.view()}); btdp.append("quantity", quantity); return std::move(btdp).str(); } diff --git a/llarp/nodedb.cpp b/llarp/nodedb.cpp index 6e6f2beb5..17c42924d 100644 --- a/llarp/nodedb.cpp +++ b/llarp/nodedb.cpp @@ -408,7 +408,7 @@ namespace llarp std::set rcs; while (not btlc.is_finished()) - rcs.emplace(btlc.consume_dict_consumer()); + rcs.emplace(btlc.consume_dict_data()); // if process_fetched_rcs returns false, then the trust model rejected the fetched RC's fetch_rcs_result(initial, not ingest_fetched_rcs(std::move(rcs), timestamp)); @@ -672,7 +672,7 @@ namespace llarp _router.link_manager().fetch_bootstrap_rcs( _bootstraps->current(), BootstrapFetchMessage::serialize( - _router.router_contact.to_remote(), BOOTSTRAP_SOURCE_COUNT), + _router.router_contact, BOOTSTRAP_SOURCE_COUNT), [this](oxen::quic::message m) mutable { if (not m) { @@ -698,7 +698,7 @@ namespace llarp while (not btlc.is_finished()) { - auto rc = RemoteRC{btlc.consume_dict_consumer()}; + auto rc = RemoteRC{btlc.consume_dict_data()}; rids.emplace(rc.router_id()); } } diff --git a/llarp/router_contact.hpp b/llarp/router_contact.hpp index 466d00719..ea7fff249 100644 --- a/llarp/router_contact.hpp +++ b/llarp/router_contact.hpp @@ -314,6 +314,7 @@ namespace llarp void bt_verify(oxenc::bt_dict_consumer& data, bool reject_expired = false) const; + explicit RemoteRC(oxenc::bt_dict_consumer btdc); public: RemoteRC() = default; explicit RemoteRC(std::string_view data) : RemoteRC{oxenc::bt_dict_consumer{data}} @@ -324,7 +325,6 @@ namespace llarp { _payload = data; } - explicit RemoteRC(oxenc::bt_dict_consumer btdc); ~RemoteRC() = default; std::string_view