@atomiqlabs/lp-lib 16.0.3 → 16.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -82,7 +82,7 @@ export declare abstract class SwapHandler<V extends SwapHandlerSwap<S> = SwapHan
82
82
  readonly swapPricing: ISwapPrice;
83
83
  abstract readonly inflightSwapStates: Set<S>;
84
84
  abstract config: SwapBaseConfig;
85
- inflightSwaps: Set<SwapHandlerSwap<S>>;
85
+ inflightSwaps: Set<string>;
86
86
  logger: LoggerType;
87
87
  protected swapLogger: {
88
88
  debug: (swap: SwapHandlerSwap, msg: string, ...args: any) => void;
@@ -67,7 +67,7 @@ class SwapHandler {
67
67
  await this.storageManager.saveData(swap.getIdentifierHash(), swap.getSequence(), swap);
68
68
  }
69
69
  if (this.inflightSwapStates.has(swap.state))
70
- this.inflightSwaps.add(swap);
70
+ this.inflightSwaps.add(swap.getIdentifier());
71
71
  }
72
72
  }
73
73
  /**
@@ -77,7 +77,8 @@ class SwapHandler {
77
77
  * @param ultimateState set the ultimate state of the swap before removing
78
78
  */
79
79
  async removeSwapData(swap, ultimateState) {
80
- this.inflightSwaps.delete(swap);
80
+ this.inflightSwaps.delete(swap.getIdentifier());
81
+ this.logger.debug("removeSwapData(): Removing in-flight swap, current in-flight swaps: " + this.inflightSwaps.size);
81
82
  if (ultimateState != null)
82
83
  await swap.setState(ultimateState);
83
84
  if (swap != null)
@@ -87,10 +88,12 @@ class SwapHandler {
87
88
  }
88
89
  async saveSwapData(swap) {
89
90
  if (this.inflightSwapStates.has(swap.state)) {
90
- this.inflightSwaps.add(swap);
91
+ this.inflightSwaps.add(swap.getIdentifier());
92
+ this.logger.debug("removeSwapData(): Adding in-flight swap, current in-flight swaps: " + this.inflightSwaps.size);
91
93
  }
92
94
  else {
93
- this.inflightSwaps.delete(swap);
95
+ this.inflightSwaps.delete(swap.getIdentifier());
96
+ this.logger.debug("removeSwapData(): Removing in-flight swap, current in-flight swaps: " + this.inflightSwaps.size);
94
97
  }
95
98
  await this.storageManager.saveData(swap.getIdentifierHash(), swap.getSequence(), swap);
96
99
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atomiqlabs/lp-lib",
3
- "version": "16.0.3",
3
+ "version": "16.0.4",
4
4
  "description": "Main functionality implementation for atomiq LP node",
5
5
  "main": "./dist/index.js",
6
6
  "types:": "./dist/index.d.ts",
@@ -89,7 +89,7 @@ export abstract class SwapHandler<V extends SwapHandlerSwap<S> = SwapHandlerSwap
89
89
  abstract readonly inflightSwapStates: Set<S>;
90
90
  abstract config: SwapBaseConfig;
91
91
 
92
- inflightSwaps: Set<SwapHandlerSwap<S>> = new Set();
92
+ inflightSwaps: Set<string> = new Set();
93
93
 
94
94
  logger: LoggerType = getLogger(() => "SwapHandler("+this.type+"): ");
95
95
 
@@ -156,7 +156,7 @@ export abstract class SwapHandler<V extends SwapHandlerSwap<S> = SwapHandlerSwap
156
156
  await this.storageManager.removeData(hash, sequence);
157
157
  await this.storageManager.saveData(swap.getIdentifierHash(), swap.getSequence(), swap);
158
158
  }
159
- if(this.inflightSwapStates.has(swap.state)) this.inflightSwaps.add(swap);
159
+ if(this.inflightSwapStates.has(swap.state)) this.inflightSwaps.add(swap.getIdentifier());
160
160
  }
161
161
  }
162
162
 
@@ -179,7 +179,8 @@ export abstract class SwapHandler<V extends SwapHandlerSwap<S> = SwapHandlerSwap
179
179
  * @param ultimateState set the ultimate state of the swap before removing
180
180
  */
181
181
  protected async removeSwapData(swap: V, ultimateState?: S) {
182
- this.inflightSwaps.delete(swap);
182
+ this.inflightSwaps.delete(swap.getIdentifier());
183
+ this.logger.debug("removeSwapData(): Removing in-flight swap, current in-flight swaps: "+this.inflightSwaps.size);
183
184
  if(ultimateState!=null) await swap.setState(ultimateState);
184
185
  if(swap!=null) await PluginManager.swapRemove(swap);
185
186
  this.swapLogger.debug(swap, "removeSwapData(): removing swap final state: "+swap.state);
@@ -188,9 +189,11 @@ export abstract class SwapHandler<V extends SwapHandlerSwap<S> = SwapHandlerSwap
188
189
 
189
190
  protected async saveSwapData(swap: V) {
190
191
  if(this.inflightSwapStates.has(swap.state)) {
191
- this.inflightSwaps.add(swap);
192
+ this.inflightSwaps.add(swap.getIdentifier());
193
+ this.logger.debug("removeSwapData(): Adding in-flight swap, current in-flight swaps: "+this.inflightSwaps.size);
192
194
  } else {
193
- this.inflightSwaps.delete(swap);
195
+ this.inflightSwaps.delete(swap.getIdentifier());
196
+ this.logger.debug("removeSwapData(): Removing in-flight swap, current in-flight swaps: "+this.inflightSwaps.size);
194
197
  }
195
198
  await this.storageManager.saveData(swap.getIdentifierHash(), swap.getSequence(), swap);
196
199
  }