Show / Hide Table of Contents

Class InMemorySettledPaymentStore

Process-local ISettledPaymentStore. Suitable for a single instance only: several instances behind a load balancer need a shared store.

Inheritance
object
InMemorySettledPaymentStore
Implements
ISettledPaymentStore
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 Source

InMemorySettledPaymentStore(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 LastLedgerSequence.

Fields

| Edit this page View Source

DefaultRetentionMarginLedgers

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 Source

Count

Number of claims currently held.

Declaration
public int Count { get; }
Property Value
Type Description
int
| Edit this page View Source

RetentionMarginLedgers

Ledgers a claim is kept past its LastLedgerSequence.

Declaration
public uint RetentionMarginLedgers { get; }
Property Value
Type Description
uint

Methods

| Edit this page View Source

ReleaseAsync(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
| Edit this page View Source

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 LastLedgerSequence: the claim must be kept at least until a later ledger is validated.

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>

true when the hash was not claimed and now is; false when it is already claimed, whether settled or still being settled.

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.

Implements

ISettledPaymentStore
  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX