Deterministic concurrency control for purchase intents. How distributed buy locks, fast-push gossip, tiebreak hashing, and reward reversal keep one listing from selling twice when multiple buyers arrive at once.
Two buyers can hit the same listing at the same time on different nodes. Without a coordination layer, the network might attest two competing purchases and only one can settle on-chain — the other becomes a wasted ceremony with stranded fees and reward claims. The buy lock system gives every listing exactly one in-flight buyer at a time and resolves ties deterministically across the mesh.
When a buyer submits an order intent, the serving node calls acquireBuyLock:
getActiveBuyLock) for any competing active lock on this listingPRECONDITION_FAILEDlockNonce and compute a tiebreakHash from (buyerPubkey, orderId, lockNonce)BUY_LOCK protocol event (Ed25519, gossiped network-wide)buyLocks row with status LOCKED, expiry, and the lock nonceBUY_LOCK_NOTIFY fast-push frame on the meshLOST and roll backThe lock TTL is 300 seconds. If the buyer disappears, an expiry sweeper releases the slot so the listing can move again.
Buy locks ride a dedicated low-latency mesh path separate from the normal event gossip layer. Three binary frame types share the marketplace fast-push range:
| Byte | Frame | Purpose |
|---|---|---|
| 0x40 | MARKETPLACE_FAST_PUSH | Listing/order updates that need sub-second propagation |
| 0x41 | BUY_LOCK_NOTIFY | "I just locked this listing" announcement |
| 0x42 | BUY_LOCK_CONFLICT | "Two locks observed for this listing — resolve the tie" |
These frames are gzip-compressed where it helps and dual-pathed: broadcast directly to mesh peers AND relayed through the Sentinel beacon backbone for cross-region acceleration. The signed BUY_LOCK protocol event still flows through normal gossip for permanent record — fast-push is the immediate signal, the protocol event is the receipt.
Because frames cross the mesh asynchronously, two nodes can each believe their own buyer locked first. The tiebreak hash resolves this without coordination:
tiebreakHash = SHA256(buyerPubkey || orderId || lockNonce)Every honest node observing both BUY_LOCK events independently sorts by tiebreak hash (lower wins, lex order on ties). The losing lock transitions to LOST status, the losing node returns PRECONDITION_FAILED to its buyer, and the network converges on a single canonical lock without any vote or coordinator.
If a lock loses the tiebreak after the buyer has already paid quote fees, the network owes the loser a refund. The rewardReversal lifecycle hook walks the affected events and emits compensating reward claims:
Reversal claims enter the standard weekly epoch like any other reward — they are not a special-case payout path.
| Status | Meaning |
|---|---|
LOCKED | Active lock, listing is reserved for this buyer |
COMPLETED | Purchase settled successfully, lock released cleanly |
LOST | Lost the deterministic tiebreak — buyer must retry |
EXPIRED | TTL elapsed without settlement, swept by buyLockExpiry |
CANCELLED | Buyer abandoned the order before settlement |
The buyLockExpiry worker runs continuously, transitioning expired LOCKED rows to EXPIRED and freeing the listing for the next buyer.
The naive alternative — first-write-wins at settlement time — fails because chain confirmations are slow and witnesses are async, so a conflict only surfaces after both purchases have already consumed witness work. Locking at intent time, broadcasting on the fast-push path, and resolving with a deterministic hash means every node converges in milliseconds without any leader election or consensus round. The same listing cannot enter two simultaneous settlements.