edge-currency-plugins 3.8.6 → 3.8.7
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.
|
@@ -115,6 +115,17 @@ var _utils3 = require('./utils');
|
|
|
115
115
|
transactionUpdateCache: {}
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
+
// Track pending timeouts so they can be cleared on stop
|
|
119
|
+
const pendingTimeouts = new Set()
|
|
120
|
+
|
|
121
|
+
// Clear all pending timeouts
|
|
122
|
+
const clearPendingTimeouts = () => {
|
|
123
|
+
for (const timeoutId of pendingTimeouts) {
|
|
124
|
+
clearTimeout(timeoutId)
|
|
125
|
+
}
|
|
126
|
+
pendingTimeouts.clear()
|
|
127
|
+
}
|
|
128
|
+
|
|
118
129
|
const clearTaskCache = () => {
|
|
119
130
|
for (const key of Object.keys(taskCache.addressForTransactionsCache)) {
|
|
120
131
|
_utils.removeItem.call(void 0, taskCache.addressForTransactionsCache, key)
|
|
@@ -212,6 +223,7 @@ var _utils3 = require('./utils');
|
|
|
212
223
|
dataLayer,
|
|
213
224
|
emitter,
|
|
214
225
|
taskCache,
|
|
226
|
+
pendingTimeouts,
|
|
215
227
|
updateProgressRatio,
|
|
216
228
|
updateSeenTxCheckpoint,
|
|
217
229
|
io,
|
|
@@ -358,6 +370,7 @@ var _utils3 = require('./utils');
|
|
|
358
370
|
async stop() {
|
|
359
371
|
serverStates.stop()
|
|
360
372
|
clearTaskCache()
|
|
373
|
+
clearPendingTimeouts()
|
|
361
374
|
running = false
|
|
362
375
|
},
|
|
363
376
|
|
|
@@ -685,6 +698,7 @@ const internalGetFreshAddress = async (
|
|
|
685
698
|
|
|
686
699
|
|
|
687
700
|
|
|
701
|
+
|
|
688
702
|
|
|
689
703
|
|
|
690
704
|
const setLookAhead = async (common) => {
|
|
@@ -1154,9 +1168,18 @@ async function* processCheckTransactionConfirmation(
|
|
|
1154
1168
|
} catch (err) {
|
|
1155
1169
|
console.error(err)
|
|
1156
1170
|
common.log('error while processing transaction update:', err)
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1171
|
+
// Delay putting the transaction back into the cache to avoid thrashing
|
|
1172
|
+
// on dropped transactions. 10 seconds is a reasonable compromise between
|
|
1173
|
+
// thrashing and not waiting too long.
|
|
1174
|
+
addPendingTimeout(
|
|
1175
|
+
common,
|
|
1176
|
+
() => {
|
|
1177
|
+
common.taskCache.transactionUpdateCache[txId] = {
|
|
1178
|
+
processing: false
|
|
1179
|
+
}
|
|
1180
|
+
},
|
|
1181
|
+
10000
|
|
1182
|
+
)
|
|
1160
1183
|
return false
|
|
1161
1184
|
}
|
|
1162
1185
|
}
|
|
@@ -1681,3 +1704,22 @@ const addToDataLayerUtxoCache = (
|
|
|
1681
1704
|
dataLayerUtxoCache[scriptPubkey] = dataLayerUtxos
|
|
1682
1705
|
dataLayerUtxos.full = dataLayerUtxos.utxos.length >= requiredCount
|
|
1683
1706
|
}
|
|
1707
|
+
|
|
1708
|
+
/**
|
|
1709
|
+
* This adds a pending timeout to the common.pendingTimeouts set.
|
|
1710
|
+
* It will call the callback after the timeout.
|
|
1711
|
+
*
|
|
1712
|
+
* This utility is a safe way to add pending timeouts for the processor because
|
|
1713
|
+
* it will clear the timeout when the processor stops.
|
|
1714
|
+
*/
|
|
1715
|
+
const addPendingTimeout = (
|
|
1716
|
+
common,
|
|
1717
|
+
callback,
|
|
1718
|
+
timeout
|
|
1719
|
+
) => {
|
|
1720
|
+
const timeoutId = setTimeout(() => {
|
|
1721
|
+
common.pendingTimeouts.delete(timeoutId)
|
|
1722
|
+
callback()
|
|
1723
|
+
}, timeout)
|
|
1724
|
+
common.pendingTimeouts.add(timeoutId)
|
|
1725
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { EdgeFreshAddress, EdgeIo, EdgeLog, EdgeTransaction } from 'edge-core-js/types';
|
|
2
3
|
import { EngineEmitter } from '../../plugin/EngineEmitter';
|
|
3
4
|
import { ChangePath, CurrencyFormat, EngineConfig, PluginInfo } from '../../plugin/types';
|
|
@@ -40,6 +41,7 @@ interface CommonParams {
|
|
|
40
41
|
dataLayer: DataLayer;
|
|
41
42
|
emitter: EngineEmitter;
|
|
42
43
|
taskCache: TaskCache;
|
|
44
|
+
pendingTimeouts: Set<NodeJS.Timeout>;
|
|
43
45
|
updateProgressRatio: () => void;
|
|
44
46
|
updateSeenTxCheckpoint: () => void;
|
|
45
47
|
io: EdgeIo;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "edge-currency-plugins",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.7",
|
|
4
4
|
"description": "Edge currency plugins to fetch and process wallet accounts, balances and transactions.",
|
|
5
5
|
"homepage": "https://edge.app/",
|
|
6
6
|
"repository": "https://github.com/EdgeApp/edge-currency-plugins",
|