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
Returns a child specification for X402.Facilitator.PendingSettlementStore.ETS.
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
@type server() :: GenServer.server()
Server identifier accepted by GenServer.call/3.
Functions
@spec child_spec(keyword()) :: Supervisor.child_spec()
Returns a child specification for X402.Facilitator.PendingSettlementStore.ETS.
@spec delete(server(), X402.Facilitator.PendingSettlementStore.key()) :: X402.Facilitator.PendingSettlementStore.write_result()
Deletes a pending settlement entry.
@spec get(server(), X402.Facilitator.PendingSettlementStore.key()) :: X402.Facilitator.PendingSettlementStore.get_result()
Looks up a pending settlement by key.
@spec put( server(), X402.Facilitator.PendingSettlementStore.key(), X402.Facilitator.PendingSettlementStore.entry() ) :: X402.Facilitator.PendingSettlementStore.write_result()
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.
@spec start_link(keyword()) :: GenServer.on_start() | {:error, NimbleOptions.ValidationError.t()}
Starts an ETS-backed pending-settlement store process.
Options
:name(term/0) - Registered name for the store process. The default value isX402.Facilitator.PendingSettlementStore.ETS.:ttl_ms(non_neg_integer/0) - Time-to-live for entries in milliseconds. The default value is300000.:cleanup_interval_ms(pos_integer/0) - How often expired entries are cleaned up, in milliseconds. The default value is60000.:max_size(pos_integer/0) - Maximum number of entries in the store. The default value is10000.