You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
refactor(node,incentive): delete node's byte-identical buyer-store re-implementation; hoist the shared codec into incentive #1246
crates/node/src/channel_store.rs carries a full buyer-channel redb store (StoredBuyerChannelState, decode_buyer_record, buyer impls + BuyerChannelStoreHandle, roughly channel_store.rs:763-1281) that re-implements what the incentive crate already ships: RedbBuyerChannelStore in crates/incentive/src/buyer_channel_redb.rs (exported at incentive/src/lib.rs:26).
The incentive struct is explicitly documented as byte-compatible with the node's buyer table (buyer_channel_redb.rs:43-45): same table name (buyer_channel_state_v1), same fields, same postcard/take_from_bytes decode, same BUYER_SUPPORTED_SCHEMA_VERSION = 1. That's ~500-570 prod lines (plus ~250 lines of buyer-store tests that duplicate buyer_channel_redb.rs:489-510) maintained twice, with the byte-compat contract enforced only by comment.
The only reason node has its own copy is that it wants buyer + seller + pending-settle + watcher checkpoints in ONE channels.redb file/transaction (PersistentChannelStateStore, channel_store.rs:259), while incentive's store opens its own file (buyer_channel_redb.rs:138).
Proposed fix (low-risk variant)
Extract the shared surface — StoredBuyerChannelState + encode/decode + schema-version constants — into incentive as the single definition, and have both stores consume it. Node keeps only its thin "which redb file/table/transaction" wiring; the single-file transaction layout and on-disk format are untouched.
The alternative (node adopts RedbBuyerChannelStore wholesale, separate buyer file) touches on-disk layout/migration — not worth it; the codec hoist gets the dedup without a format change.
Acceptance
One definition of the buyer record codec, in incentive; node imports it.
No change to channels.redb on-disk format (existing stores open cleanly).
Duplicated buyer-store tests collapse to one suite next to the codec.
Activity
refactor(node,incentive): hoist the duplicated buyer-channel redb sto…