fast-time: switch-crossing.mjs drops null override fields at write (an older binary refuses an unknown key)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
igneum-labs 2026-10-07 18:12:00 +00:00
parent 8c15e25424
commit e54fda40d7

View file

@ -52,7 +52,10 @@ function mergeOverrideText(text, fields) {
let out = text;
for (const k of Object.keys(fields)) out = out.replace(new RegExp(`\\s*"${k}":\\s*[^,}\\n]+,?`), '');
const extra = Object.entries(fields).map(([k, v]) => `"${k}": ${typeof v === 'string' && !/^\d+$/.test(v) ? JSON.stringify(v) : v}`).join(', ');
return out.replace(/,?\s*}\s*$/, `,\n ${extra}\n}\n`);
out = out.replace(/,?\s*}\s*$/, `,\n ${extra}\n}\n`);
// a null field is an unset Option and means the same as an absent one, but a binary older than the field refuses the
// unknown key (deny_unknown_fields): the 0.3.22 pair exited on the 0.3.23 line's subsidy_per_block field, 18:09Z
return out.replace(/\n\s*"[a-z0-9_]+":\s*null\s*,?/g, '').replace(/,(\s*})/g, '$1');
}
const DAY_MS = fieldOf('pow_day_ms');
const common = { genesis_bits: GENESIS_BITS, skip_proof_of_work: false, program_class_v3_activation_daa: NEVER, program_class_v4_activation_daa: NEVER, signing_bonus_activation_daa: NEVER };