| 1102 | } |
| 1103 | |
| 1104 | void NetDb::Flood (const IdentHash& ident, std::shared_ptr<I2NPMessage> floodMsg, bool andNextDay) |
| 1105 | { |
| 1106 | std::unordered_set<IdentHash> excluded; |
| 1107 | excluded.insert (i2p::context.GetIdentHash ()); // don't flood to itself |
| 1108 | excluded.insert (ident); // don't flood back |
| 1109 | for (int i = 0; i < 3; i++) |
| 1110 | { |
| 1111 | auto floodfill = GetClosestFloodfill (ident, excluded, false); // current day |
| 1112 | if (floodfill) |
| 1113 | { |
| 1114 | const auto& h = floodfill->GetIdentHash(); |
| 1115 | transports.SendMessage (h, CopyI2NPMessage(floodMsg)); |
| 1116 | excluded.insert (h); |
| 1117 | } |
| 1118 | else |
| 1119 | return; // no more floodfills |
| 1120 | } |
| 1121 | if (andNextDay) |
| 1122 | { |
| 1123 | // flood to two more closest flodfills for next day |
| 1124 | std::unordered_set<IdentHash> excluded1; |
| 1125 | excluded1.insert (i2p::context.GetIdentHash ()); // don't flood to itself |
| 1126 | excluded1.insert (ident); // don't flood back |
| 1127 | for (int i = 0; i < 2; i++) |
| 1128 | { |
| 1129 | auto floodfill = GetClosestFloodfill (ident, excluded1, true); // next day |
| 1130 | if (floodfill) |
| 1131 | { |
| 1132 | const auto& h = floodfill->GetIdentHash(); |
| 1133 | if (!excluded.count (h)) // we didn't send for current day, otherwise skip |
| 1134 | transports.SendMessage (h, CopyI2NPMessage(floodMsg)); |
| 1135 | excluded1.insert (h); |
| 1136 | } |
| 1137 | else |
| 1138 | return; |
| 1139 | } |
| 1140 | } |
| 1141 | } |
| 1142 | |
| 1143 | std::shared_ptr<const RouterInfo> NetDb::GetRandomRouter () const |
| 1144 | { |
nothing calls this directly
no test coverage detected