Refactor router into runner, dispatcher, cashier, and order_book modules #617

Merged
paratoxic merged 12 commits from router-refactor into master 2026-08-25 22:31:38 +00:00
Owner
No description provided.
Refactor router into supervisor, dispatcher, cashier, and order book modules
Some checks failed
CI / ckpool (pull_request) Successful in 1m2s
CI / lint (pull_request) Successful in 6m56s
CI / test-linux (pull_request) Failing after 20m10s
1ec7feed60
Remove Paid order status from router refactor
All checks were successful
CI / ckpool (pull_request) Successful in 30s
CI / lint (pull_request) Successful in 3m10s
CI / test-linux (pull_request) Successful in 14m50s
bdfbb2d36f
The Paid status was introduced as a lifecycle marker between payment
confirmation and connect, but it changes what gets persisted to redb:
an order sitting in Paid would serialize as "paid", which the previous
release cannot decode on startup, breaking rollback.

The refactor must roll forward and backward cleanly against the existing
database and API. Removing the Paid variant entirely restores
byte-identical persisted records and identical external behavior:
orders transition from InMempool directly into connect, exactly as on
master. The payment-gating logic in cashier.wait_for_payment is
unchanged and now fully matches master.
Restore atomic capacity check in add_bucket_order
Some checks failed
CI / ckpool (pull_request) Successful in 14s
CI / lint (pull_request) Successful in 2m25s
CI / test-linux (pull_request) Failing after 9m5s
33911bd610
The refactor split the capacity check, id allocation, wallet reveal, and
order insertion across separate OrderBook read and write locks, whereas
master held the orders write lock across the entire sequence. Concurrent
admin order requests could therefore both pass the capacity check before
either inserted, overshooting the configured capacity.

Give OrderBook a checked add_bucket_order that holds a single write lock
across the capacity check, id allocation, address reveal, and insertion,
restoring master's serialization.

Also remove the redundant double insertion on restore and the now-unneeded
register_and_execute indirection.
Mirror the pattern used by the party command: give the proxy its own slim
node type that composes only the router components it needs, rather than
constructing a full Router with a None wallet and a throwaway initial hash
value.

The proxy only ever runs sink orders and exposes a status-only API, so the
new src/proxy.rs node holds just OrderBook, Control, OrderSupervisor
([Connect] stage, no cashier), and Dispatcher. It drops the wallet,
cashier, price feed, capacity, and bucket-order machinery entirely,
removing the Option<Wallet> and HashValue::from_sats(1) placeholder from
the proxy path.

subcommand/proxy.rs now builds Proxy::new, and api/proxy.rs takes
Arc<Proxy>. The ProxyStatus JSON shape is unchanged, so there is no API or
redb change. Router is left intact for the router binary and its tests.
The components each use one to three Settings accessors, and every caller
already has an Arc<Settings>, matching the codebase convention (Control on
master, Dispatcher, Stratifier, Wallet). NodeConfig added indirection
without decoupling anything.
The Vec<Stage> + Stage enum was speculative generality for a single fixed
sequence that no current consumer varies: await payment, then connect.
Hardcode that sequence in execute_order and drop the stages parameter from
OrderSupervisor::new.

The proxy needed no special-casing: await_payment already returns Ok(true)
immediately for sink orders (no bucket), so a None-cashier proxy supervisor
behaves identically with the stage list removed.

If a future consumer needs to insert a phase (e.g. a gate), it can
introduce the stage abstraction at that call site where it is motivated.
Consolidate
Some checks failed
CI / ckpool (pull_request) Successful in 26s
CI / lint (pull_request) Successful in 2m57s
CI / test-linux (pull_request) Failing after 12m20s
7b882af554
Relevel
Some checks failed
CI / ckpool (pull_request) Successful in 28s
CI / lint (pull_request) Failing after 3m20s
CI / test-linux (pull_request) Successful in 15m44s
8024e372d4
paratoxic changed title from Refactor router into supervisor, dispatcher, cashier, and order book modules to Refactor router into runner, dispatcher, cashier, and order book modules 2026-08-25 02:06:49 +00:00
Solidify
Some checks failed
CI / ckpool (pull_request) Successful in 50s
CI / lint (pull_request) Successful in 4m5s
CI / test-linux (pull_request) Failing after 12m34s
c168c0a4c2
paratoxic changed title from Refactor router into runner, dispatcher, cashier, and order book modules to Refactor router into runner, dispatcher, cashier, and order_book modules 2026-08-25 02:21:42 +00:00
use independent cancel tokens
Some checks failed
CI / ckpool (pull_request) Successful in 12s
CI / lint (pull_request) Successful in 2m49s
CI / test-linux (pull_request) Failing after 10m34s
89e85a148a
Update
Some checks failed
CI / ckpool (pull_request) Successful in 44s
CI / lint (pull_request) Successful in 3m3s
CI / test-linux (pull_request) Failing after 11m42s
cb3d12dcf9
Fix
Some checks failed
CI / ckpool (pull_request) Successful in 15s
CI / lint (pull_request) Successful in 2m49s
CI / test-linux (pull_request) Failing after 14m11s
33c67cdb35
paratoxic merged commit 7116a5ea41 into master 2026-08-25 22:31:38 +00:00
paratoxic deleted branch router-refactor 2026-08-25 22:31:39 +00:00
Sign in to join this conversation.
No description provided.