MCPcopy Create free account
hub / github.com/PurpleI2P/i2pd / AddLeaseSet2

Method AddLeaseSet2

libi2pd/NetDb.cpp:398–426  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

396 }
397
398 bool NetDb::AddLeaseSet2 (const IdentHash& ident, const uint8_t * buf, int len, uint8_t storeType)
399 {
400 auto leaseSet = std::make_shared<LeaseSet2> (storeType, buf, len, false); // we don't need leases in netdb
401 if (leaseSet->IsValid ())
402 {
403 std::lock_guard<std::mutex> lock(m_LeaseSetsMutex);
404 auto it = m_LeaseSets.find(ident);
405 if (it == m_LeaseSets.end () || it->second->GetStoreType () != storeType ||
406 leaseSet->GetPublishedTimestamp () > it->second->GetPublishedTimestamp ())
407 {
408 if (leaseSet->IsPublic () && !leaseSet->IsExpired ())
409 {
410 // TODO: implement actual update
411 if (CheckLogLevel (eLogInfo))
412 LogPrint (eLogInfo, "NetDb: LeaseSet2 updated: ", ident.ToBase32());
413 m_LeaseSets[ident] = leaseSet;
414 return true;
415 }
416 else
417 {
418 LogPrint (eLogWarning, "NetDb: Unpublished or expired or future LeaseSet2 received: ", ident.ToBase32());
419 m_LeaseSets.erase (ident);
420 }
421 }
422 }
423 else
424 LogPrint (eLogError, "NetDb: New LeaseSet2 validation failed: ", ident.ToBase32());
425 return false;
426 }
427
428 std::shared_ptr<RouterInfo> NetDb::FindRouter (const IdentHash& ident) const
429 {

Callers

nothing calls this directly

Calls 7

CheckLogLevelFunction · 0.85
LogPrintFunction · 0.85
IsValidMethod · 0.45
GetStoreTypeMethod · 0.45
GetPublishedTimestampMethod · 0.45
IsPublicMethod · 0.45
IsExpiredMethod · 0.45

Tested by

no test coverage detected