| 2819 | } |
| 2820 | |
| 2821 | void updateTssMappings(Database cx, const GetKeyServerLocationsReply& reply) { |
| 2822 | // Since a ss -> tss mapping is included in resultsTssMapping iff that SS is in results and has a tss pair, |
| 2823 | // all SS in results that do not have a mapping present must not have a tss pair. |
| 2824 | std::unordered_map<UID, const StorageServerInterface*> ssiById; |
| 2825 | for (const auto& [_, shard] : reply.results) { |
| 2826 | for (auto& ssi : shard) { |
| 2827 | ssiById[ssi.id()] = &ssi; |
| 2828 | } |
| 2829 | } |
| 2830 | |
| 2831 | for (const auto& mapping : reply.resultsTssMapping) { |
| 2832 | auto ssi = ssiById.find(mapping.first); |
| 2833 | ASSERT(ssi != ssiById.end()); |
| 2834 | cx->addTssMapping(*ssi->second, mapping.second); |
| 2835 | ssiById.erase(mapping.first); |
| 2836 | } |
| 2837 | |
| 2838 | // if SS didn't have a mapping above, it's still in the ssiById map, so remove its tss mapping |
| 2839 | for (const auto& it : ssiById) { |
| 2840 | cx->removeTssMapping(*it.second); |
| 2841 | } |
| 2842 | } |
| 2843 | |
| 2844 | void updateTagMappings(Database cx, const GetKeyServerLocationsReply& reply) { |
| 2845 | for (const auto& mapping : reply.resultsTagMapping) { |
no test coverage detected