Skip to content

Commit

Permalink
P3A: Rename Nebula scramble function
Browse files Browse the repository at this point in the history
This really does two things, which I've tried to make more clear
with a comment, but `MaybeFoo` is a more common idiom in our code,
and it avoids the misleading idea that scrambling happens most of
the time.
  • Loading branch information
rillian committed Jun 3, 2024
1 parent d06b1fc commit 1289c83
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions components/p3a/constellation_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,15 @@ constexpr double kNebulaParticipationRate = 0.105;
// be aggregated.
constexpr double kNebulaScramblingRate = 0.05;

bool CheckParticipationAndScrambleForNebula(std::vector<std::string>* layers) {
// Check and prepare a response under the Nebula protocol
//
// Decides based on the probability constants above whether
// to participate in the random sampling, and whether to
// scramble the message vector before submission.
//
// The report should only be submitted if this function
// returns true. Otherwise the message should be discarded.
bool MaybeScrambleForNebula(std::vector<std::string>* layers) {
bool should_participate = base::RandDouble() < kNebulaParticipationRate;
if (should_participate) {
return true;
Expand Down Expand Up @@ -111,7 +119,7 @@ bool ConstellationHelper::StartMessagePreparation(std::string histogram_name,
base::WhitespaceHandling::TRIM_WHITESPACE,
base::SplitResult::SPLIT_WANT_NONEMPTY);

if (is_nebula && !CheckParticipationAndScrambleForNebula(&layers)) {
if (is_nebula && !MaybeScrambleForNebula(&layers)) {
// Do not send measurement since client is unable to participate,
// but mark the request as successful so the client does not retry
// transmission.
Expand Down

0 comments on commit 1289c83

Please sign in to comment.