Table of Contents

Class ArkadeIntentAdvanceService

Namespace
NArk.ArkadeIntents.Services
Assembly
NArk.ArkadeIntents.dll

Does for every swap whatever its state already calls for.

public sealed class ArkadeIntentAdvanceService : BackgroundService, IHostedService, IDisposable
Inheritance
ArkadeIntentAdvanceService
Implements
Inherited Members

Remarks

The companion to ArkadeSwapIntentMonitoringService, and registered beside it because half the mechanism is worse than none. The monitor observes — it moves a swap to Claimable when the counterparty's lockup appears, and to Fulfilled or Resolved once it is spent — and observing was all that happened by default. Acting on what it observed was left to whoever wired the SDK up, which is a dangerous thing to leave out: the receive window is a couple of hours, and a swap that reaches Claimable while nobody is running a loop is a payment that quietly does not arrive.

What to do is decided by ArkadeIntentPolicy and not here; this supplies a clock. The two actions it will take are claiming a funded receive and refunding a send the solver never filled. Cancelling a pending swap is deliberately not among them — a pending swap is waiting to be filled, which is what was asked for.

A pass covers many swaps, so a failure is logged and the pass continues: one swap that cannot proceed must not stop the others, nor end the loop that would have retried it.

Constructors

ArkadeIntentAdvanceService(ArkadeIntentsService, IArkadeIntentStorage, IOptions<ArkadeIntentAdvanceOptions>?, ILogger<ArkadeIntentAdvanceService>?)

Does for every swap whatever its state already calls for.

public ArkadeIntentAdvanceService(ArkadeIntentsService intents, IArkadeIntentStorage intentStorage, IOptions<ArkadeIntentAdvanceOptions>? options = null, ILogger<ArkadeIntentAdvanceService>? logger = null)

Parameters

intents ArkadeIntentsService
intentStorage IArkadeIntentStorage
options IOptions<ArkadeIntentAdvanceOptions>
logger ILogger<ArkadeIntentAdvanceService>

Remarks

The companion to ArkadeSwapIntentMonitoringService, and registered beside it because half the mechanism is worse than none. The monitor observes — it moves a swap to Claimable when the counterparty's lockup appears, and to Fulfilled or Resolved once it is spent — and observing was all that happened by default. Acting on what it observed was left to whoever wired the SDK up, which is a dangerous thing to leave out: the receive window is a couple of hours, and a swap that reaches Claimable while nobody is running a loop is a payment that quietly does not arrive.

What to do is decided by ArkadeIntentPolicy and not here; this supplies a clock. The two actions it will take are claiming a funded receive and refunding a send the solver never filled. Cancelling a pending swap is deliberately not among them — a pending swap is waiting to be filled, which is what was asked for.

A pass covers many swaps, so a failure is logged and the pass continues: one swap that cannot proceed must not stop the others, nor end the loop that would have retried it.

Methods

ExecuteAsync(CancellationToken)

This method is called when the IHostedService starts. The implementation should return a task that represents the lifetime of the long running operation(s) being performed.

protected override Task ExecuteAsync(CancellationToken stoppingToken)

Parameters

stoppingToken CancellationToken

Triggered when StopAsync(CancellationToken) is called.

Returns

Task

A Task that represents the long running operations.

Remarks

See Worker Services in .NET for implementation guidelines.