| 318 | } |
| 319 | |
| 320 | roster_variant session::process_commit(std::vector<uint8_t> commit) noexcept |
| 321 | try { |
| 322 | creator.log(dpp::ll_debug, "Processing commit"); |
| 323 | |
| 324 | auto commit_message = ::mlspp::tls::get<::mlspp::MLSMessage>(commit); |
| 325 | |
| 326 | if (!can_process_commit(commit_message)) { |
| 327 | creator.log(dpp::ll_warning, "process_commit called with unprocessable MLS commit"); |
| 328 | return ignored_t{}; |
| 329 | } |
| 330 | |
| 331 | // in case we're the sender of this commit |
| 332 | // we need to pull the cached state from our outbound cache |
| 333 | std::optional<::mlspp::State> optional_cached_state = std::nullopt; |
| 334 | if (outbound_cached_group_state) { |
| 335 | optional_cached_state = *(outbound_cached_group_state.get()); |
| 336 | } |
| 337 | |
| 338 | auto new_state = state_with_proposals->handle(commit_message, optional_cached_state); |
| 339 | if (!new_state) { |
| 340 | creator.log(dpp::ll_warning, "MLS commit handling did not produce a new state"); |
| 341 | return failed_t{}; |
| 342 | } |
| 343 | |
| 344 | creator.log(dpp::ll_debug, "Successfully processed MLS commit, updating state; our leaf index is " + std::to_string(new_state->index().val) + "; current epoch is " + std::to_string(new_state->epoch())); |
| 345 | |
| 346 | roster_map ret = replace_state(std::make_unique<::mlspp::State>(std::move(*new_state))); |
| 347 | |
| 348 | // reset the outbound cached group since we handled the commit for this epoch |
| 349 | outbound_cached_group_state.reset(); |
| 350 | clear_pending_state(); |
| 351 | |
| 352 | return ret; |
| 353 | } |
| 354 | catch (const std::exception& e) { |
| 355 | creator.log(dpp::ll_warning, "Failed to process MLS commit: " + std::string(e.what())); |
| 356 | TRACK_MLS_ERROR(e.what()); |
| 357 | return failed_t{}; |
| 358 | } |
| 359 | |
| 360 | std::optional<roster_map> session::process_welcome(std::vector<uint8_t> welcome, std::set<dpp::snowflake> const& recognised_user_ids) noexcept |
| 361 | try { |