Browse Source

use shared_ptr for CreateDatabaseStore

pull/177/head
orignal 10 years ago
parent
commit
1e74ff8a85
  1. 4
      I2NPProtocol.cpp
  2. 2
      I2NPProtocol.h
  3. 4
      NetDb.cpp

4
I2NPProtocol.cpp

@ -205,10 +205,10 @@ namespace i2p @@ -205,10 +205,10 @@ namespace i2p
return m;
}
I2NPMessage * CreateDatabaseStoreMsg (const i2p::data::RouterInfo * router, uint32_t replyToken)
I2NPMessage * CreateDatabaseStoreMsg (std::shared_ptr<const i2p::data::RouterInfo> router, uint32_t replyToken)
{
if (!router) // we send own RouterInfo
router = &context.GetRouterInfo ();
router = context.GetSharedRouterInfo ();
I2NPMessage * m = NewI2NPShortMessage ();
uint8_t * payload = m->GetPayload ();

2
I2NPProtocol.h

@ -209,7 +209,7 @@ namespace tunnel @@ -209,7 +209,7 @@ namespace tunnel
const i2p::tunnel::InboundTunnel * replyTunnel, const uint8_t * replyKey, const uint8_t * replyTag);
I2NPMessage * CreateDatabaseSearchReply (const i2p::data::IdentHash& ident, std::vector<i2p::data::IdentHash> routers);
I2NPMessage * CreateDatabaseStoreMsg (const i2p::data::RouterInfo * router = nullptr, uint32_t replyToken = 0);
I2NPMessage * CreateDatabaseStoreMsg (std::shared_ptr<const i2p::data::RouterInfo> router = nullptr, uint32_t replyToken = 0);
I2NPMessage * CreateDatabaseStoreMsg (std::shared_ptr<const i2p::data::LeaseSet> leaseSet, uint32_t replyToken = 0);
bool HandleBuildRequestRecords (int num, uint8_t * records, uint8_t * clearText);

4
NetDb.cpp

@ -740,7 +740,7 @@ namespace data @@ -740,7 +740,7 @@ namespace data
LogPrint ("Requested RouterInfo ", key, " found");
router->LoadBuffer ();
if (router->GetBuffer ())
replyMsg = CreateDatabaseStoreMsg (router.get ());
replyMsg = CreateDatabaseStoreMsg (router);
}
if (!replyMsg)
@ -874,7 +874,7 @@ namespace data @@ -874,7 +874,7 @@ namespace data
{
uint32_t replyToken = i2p::context.GetRandomNumberGenerator ().GenerateWord32 ();
LogPrint ("Publishing our RouterInfo to ", floodfill->GetIdentHashAbbreviation (), ". reply token=", replyToken);
transports.SendMessage (floodfill->GetIdentHash (), CreateDatabaseStoreMsg ((RouterInfo *)nullptr, replyToken));
transports.SendMessage (floodfill->GetIdentHash (), CreateDatabaseStoreMsg (std::make_shared<RouterInfo>(nullptr), replyToken));
excluded.insert (floodfill->GetIdentHash ());
}
}

Loading…
Cancel
Save