Skip to content

Commit

Permalink
search: combine callbacks in case of multiple equivalent puts
Browse files Browse the repository at this point in the history
  • Loading branch information
aberaud committed Nov 14, 2024
1 parent be0b115 commit 5953c2d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/search.h
Original file line number Diff line number Diff line change
Expand Up @@ -641,18 +641,20 @@ struct Dht::Search {
n->acked[value->id].req.reset();
n->probe_query.reset();
}
} else {
a_sr->callback = [
cb1 = std::move(a_sr->callback),
cb2 = std::move(callback)
](bool success, const std::vector<std::shared_ptr<Node>>& nodes){
if (cb1) cb1(success, nodes);
if (cb2) cb2(success, nodes);
};
}
if (isAnnounced(value->id)) {
if (a_sr->callback)
a_sr->callback(true, {});
a_sr->callback = {};
if (callback)
callback(true, {});
return;
} else {
if (a_sr->callback)
a_sr->callback(false, {});
a_sr->callback = callback;
}
}
}
Expand Down

0 comments on commit 5953c2d

Please sign in to comment.