Skip to content

ltc: command-line parsing under the MSVC nesting limit (Windows build) - #2361

Merged
frstrtr merged 3 commits into
masterfrom
ci/ltc-cli-chain-msvc
Nov 28, 2026
Merged

frstrtr merged 3 commits into
masterfrom
ci/ltc-cli-chain-msvc

Conversation

@frstrtr

@frstrtr frstrtr commented Nov 28, 2026 •

Copy link
Copy Markdown
Owner

Command-line behaviour is unchanged. Net change: src/c2pool/main_ltc.cpp only.

  • Why. Master's "Windows x86_64" fails with MSVC src/c2pool/main_ltc.cpp(1940,17): error C1061: compiler limit: blocks nested too deeply (runs 46049548931 on 8e5b129 and 46071785930 on 902c42e). The LTC argument loop was one else-if chain of 119 branches (nesting 126 against MSVC's 128).

ltc: command-line parsing as independent checks (MSVC nesting limit) (315d5d7)

  • Each flag is now an independent if. 113 branches end in continue;, and the 5 that returned before still return.
  • Nothing in the loop runs after the chain. The unknown-argument check and the positional branch stay last, in the same order.
  • Against master, the token diff is only the 118 removed else and the 113 added continue;.
  • Longest else-if chain in the loop: 1. Deepest nesting in main(): 23 (was 126).

v37-xmr: unchanged here (1dad4f1 reverts 9432722)

  • main_v37_xmr.cpp's longest chain is 92, below the limit; its split goes through the XMR lane as a separate change.

Longest else-if chain per main, after this change

ltc 3, v37_xmr 92 (unchanged), dash 59 (already split), xmr_native_node 47, dgb 41, bch 36, btc 32, bip110 26, v37_btc_dash 14, v37 4.

Checks

  • LTC old vs new, built with the same temporary dump of every variable the loop writes: 302 argv cases are identical in exit code, stdout and stderr. The cases cover:
    • every one of the 139 flag spellings, with a value where it takes one;
    • 99 value flags missing their value at the end of argv;
    • unknown flags and positional arguments;
    • order, last-wins and repeated flags;
    • bad values;
    • all flags at once.
  • c2pool-ltc --help is byte-identical to master.
  • test_settings_cli_scan ALL PASS; ci/check_param_catalog.py PASSED.

Canon: none (command-line parse restructure of main_ltc.cpp; no consensus, payout or share-format change)

MSVC stops at src/c2pool/main_ltc.cpp(1940,17) with C1061 (blocks nested
too deeply; limit 128): the argument loop in main() was one if/else-if
chain of 119 branches, 118 else-ifs, nesting 126 at the positional
branch.

main_ltc.cpp: each flag is an independent if inside the loop. 113 branches
end in continue, 5 end in return as before (--help/-h,
--dump-doge-schedule-anchors, --utxo-digest, --utxo-stats,
--ltc-utxo-stats). Checks run in the same order; the unknown-argument
check and the positional branch stay last. Longest else-if chain in
main() now 3, deepest nesting 23.

Against master, the C++ tokens differ only by the 118 removed else and the
113 added continue.

Behaviour check: master and this tree built with one identical dump of
every local the loop writes, printed right after the loop. 302 argv cases
(each of the 139 flag spellings once, with a value where it takes one;
each value flag with its value missing at the end of argv; unknown flags;
positional arguments; order, repeats and bad values; all flags at once):
302 of 302 give the same exit code, stdout and stderr. --help output is
identical. test_settings_cli_scan ALL PASS; ci/check_param_catalog.py
PASSED (453 main flag spellings, 441 catalog aliases).
The argument chain in main_v37_xmr.cpp main() had 92 else-ifs (MSVC
C1061 limit 128). It is split before --relay-listen into two chains of
42 and 49: the first ends in else flag_matched = false, and a match there
is recorded and moves to the next argument; the second keeps the
unknown-option and unexpected-argument errors and the record() after it.
Same flags in the same order, same recorded flags, errors and exit codes.
Against master, the C++ tokens differ only by the added flag_matched
declaration and the else flag_matched = false; if (flag_matched)
{ record(); continue; } between the two chains. v37_xmr_cli_strict_kat
gives the same result for all 1622 rows on master's binary and this one.
Reverts 9432722. main_v37_xmr.cpp's longest else-if chain is 92, below
the MSVC nesting limit; its split goes through the XMR lane separately.
This change then touches src/c2pool/main_ltc.cpp only.
@frstrtr frstrtr changed the title ltc, v37-xmr: command-line parsing under the MSVC nesting limit (Windows build) ltc: command-line parsing under the MSVC nesting limit (Windows build) Nov 28, 2026
@frstrtr
frstrtr merged commit d52abc3 into master Nov 28, 2026
41 of 42 checks passed
frstrtr added a commit that referenced this pull request Nov 28, 2026
master brings #2353 (one scrypt per DGB submit: the vardiff gate's digest
reused by mining_submit for byte-equal headers), #2361, #2357, #2352 and
#2363. work_source.cpp keeps both sides; its include block takes both
<atomic> and <cctype>.
frstrtr added a commit that referenced this pull request Nov 28, 2026
One commit, src/core/http_session.cpp only. Responses are unchanged.

- **Why.** `HttpSession::process_request` matched its REST routes with one else-if chain of 87 branches (nesting 111). MSVC stops at about 128 nested blocks (C1061, as in #2361), so about 17 more routes would have broken the Windows build.
- **Change.** The chain is split into four chains (27, 27, 25 and 9 branches), joined by a `route_matched` flag, the pattern `main_dash.cpp` uses.
  - Most branches set `rest_result` / `response_body` and fall through to the shared response code after the chain, so the split keeps that code path as it was.
  - The fourth chain keeps the original final else: admin, explorer, static files, 404 and the getinfo fallback.
  - Route order, conditions, the guards before the chain and the code after it are unchanged. A token diff against master (comments excluded) adds only the `route_matched` tokens and three braces.
- **After:** longest else-if chain 26; deepest nesting in `process_request` 37.

## Checks (Release)
- **Old vs new responses**, compared byte for byte by a temporary harness (not committed) on three local servers: every function wired, nothing wired, and token/CORS/not-ready.
  - Requests: every route on the web and stratum ports with GET and HEAD, prefix, bad-parameter, unknown, static and traversal variants, X-Forwarded-For, token and If-None-Match cases, other methods, and POST bodies.
  - **3624 requests:** 3602 byte-identical; the other 22 differ only in time fields (`timestamp`, `computed_at`, `ts`, `started`). They are identical once those fields are masked, and two runs of the old binary differ in exactly the same 22.
- core_test HTTP/web/stratum-HTTP suites: 278 passed on both binaries; full core_test 870 passed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant