Browse Source

check log level before calculating base32 or base64 of ident

pull/2014/head
orignal 9 months ago
parent
commit
592d6ae4f4
  1. 12
      libi2pd/NetDb.cpp

12
libi2pd/NetDb.cpp

@ -262,9 +262,11 @@ namespace data @@ -262,9 +262,11 @@ namespace data
return nullptr;
}
}
if (CheckLogLevel (eLogInfo))
LogPrint (eLogInfo, "NetDb: RouterInfo updated: ", ident.ToBase64());
if (wasFloodfill != r->IsFloodfill ()) // if floodfill status updated
{
if (CheckLogLevel (eLogDebug))
LogPrint (eLogDebug, "NetDb: RouterInfo floodfill status updated: ", ident.ToBase64());
std::lock_guard<std::mutex> l(m_FloodfillsMutex);
if (wasFloodfill)
@ -280,6 +282,7 @@ namespace data @@ -280,6 +282,7 @@ namespace data
}
else
{
if (CheckLogLevel (eLogDebug))
LogPrint (eLogDebug, "NetDb: RouterInfo is older: ", ident.ToBase64());
updated = false;
}
@ -297,6 +300,7 @@ namespace data @@ -297,6 +300,7 @@ namespace data
}
if (inserted)
{
if (CheckLogLevel (eLogInfo))
LogPrint (eLogInfo, "NetDb: RouterInfo added: ", ident.ToBase64());
if (r->IsFloodfill () && r->IsEligibleFloodfill ())
{
@ -338,10 +342,11 @@ namespace data @@ -338,10 +342,11 @@ namespace data
if(it->second->GetExpirationTime() < expires)
{
it->second->Update (buf, len, false); // signature is verified already
if (CheckLogLevel (eLogInfo))
LogPrint (eLogInfo, "NetDb: LeaseSet updated: ", ident.ToBase32());
updated = true;
}
else
else if (CheckLogLevel (eLogDebug))
LogPrint(eLogDebug, "NetDb: LeaseSet is older: ", ident.ToBase32());
}
else
@ -352,6 +357,7 @@ namespace data @@ -352,6 +357,7 @@ namespace data
auto leaseSet = std::make_shared<LeaseSet> (buf, len, false); // we don't need leases in netdb
if (leaseSet->IsValid ())
{
if (CheckLogLevel (eLogInfo))
LogPrint (eLogInfo, "NetDb: LeaseSet added: ", ident.ToBase32());
m_LeaseSets[ident] = leaseSet;
updated = true;
@ -376,6 +382,7 @@ namespace data @@ -376,6 +382,7 @@ namespace data
i2p::util::GetSecondsSinceEpoch () + NETDB_EXPIRATION_TIMEOUT_THRESHOLD > leaseSet->GetPublishedTimestamp ())
{
// TODO: implement actual update
if (CheckLogLevel (eLogInfo))
LogPrint (eLogInfo, "NetDb: LeaseSet2 updated: ", ident.ToBase32());
m_LeaseSets[ident] = leaseSet;
return true;
@ -863,11 +870,13 @@ namespace data @@ -863,11 +870,13 @@ namespace data
{
if (storeType == NETDB_STORE_TYPE_LEASESET) // 1
{
if (CheckLogLevel (eLogDebug))
LogPrint (eLogDebug, "NetDb: Store request: LeaseSet for ", ident.ToBase32());
updated = AddLeaseSet (ident, buf + offset, len - offset);
}
else // all others are considered as LeaseSet2
{
if (CheckLogLevel (eLogDebug))
LogPrint (eLogDebug, "NetDb: Store request: LeaseSet2 of type ", int(storeType), " for ", ident.ToBase32());
updated = AddLeaseSet2 (ident, buf + offset, len - offset, storeType);
}
@ -875,6 +884,7 @@ namespace data @@ -875,6 +884,7 @@ namespace data
}
else // RouterInfo
{
if (CheckLogLevel (eLogDebug))
LogPrint (eLogDebug, "NetDb: Store request: RouterInfo ", ident.ToBase64());
size_t size = bufbe16toh (buf + offset);
offset += 2;

Loading…
Cancel
Save