X402.Facilitator.PendingSettlementStore.ETS (X402 v0.6.0)

Copy Markdown View Source

ETS-backed pending-settlement store adapter.

Entries expire after :ttl_ms (default: 5 minutes, matching the reference SDKs' pending-settlement TTL). Expired entries are removed by an internal periodic cleanup loop.

Per-node only

The ETS table lives on the local node. A facilitator running more than one instance behind a load balancer must supply a shared-store adapter instead — a retried settlement routed to a different node would miss this table and re-broadcast. See the adapter sketch in X402.Facilitator.PendingSettlementStore.

Usage

Add the store to your supervision tree and pass it to the engine:

children = [
  {X402.Facilitator.PendingSettlementStore.ETS, name: MyApp.PendingStore}
]

{:ok, engine} =
  X402.Facilitator.Engine.new(
    rpc: rpc,
    signer: signer,
    networks: ["eip155:84532"],
    pending_settlement_store:
      {X402.Facilitator.PendingSettlementStore.ETS, MyApp.PendingStore}
  )

Summary

Types

Server identifier accepted by GenServer.call/3.

Functions

Deletes a pending settlement entry.

Looks up a pending settlement by key.

Stores a pending settlement entry, resetting its TTL.

Starts an ETS-backed pending-settlement store process.

Types

server()

@type server() :: GenServer.server()

Server identifier accepted by GenServer.call/3.

Functions

child_spec(init_arg)

(since 0.6.0)
@spec child_spec(keyword()) :: Supervisor.child_spec()

Returns a child specification for X402.Facilitator.PendingSettlementStore.ETS.

delete(store, key)

(since 0.6.0)

Deletes a pending settlement entry.

get(store, key)

(since 0.6.0)

Looks up a pending settlement by key.

put(store, key, entry)

(since 0.6.0)

Stores a pending settlement entry, resetting its TTL.

When the table is at :max_size and purging expired entries does not free a slot, returns {:error, :store_full} rather than evicting a live entry — evicting a live pending record would silently turn its retry into a second broadcast attempt. The engine treats a failed put as "could not persist for retry" and reports the settlement accordingly.

start_link(opts \\ [])

(since 0.6.0)
@spec start_link(keyword()) ::
  GenServer.on_start() | {:error, NimbleOptions.ValidationError.t()}

Starts an ETS-backed pending-settlement store process.

Options