agorix
AirdropMarketsCollectionsLeaderboardActivity
Agorix · Decentralized Marketplace
Independent · Resilient · Community-Run

A cross-chain marketplace, run by the community.

Discover, list, and trade across Bitcoin, Ethereum, and Solana on an open, community-run network.

Marketplace
CollectionsMarketsLeaderboardActivity
Network
GovernanceExplorerAirdropDocs
Account
ProfileSettings
Legal
Terms of ServicePrivacy PolicyYour Privacy Choices
agorix.io — Lasting Access
CID: 0xA60R1X · v0.1
AirdropMarketsCollections
D
Protocol Docs
Marketplace OverviewAtomic Buy LocksDatabase ArchitectureProfiles & AuthenticationCollections & RoyaltiesCreator Royalty SystemMedia Cache & OptimizationModeration & ReputationSearch & DiscoveryCollection Rarity AlgorithmsLive Activity & LeaderboardsCollection Preseed Queue
Docs/Marketplace/Atomic Buy Locks
Marketplace

Atomic Buy Locks

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.

#Atomic Buy Locks

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.

#Lock Acquisition

When a buyer submits an order intent, the serving node calls acquireBuyLock:

  • Check the in-memory lock registry (getActiveBuyLock) for any competing active lock on this listing
  • If a competing lock exists for a different buyer, reject with PRECONDITION_FAILED
  • Otherwise, generate a 256-bit lockNonce and compute a tiebreakHash from (buyerPubkey, orderId, lockNonce)
  • Sign and emit a BUY_LOCK protocol event (Ed25519, gossiped network-wide)
  • Insert a buyLocks row with status LOCKED, expiry, and the lock nonce
  • Broadcast a BUY_LOCK_NOTIFY fast-push frame on the mesh
  • Wait briefly for any racing notifies; if a competing notify arrives, mark the lock LOST and roll back

The lock TTL is 300 seconds. If the buyer disappears, an expiry sweeper releases the slot so the listing can move again.

#Marketplace Fast-Push Wire Frames

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:

ByteFramePurpose
0x40MARKETPLACE_FAST_PUSHListing/order updates that need sub-second propagation
0x41BUY_LOCK_NOTIFY"I just locked this listing" announcement
0x42BUY_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.

#Deterministic Tiebreak

Because frames cross the mesh asynchronously, two nodes can each believe their own buyer locked first. The tiebreak hash resolves this without coordination:

text
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.

#Reward Reversal

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:

  • Stranded UI provider fees: return the served quote fee to the buyer
  • Witness work: small participation reward to attesting witnesses on the losing branch

Reversal claims enter the standard weekly epoch like any other reward — they are not a special-case payout path.

#Buy Lock States

StatusMeaning
LOCKEDActive lock, listing is reserved for this buyer
COMPLETEDPurchase settled successfully, lock released cleanly
LOSTLost the deterministic tiebreak — buyer must retry
EXPIREDTTL elapsed without settlement, swept by buyLockExpiry
CANCELLEDBuyer abandoned the order before settlement

The buyLockExpiry worker runs continuously, transitioning expired LOCKED rows to EXPIRED and freeing the listing for the next buyer.

#Why This Matters

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.

PreviousMarketplace OverviewNext Database Architecture

On this page

  • Atomic Buy Locks
  • Lock Acquisition
  • Marketplace Fast-Push Wire Frames
  • Deterministic Tiebreak
  • Reward Reversal
  • Buy Lock States
  • Why This Matters