hygiene: Phase 5 — correct stale comments + name safe magic numbers
Fifth phase of the code-hygiene remediation, done per-file (18 files) via an 18-agent Workflow with strict guardrails. No consensus or security VALUES changed (verified: pow/hush_utils/hush_bitcoind/net.h/crypter/stratum have zero non-comment numeric changes); built clean, self-mined, verifychain=true. Totals: 57 stale comments corrected, 46 user-facing branding fixes, 6 behavior-preserving named constants, 4 stratum warnings, 77 items deliberately left (consensus/security values, copyright headers). - Stale comments -> DragonX: corrected HUSH3/HUSH/Komodo/Equihash/Arrakis leftovers that misdescribed the active chain (pow AWT/lwma notes, txdb "Equihash solution" -> RandomX, wallet CLTV/overwinter/Sapling@1 notes, util datadir provenance, crypter's stale mapSproutSpendingKeys invariant). Replaced unprofessional/editorializing comments (profane TODOs, "developers are elite") with neutral technical notes, preserving the real design info. - User-facing branding: dumpwallet header "created by Hush" -> "DragonX"; RPC help text hushd/hush-cli/hushprivkey/hushaddress/Agama -> dragonx*; rebranded provably-dead "HUSH3" symbol-fallback literals to DRAGONX. - Named constants (same values, non-consensus/non-security): addrman peer-selection factors (kChanceFactorGrowth/kChanceScale/deprioritize), sietch MIN_ZOUTS, an init notarization-DB cache size. - Left the security macros (ECC/TFM_TIMING_RESISTANT=420, comment-clarified only), the consensus subsidy/commission literals + 128/129 TRANSITION (comment only), and copyright headers untouched. - Added a prominent WARNING that the stratum server is Equihash-era and NOT updated for DragonX's RandomX PoW (flagged, not rewritten). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+22
-8
@@ -478,6 +478,20 @@ CAddrInfo CAddrMan::Select_(bool newOnly)
|
||||
const int kRetriesBetweenSleep = 1000;
|
||||
const int kRetrySleepInterval = 100; // milliseconds
|
||||
|
||||
// Peer-selection tuning factors (networking heuristics, not consensus).
|
||||
// On each rejected candidate the running chance factor is scaled up by this
|
||||
// amount so the loop is guaranteed to eventually accept a peer.
|
||||
const double kChanceFactorGrowth = 1.2;
|
||||
// Candidates on unreachable networks are deprioritized to this fraction of
|
||||
// their base chance.
|
||||
const double kUnreachableDeprioritize = 0.25;
|
||||
// Candidates that were just tried are deprioritized to this fraction of
|
||||
// their base chance.
|
||||
const double kJustTriedDeprioritize = 0.10;
|
||||
// Fixed-point scale for the acceptance probability test: draw a random int in
|
||||
// [0, kChanceScale) and accept if it falls below (factors * chance) * kChanceScale.
|
||||
const int kChanceScale = 1 << 30;
|
||||
|
||||
if (newOnly && nNew == 0)
|
||||
return CAddrInfo();
|
||||
|
||||
@@ -513,15 +527,15 @@ CAddrInfo CAddrMan::Select_(bool newOnly)
|
||||
CAddrInfo& info = mapInfo[nId];
|
||||
if (info.IsReachableNetwork()) {
|
||||
//deprioritize unreachable networks
|
||||
fReachableFactor = 0.25;
|
||||
fReachableFactor = kUnreachableDeprioritize;
|
||||
}
|
||||
if (info.IsJustTried()) {
|
||||
//deprioritize entries just tried
|
||||
fJustTried = 0.10;
|
||||
fJustTried = kJustTriedDeprioritize;
|
||||
}
|
||||
if (RandomInt(1 << 30) < fChanceFactor * fReachableFactor * fJustTried * info.GetChance() * (1 << 30))
|
||||
if (RandomInt(kChanceScale) < fChanceFactor * fReachableFactor * fJustTried * info.GetChance() * kChanceScale)
|
||||
return info;
|
||||
fChanceFactor *= 1.2;
|
||||
fChanceFactor *= kChanceFactorGrowth;
|
||||
}
|
||||
} else {
|
||||
// use a new node
|
||||
@@ -553,15 +567,15 @@ CAddrInfo CAddrMan::Select_(bool newOnly)
|
||||
CAddrInfo& info = mapInfo[nId];
|
||||
if (info.IsReachableNetwork()) {
|
||||
//deprioritize unreachable networks
|
||||
fReachableFactor = 0.25;
|
||||
fReachableFactor = kUnreachableDeprioritize;
|
||||
}
|
||||
if (info.IsJustTried()) {
|
||||
//deprioritize entries just tried
|
||||
fJustTried = 0.10;
|
||||
fJustTried = kJustTriedDeprioritize;
|
||||
}
|
||||
if (RandomInt(1 << 30) < fChanceFactor * fReachableFactor * fJustTried * info.GetChance() * (1 << 30))
|
||||
if (RandomInt(kChanceScale) < fChanceFactor * fReachableFactor * fJustTried * info.GetChance() * kChanceScale)
|
||||
return info;
|
||||
fChanceFactor *= 1.2;
|
||||
fChanceFactor *= kChanceFactorGrowth;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user