1
1
Fork 0
mirror of https://github.com/oxen-io/lokinet synced 2023-12-14 06:53:00 +01:00
lokinet/llarp/bootstrap.hpp
dr7ana 91121ea22b pull yourself up by your bootstraps sonny
- initial/subsequent fetching combined for RouterContacts and RouterIDs
- bootstraps fallback implemented and looped into fetch logic
2023-11-30 15:16:33 -08:00

51 lines
891 B
C++

#pragma once
#include "router_contact.hpp"
#include <llarp/util/fs.hpp>
#include <set>
#include <unordered_map>
namespace llarp
{
struct BootstrapList final : public std::set<RemoteRC>
{
size_t index;
bool
bt_decode(std::string_view buf);
std::string_view
bt_encode() const;
void
read_from_file(const fs::path& fpath);
bool
contains(const RouterID& rid);
// returns a reference to the next index and a boolean that equals true if
// this is the front of the set
std::pair<const RemoteRC&, bool>
next()
{
++index %= this->size();
return std::make_pair(*std::next(this->begin(), index), index == 0);
}
bool
contains(const RemoteRC& rc);
void
clear_list()
{
clear();
}
};
std::unordered_map<std::string, BootstrapList>
load_bootstrap_fallbacks();
} // namespace llarp