Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
ignore accidental archival orders is repsectful live orders are recei…
Browse files Browse the repository at this point in the history
…ved (#164)
  • Loading branch information
alexeychr authored Dec 20, 2023
1 parent 58dd217 commit 2130057
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@debridge-finance/dln-taker",
"version": "3.1.0",
"version": "3.1.1",
"description": "DLN executor is the rule-based daemon service developed to automatically execute orders placed on the deSwap Liquidity Network (DLN) across supported blockchains",
"license": "GPL-3.0-only",
"author": "deBridge",
Expand Down
12 changes: 9 additions & 3 deletions src/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,21 @@ export class OrderProcessor {

// creation events must be tracked in a separate storage
if ([OrderInfoStatus.Created, OrderInfoStatus.ArchivalCreated].includes(status)) {
if (this.#createdOrdersMetadata.has(orderId)) {
this.#createdOrdersMetadata.get(orderId)!.context = context;
} else {
// order is not yet known
if (!this.#createdOrdersMetadata.has(orderId)) {
this.#createdOrdersMetadata.set(orderId, {
orderId,
arrivedAt: new Date(),
attempts: 0,
context,
});
// order is known, so we receive only Live updates. Archival orders should not override data
} else if (context.orderInfo.status === OrderInfoStatus.Created) {
const knownContext = this.#createdOrdersMetadata.get(orderId)!.context;
// only finalization_info to be updated
(<IncomingOrder<OrderInfoStatus.Created>>knownContext.orderInfo).finalization_info = (<
IncomingOrder<OrderInfoStatus.Created>
>context.orderInfo).finalization_info;
}
}

Expand Down

0 comments on commit 2130057

Please sign in to comment.