|
|
|
@ -106,6 +106,9 @@ llarp_nodedb::Insert(const llarp::RouterContact &rc)
|
|
|
|
|
llarp_buffer_t buf(tmp);
|
|
|
|
|
{
|
|
|
|
|
llarp::util::Lock lock(access);
|
|
|
|
|
auto itr = entries.find(rc.pubkey.as_array());
|
|
|
|
|
if(itr != entries.end())
|
|
|
|
|
entries.erase(itr);
|
|
|
|
|
entries.emplace(rc.pubkey.as_array(), rc);
|
|
|
|
|
}
|
|
|
|
|
if(!rc.BEncode(&buf))
|
|
|
|
@ -388,6 +391,7 @@ llarp_nodedb::num_loaded() const
|
|
|
|
|
bool
|
|
|
|
|
llarp_nodedb::select_random_exit(llarp::RouterContact &result)
|
|
|
|
|
{
|
|
|
|
|
llarp::util::Lock lock(access);
|
|
|
|
|
const auto sz = entries.size();
|
|
|
|
|
auto itr = entries.begin();
|
|
|
|
|
if(sz < 3)
|
|
|
|
@ -422,6 +426,7 @@ bool
|
|
|
|
|
llarp_nodedb::select_random_hop(const llarp::RouterContact &prev,
|
|
|
|
|
llarp::RouterContact &result, size_t N)
|
|
|
|
|
{
|
|
|
|
|
llarp::util::Lock lock(access);
|
|
|
|
|
/// checking for "guard" status for N = 0 is done by caller inside of
|
|
|
|
|
/// pathbuilder's scope
|
|
|
|
|
size_t sz = entries.size();
|
|
|
|
|