reorgs, fetch batching (parallel fetch), orphans

This commit is contained in:
2026-05-15 13:01:27 +02:00
parent ad339dc696
commit 3337ac85ab
14 changed files with 827 additions and 133 deletions
+24
View File
@@ -0,0 +1,24 @@
#include <nets/fetch_scheduler.h>
#include <constants.h>
#include <math.h>
// Note: floating point is used intentionally here for readability and
// because the final penalty is rounded to whole blocks. This keeps the
// implementation straightforward while avoiding subtle integer overflow
// for large exponents. If desired, replace with fixed-point arithmetic.
uint64_t FetchScheduler_ComputeReorgPenaltyBlocks(uint64_t delayBlocks) {
if (delayBlocks <= REORG_PENALTY_GRACE_BLOCKS) {
return 0ULL;
}
double B = (double)delayBlocks;
double factor = REORG_PENALTY_FACTOR;
double exp = REORG_PENALTY_EXPONENT;
double timeScale = ((double)TARGET_BLOCK_TIME) / REORG_PENALTY_REF_BLOCK_TIME;
double raw = factor * pow(B, exp) * timeScale;
if (raw < 0.0) raw = 0.0;
uint64_t penalty = (uint64_t)ceil(raw);
return penalty;
}