llarp::NodeDB

Public Functions

Name
NodeDB(fs::path rootdir, std::function< void(std::function< void()>)> diskCaller)
NodeDB()
in memory nodedb
void LoadFromDisk()
load all entries from disk syncrhonously
void SaveToDisk() const
explicit save all RCs to disk synchronously
size_t NumLoaded() const
the number of RCs that are loaded from disk
void Tick(llarp_time_t now)
do periodic tasks like flush to disk and expiration
RouterContact FindClosestTo(dht::Key_t location) const
find the absolute closets router to a dht location
std::vector< RouterContact > FindManyClosestTo(dht::Key_t location, uint32_t numRouters) const
find many routers closest to dht key
bool Has(RouterID pk) const
return true if we have an rc by its ident pubkey
std::optional< RouterContact > Get(RouterID pk) const
maybe get an rc by its ident pubkey
template <typename Filter >
std::optional< RouterContact >
GetRandom(Filter visit) const
template <typename Visit >
void
VisitAll(Visit visit) const
visit all entries
template <typename Visit >
void
VisitInsertedBefore(Visit visit, llarp_time_t insertedBefore)
visit all entries inserted before a timestamp
void Remove(RouterID pk)
remove an entry via its ident pubkey
template <typename Filter >
void
RemoveIf(Filter visit)
remove an entry given a filter that inspects the rc
void RemoveStaleRCs(std::unordered_set< RouterID > keep, llarp_time_t cutoff)
remove rcs that are not in keep and have been inserted before cutoff
void PutIfNewer(RouterContact rc)
put this rc into the cache if it is not there or newer than the one there already
void Put(RouterContact rc)
unconditional put of rc into cache

Public Functions Documentation

function NodeDB

explicit NodeDB(
    fs::path rootdir,
    std::function< void(std::function< void()>)> diskCaller
)

function NodeDB

NodeDB()

in memory nodedb

function LoadFromDisk

void LoadFromDisk()

load all entries from disk syncrhonously

function SaveToDisk

void SaveToDisk() const

explicit save all RCs to disk synchronously

function NumLoaded

size_t NumLoaded() const

the number of RCs that are loaded from disk

function Tick

void Tick(
    llarp_time_t now
)

do periodic tasks like flush to disk and expiration

function FindClosestTo

RouterContact FindClosestTo(
    dht::Key_t location
) const

find the absolute closets router to a dht location

function FindManyClosestTo

std::vector< RouterContact > FindManyClosestTo(
    dht::Key_t location,
    uint32_t numRouters
) const

find many routers closest to dht key

function Has

bool Has(
    RouterID pk
) const

return true if we have an rc by its ident pubkey

function Get

std::optional< RouterContact > Get(
    RouterID pk
) const

maybe get an rc by its ident pubkey

function GetRandom

template <typename Filter >
inline std::optional< RouterContact > GetRandom(
    Filter visit
) const

function VisitAll

template <typename Visit >
inline void VisitAll(
    Visit visit
) const

visit all entries

function VisitInsertedBefore

template <typename Visit >
inline void VisitInsertedBefore(
    Visit visit,
    llarp_time_t insertedBefore
)

visit all entries inserted before a timestamp

function Remove

void Remove(
    RouterID pk
)

remove an entry via its ident pubkey

function RemoveIf

template <typename Filter >
inline void RemoveIf(
    Filter visit
)

remove an entry given a filter that inspects the rc

function RemoveStaleRCs

void RemoveStaleRCs(
    std::unordered_set< RouterID > keep,
    llarp_time_t cutoff
)

remove rcs that are not in keep and have been inserted before cutoff

function PutIfNewer

void PutIfNewer(
    RouterContact rc
)

put this rc into the cache if it is not there or newer than the one there already

function Put

void Put(
    RouterContact rc
)

unconditional put of rc into cache


Updated on 2026-01-10 at 22:49:45 +0000