Class InMemorySettledPaymentStore
Process-local ISettledPaymentStore. Suitable for a single instance only: several instances behind a load balancer need a shared store.
Inheritance
Implements
Namespace: Xrpl.X402.AspNetCore
Assembly: Xrpl.X402.AspNetCore.dll
Syntax
public sealed class InMemorySettledPaymentStore : ISettledPaymentStore
Remarks
A claim is kept until the validated ledger passes its LastLedgerSequence by
RetentionMarginLedgers. The margin covers a request that read the validated ledger
before another request advanced it and pruned: that request still checks the blob's expiry
against its older ledger, and must still find the claim.
Constructors
| Edit this page View SourceInMemorySettledPaymentStore(uint)
Initializes a new instance of InMemorySettledPaymentStore.
Declaration
public InMemorySettledPaymentStore(uint retentionMarginLedgers = 256)
Parameters
| Type | Name | Description |
|---|---|---|
| uint | retentionMarginLedgers | Ledgers a claim is kept past its |
Fields
| Edit this page View SourceDefaultRetentionMarginLedgers
Default RetentionMarginLedgers: about a quarter of an hour on mainnet.
Declaration
public const uint DefaultRetentionMarginLedgers = 256
Field Value
| Type | Description |
|---|---|
| uint |
Properties
| Edit this page View SourceCount
Number of claims currently held.
Declaration
public int Count { get; }
Property Value
| Type | Description |
|---|---|
| int |
RetentionMarginLedgers
Ledgers a claim is kept past its LastLedgerSequence.
Declaration
public uint RetentionMarginLedgers { get; }
Property Value
| Type | Description |
|---|---|
| uint |
Methods
| Edit this page View SourceReleaseAsync(string, CancellationToken)
Drops a claim whose settlement did not succeed, so the payer can present the same blob again.
Declaration
public ValueTask ReleaseAsync(string transactionHash, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | transactionHash | Hash passed to TryReserveAsync(string, uint, uint, CancellationToken). |
| CancellationToken | cancellationToken | Cancels the operation. |
Returns
| Type | Description |
|---|---|
| ValueTask |
TryReserveAsync(string, uint, uint, CancellationToken)
Atomically claims transactionHash for settlement.
Declaration
public ValueTask<bool> TryReserveAsync(string transactionHash, uint lastLedgerSequence, uint validatedLedgerIndex, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | transactionHash | Hash of the signed transaction, uppercase hex. |
| uint | lastLedgerSequence | The transaction's |
| uint | validatedLedgerIndex | The latest validated ledger the facilitator saw; claims whose window ended well before it may be dropped. |
| CancellationToken | cancellationToken | Cancels the operation. |
Returns
| Type | Description |
|---|---|
| ValueTask<bool> |
|
Remarks
An implementation that throws must leave the hash unclaimed. The facilitator cannot release a
claim it was not told it holds - releasing it could drop a concurrent caller's claim and admit
the blob twice - so a claim written before an exception (a cancelled request, a reply that
timed out) refuses the blob as duplicate_payment until the store prunes it.