From 83e76c6b5326596b677a74e30dbf8bac6561d1c5 Mon Sep 17 00:00:00 2001 From: orignal Date: Wed, 1 Jul 2015 14:13:42 -0400 Subject: [PATCH] use shared flood message --- NetDb.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/NetDb.cpp b/NetDb.cpp index 06fd3c37..db163002 100644 --- a/NetDb.cpp +++ b/NetDb.cpp @@ -486,22 +486,19 @@ namespace data if (context.IsFloodfill ()) { // flood it + auto floodMsg = ToSharedI2NPMessage (NewI2NPShortMessage ()); + uint8_t * payload = floodMsg->GetPayload (); + memcpy (payload, buf, 33); // key + type + htobe32buf (payload + DATABASE_STORE_REPLY_TOKEN_OFFSET, 0); // zero reply token + memcpy (payload + DATABASE_STORE_HEADER_SIZE, buf + offset, len - offset); + floodMsg->len += DATABASE_STORE_HEADER_SIZE + len -offset; + FillI2NPMessageHeader (floodMsg.get (), eI2NPDatabaseStore); // TODO std::set excluded; for (int i = 0; i < 3; i++) { auto floodfill = GetClosestFloodfill (ident, excluded); if (floodfill) - { - excluded.insert (floodfill->GetIdentHash ()); - auto floodMsg = NewI2NPShortMessage (); - uint8_t * payload = floodMsg->GetPayload (); - memcpy (payload, buf, 33); // key + type - htobe32buf (payload + DATABASE_STORE_REPLY_TOKEN_OFFSET, 0); // zero reply token - memcpy (payload + DATABASE_STORE_HEADER_SIZE, buf + offset, len - offset); - floodMsg->len += DATABASE_STORE_HEADER_SIZE + len -offset; - FillI2NPMessageHeader (floodMsg, eI2NPDatabaseStore); - transports.SendMessage (floodfill->GetIdentHash (), ToSharedI2NPMessage (floodMsg)); - } + transports.SendMessage (floodfill->GetIdentHash (), floodMsg); } } }