@metamask-previews/eth-block-tracker 15.0.0-preview-eb60826c → 15.0.0-preview-565dfca2
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.
- package/dist/PollingBlockTracker.cjs +209 -205
- package/dist/PollingBlockTracker.cjs.map +1 -1
- package/dist/PollingBlockTracker.d.cts +33 -0
- package/dist/PollingBlockTracker.d.cts.map +1 -1
- package/dist/PollingBlockTracker.d.mts +33 -0
- package/dist/PollingBlockTracker.d.mts.map +1 -1
- package/dist/PollingBlockTracker.mjs +208 -204
- package/dist/PollingBlockTracker.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -13,6 +13,17 @@ export type PollingBlockTrackerOptions<Context extends ContextConstraint = Middl
|
|
|
13
13
|
};
|
|
14
14
|
export declare class PollingBlockTracker<Context extends ContextConstraint = MiddlewareContext> extends SafeEventEmitter implements BlockTracker {
|
|
15
15
|
#private;
|
|
16
|
+
private _isRunning;
|
|
17
|
+
private readonly _blockResetDuration;
|
|
18
|
+
private readonly _usePastBlocks;
|
|
19
|
+
private _currentBlock;
|
|
20
|
+
private _blockResetTimeout?;
|
|
21
|
+
private _pollingTimeout?;
|
|
22
|
+
private readonly _provider;
|
|
23
|
+
private readonly _pollingInterval;
|
|
24
|
+
private readonly _retryTimeout;
|
|
25
|
+
private readonly _keepEventLoopActive;
|
|
26
|
+
private readonly _setSkipCacheFlag;
|
|
16
27
|
constructor(opts?: PollingBlockTrackerOptions<Context>);
|
|
17
28
|
destroy(): Promise<void>;
|
|
18
29
|
isRunning(): boolean;
|
|
@@ -21,6 +32,18 @@ export declare class PollingBlockTracker<Context extends ContextConstraint = Mid
|
|
|
21
32
|
useCache?: boolean;
|
|
22
33
|
}): Promise<string>;
|
|
23
34
|
removeAllListeners(eventName?: string | symbol): this;
|
|
35
|
+
private _setupInternalEvents;
|
|
36
|
+
private _onNewListener;
|
|
37
|
+
private _onRemoveListener;
|
|
38
|
+
private _maybeStart;
|
|
39
|
+
private _maybeEnd;
|
|
40
|
+
private _getBlockTrackerEventCount;
|
|
41
|
+
private _shouldUseNewBlock;
|
|
42
|
+
private _newPotentialLatest;
|
|
43
|
+
private _setCurrentBlock;
|
|
44
|
+
private _setupBlockResetTimeout;
|
|
45
|
+
private _cancelBlockResetTimeout;
|
|
46
|
+
private _resetCurrentBlock;
|
|
24
47
|
/**
|
|
25
48
|
* Checks for the latest block, updates the internal state, and returns the
|
|
26
49
|
* value immediately rather than waiting for the next polling interval.
|
|
@@ -29,5 +52,15 @@ export declare class PollingBlockTracker<Context extends ContextConstraint = Mid
|
|
|
29
52
|
* @returns A promise that resolves to the latest block number.
|
|
30
53
|
*/
|
|
31
54
|
checkForLatestBlock(): Promise<string>;
|
|
55
|
+
private _start;
|
|
56
|
+
private _end;
|
|
57
|
+
private _updateLatestBlock;
|
|
58
|
+
private _fetchLatestBlock;
|
|
59
|
+
/**
|
|
60
|
+
* The core polling function that runs after each interval.
|
|
61
|
+
* Updates the latest block and then queues the next update.
|
|
62
|
+
*/
|
|
63
|
+
private _updateAndQueue;
|
|
64
|
+
_clearPollingTimeout(): void;
|
|
32
65
|
}
|
|
33
66
|
//# sourceMappingURL=PollingBlockTracker.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PollingBlockTracker.d.cts","sourceRoot":"","sources":["../src/PollingBlockTracker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,wCAAwC;AACxE,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EAClB,qCAAqC;AACtC,OAAO,gBAAgB,qCAAqC;AAK5D,OAAO,KAAK,EAAE,YAAY,EAAE,2BAAuB;AASnD,MAAM,MAAM,0BAA0B,CACpC,OAAO,SAAS,iBAAiB,GAAG,iBAAiB,IACnD;IACF,QAAQ,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACrC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAQF,qBAAa,mBAAmB,CAC5B,OAAO,SAAS,iBAAiB,GAAG,iBAAiB,CAEvD,SAAQ,gBACR,YAAW,YAAY;;
|
|
1
|
+
{"version":3,"file":"PollingBlockTracker.d.cts","sourceRoot":"","sources":["../src/PollingBlockTracker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,wCAAwC;AACxE,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EAClB,qCAAqC;AACtC,OAAO,gBAAgB,qCAAqC;AAK5D,OAAO,KAAK,EAAE,YAAY,EAAE,2BAAuB;AASnD,MAAM,MAAM,0BAA0B,CACpC,OAAO,SAAS,iBAAiB,GAAG,iBAAiB,IACnD;IACF,QAAQ,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACrC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAQF,qBAAa,mBAAmB,CAC5B,OAAO,SAAS,iBAAiB,GAAG,iBAAiB,CAEvD,SAAQ,gBACR,YAAW,YAAY;;IAEvB,OAAO,CAAC,UAAU,CAAU;IAE5B,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAS;IAE7C,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAU;IAEzC,OAAO,CAAC,aAAa,CAAgB;IAErC,OAAO,CAAC,kBAAkB,CAAC,CAAgC;IAE3D,OAAO,CAAC,eAAe,CAAC,CAAgC;IAExD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA4B;IAEtD,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAS;IAE1C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IAEvC,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAU;IAE/C,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAU;gBAQhC,IAAI,GAAE,0BAA0B,CAAC,OAAO,CAAM;IAgCpD,OAAO;IAMb,SAAS,IAAI,OAAO;IAIpB,eAAe,IAAI,MAAM,GAAG,IAAI;IAI1B,cAAc,CAAC,EACnB,QAAe,GAChB,GAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAO,GAAG,OAAO,CAAC,MAAM,CAAC;IAuDhD,kBAAkB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM;IAgB9C,OAAO,CAAC,oBAAoB;IAS5B,OAAO,CAAC,cAAc;IAQtB,OAAO,CAAC,iBAAiB;IAQzB,OAAO,CAAC,WAAW;IAYnB,OAAO,CAAC,SAAS;IAYjB,OAAO,CAAC,0BAA0B;IAclC,OAAO,CAAC,kBAAkB;IAc1B,OAAO,CAAC,mBAAmB;IAO3B,OAAO,CAAC,gBAAgB;IAOxB,OAAO,CAAC,uBAAuB;IAe/B,OAAO,CAAC,wBAAwB;IAMhC,OAAO,CAAC,kBAAkB;IAI1B;;;;;;OAMG;IACG,mBAAmB;IAKzB,OAAO,CAAC,MAAM;IAMd,OAAO,CAAC,IAAI;YAIE,kBAAkB;YAelB,iBAAiB;IAsC/B;;;OAGG;YACW,eAAe;IAoC7B,oBAAoB;CAsBrB"}
|
|
@@ -13,6 +13,17 @@ export type PollingBlockTrackerOptions<Context extends ContextConstraint = Middl
|
|
|
13
13
|
};
|
|
14
14
|
export declare class PollingBlockTracker<Context extends ContextConstraint = MiddlewareContext> extends SafeEventEmitter implements BlockTracker {
|
|
15
15
|
#private;
|
|
16
|
+
private _isRunning;
|
|
17
|
+
private readonly _blockResetDuration;
|
|
18
|
+
private readonly _usePastBlocks;
|
|
19
|
+
private _currentBlock;
|
|
20
|
+
private _blockResetTimeout?;
|
|
21
|
+
private _pollingTimeout?;
|
|
22
|
+
private readonly _provider;
|
|
23
|
+
private readonly _pollingInterval;
|
|
24
|
+
private readonly _retryTimeout;
|
|
25
|
+
private readonly _keepEventLoopActive;
|
|
26
|
+
private readonly _setSkipCacheFlag;
|
|
16
27
|
constructor(opts?: PollingBlockTrackerOptions<Context>);
|
|
17
28
|
destroy(): Promise<void>;
|
|
18
29
|
isRunning(): boolean;
|
|
@@ -21,6 +32,18 @@ export declare class PollingBlockTracker<Context extends ContextConstraint = Mid
|
|
|
21
32
|
useCache?: boolean;
|
|
22
33
|
}): Promise<string>;
|
|
23
34
|
removeAllListeners(eventName?: string | symbol): this;
|
|
35
|
+
private _setupInternalEvents;
|
|
36
|
+
private _onNewListener;
|
|
37
|
+
private _onRemoveListener;
|
|
38
|
+
private _maybeStart;
|
|
39
|
+
private _maybeEnd;
|
|
40
|
+
private _getBlockTrackerEventCount;
|
|
41
|
+
private _shouldUseNewBlock;
|
|
42
|
+
private _newPotentialLatest;
|
|
43
|
+
private _setCurrentBlock;
|
|
44
|
+
private _setupBlockResetTimeout;
|
|
45
|
+
private _cancelBlockResetTimeout;
|
|
46
|
+
private _resetCurrentBlock;
|
|
24
47
|
/**
|
|
25
48
|
* Checks for the latest block, updates the internal state, and returns the
|
|
26
49
|
* value immediately rather than waiting for the next polling interval.
|
|
@@ -29,5 +52,15 @@ export declare class PollingBlockTracker<Context extends ContextConstraint = Mid
|
|
|
29
52
|
* @returns A promise that resolves to the latest block number.
|
|
30
53
|
*/
|
|
31
54
|
checkForLatestBlock(): Promise<string>;
|
|
55
|
+
private _start;
|
|
56
|
+
private _end;
|
|
57
|
+
private _updateLatestBlock;
|
|
58
|
+
private _fetchLatestBlock;
|
|
59
|
+
/**
|
|
60
|
+
* The core polling function that runs after each interval.
|
|
61
|
+
* Updates the latest block and then queues the next update.
|
|
62
|
+
*/
|
|
63
|
+
private _updateAndQueue;
|
|
64
|
+
_clearPollingTimeout(): void;
|
|
32
65
|
}
|
|
33
66
|
//# sourceMappingURL=PollingBlockTracker.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PollingBlockTracker.d.mts","sourceRoot":"","sources":["../src/PollingBlockTracker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,wCAAwC;AACxE,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EAClB,qCAAqC;AACtC,OAAO,gBAAgB,qCAAqC;AAK5D,OAAO,KAAK,EAAE,YAAY,EAAE,2BAAuB;AASnD,MAAM,MAAM,0BAA0B,CACpC,OAAO,SAAS,iBAAiB,GAAG,iBAAiB,IACnD;IACF,QAAQ,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACrC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAQF,qBAAa,mBAAmB,CAC5B,OAAO,SAAS,iBAAiB,GAAG,iBAAiB,CAEvD,SAAQ,gBACR,YAAW,YAAY;;
|
|
1
|
+
{"version":3,"file":"PollingBlockTracker.d.mts","sourceRoot":"","sources":["../src/PollingBlockTracker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,wCAAwC;AACxE,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EAClB,qCAAqC;AACtC,OAAO,gBAAgB,qCAAqC;AAK5D,OAAO,KAAK,EAAE,YAAY,EAAE,2BAAuB;AASnD,MAAM,MAAM,0BAA0B,CACpC,OAAO,SAAS,iBAAiB,GAAG,iBAAiB,IACnD;IACF,QAAQ,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACrC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAQF,qBAAa,mBAAmB,CAC5B,OAAO,SAAS,iBAAiB,GAAG,iBAAiB,CAEvD,SAAQ,gBACR,YAAW,YAAY;;IAEvB,OAAO,CAAC,UAAU,CAAU;IAE5B,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAS;IAE7C,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAU;IAEzC,OAAO,CAAC,aAAa,CAAgB;IAErC,OAAO,CAAC,kBAAkB,CAAC,CAAgC;IAE3D,OAAO,CAAC,eAAe,CAAC,CAAgC;IAExD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA4B;IAEtD,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAS;IAE1C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IAEvC,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAU;IAE/C,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAU;gBAQhC,IAAI,GAAE,0BAA0B,CAAC,OAAO,CAAM;IAgCpD,OAAO;IAMb,SAAS,IAAI,OAAO;IAIpB,eAAe,IAAI,MAAM,GAAG,IAAI;IAI1B,cAAc,CAAC,EACnB,QAAe,GAChB,GAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAO,GAAG,OAAO,CAAC,MAAM,CAAC;IAuDhD,kBAAkB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM;IAgB9C,OAAO,CAAC,oBAAoB;IAS5B,OAAO,CAAC,cAAc;IAQtB,OAAO,CAAC,iBAAiB;IAQzB,OAAO,CAAC,WAAW;IAYnB,OAAO,CAAC,SAAS;IAYjB,OAAO,CAAC,0BAA0B;IAclC,OAAO,CAAC,kBAAkB;IAc1B,OAAO,CAAC,mBAAmB;IAO3B,OAAO,CAAC,gBAAgB;IAOxB,OAAO,CAAC,uBAAuB;IAe/B,OAAO,CAAC,wBAAwB;IAMhC,OAAO,CAAC,kBAAkB;IAI1B;;;;;;OAMG;IACG,mBAAmB;IAKzB,OAAO,CAAC,MAAM;IAMd,OAAO,CAAC,IAAI;YAIE,kBAAkB;YAelB,iBAAiB;IAsC/B;;;OAGG;YACW,eAAe;IAoC7B,oBAAoB;CAsBrB"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
+
};
|
|
1
6
|
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
7
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
8
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
10
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
11
|
};
|
|
7
|
-
var
|
|
8
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
-
};
|
|
12
|
-
var _PollingBlockTracker_instances, _PollingBlockTracker_isRunning, _PollingBlockTracker_blockResetDuration, _PollingBlockTracker_usePastBlocks, _PollingBlockTracker_currentBlock, _PollingBlockTracker_blockResetTimeout, _PollingBlockTracker_pollingTimeout, _PollingBlockTracker_provider, _PollingBlockTracker_pollingInterval, _PollingBlockTracker_retryTimeout, _PollingBlockTracker_keepEventLoopActive, _PollingBlockTracker_setSkipCacheFlag, _PollingBlockTracker_internalEventListeners, _PollingBlockTracker_pendingLatestBlock, _PollingBlockTracker_pendingFetch, _PollingBlockTracker_onNewListener, _PollingBlockTracker_onRemoveListener, _PollingBlockTracker_resetCurrentBlock, _PollingBlockTracker_setupInternalEvents, _PollingBlockTracker_onNewListenerUnbound, _PollingBlockTracker_onRemoveListenerUnbound, _PollingBlockTracker_maybeStart, _PollingBlockTracker_maybeEnd, _PollingBlockTracker_getBlockTrackerEventCount, _PollingBlockTracker_shouldUseNewBlock, _PollingBlockTracker_newPotentialLatest, _PollingBlockTracker_setCurrentBlock, _PollingBlockTracker_setupBlockResetTimeout, _PollingBlockTracker_cancelBlockResetTimeout, _PollingBlockTracker_resetCurrentBlockUnbound, _PollingBlockTracker_start, _PollingBlockTracker_end, _PollingBlockTracker_updateLatestBlock, _PollingBlockTracker_fetchLatestBlock, _PollingBlockTracker_updateAndQueue, _PollingBlockTracker_clearPollingTimeout, _PollingBlockTracker_addInternalListener, _PollingBlockTracker_removeInternalListener, _PollingBlockTracker_rejectPendingLatestBlock;
|
|
12
|
+
var _PollingBlockTracker_instances, _PollingBlockTracker_internalEventListeners, _PollingBlockTracker_pendingLatestBlock, _PollingBlockTracker_pendingFetch, _PollingBlockTracker_addInternalListener, _PollingBlockTracker_removeInternalListener, _PollingBlockTracker_rejectPendingLatestBlock;
|
|
13
13
|
function $importDefault(module) {
|
|
14
14
|
if (module?.__esModule) {
|
|
15
15
|
return module.default;
|
|
@@ -33,57 +33,44 @@ export class PollingBlockTracker extends SafeEventEmitter {
|
|
|
33
33
|
}
|
|
34
34
|
super();
|
|
35
35
|
_PollingBlockTracker_instances.add(this);
|
|
36
|
-
_PollingBlockTracker_isRunning.set(this, void 0);
|
|
37
|
-
_PollingBlockTracker_blockResetDuration.set(this, void 0);
|
|
38
|
-
_PollingBlockTracker_usePastBlocks.set(this, void 0);
|
|
39
|
-
_PollingBlockTracker_currentBlock.set(this, void 0);
|
|
40
|
-
_PollingBlockTracker_blockResetTimeout.set(this, void 0);
|
|
41
|
-
_PollingBlockTracker_pollingTimeout.set(this, void 0);
|
|
42
|
-
_PollingBlockTracker_provider.set(this, void 0);
|
|
43
|
-
_PollingBlockTracker_pollingInterval.set(this, void 0);
|
|
44
|
-
_PollingBlockTracker_retryTimeout.set(this, void 0);
|
|
45
|
-
_PollingBlockTracker_keepEventLoopActive.set(this, void 0);
|
|
46
|
-
_PollingBlockTracker_setSkipCacheFlag.set(this, void 0);
|
|
47
36
|
_PollingBlockTracker_internalEventListeners.set(this, []);
|
|
48
37
|
_PollingBlockTracker_pendingLatestBlock.set(this, void 0);
|
|
49
38
|
_PollingBlockTracker_pendingFetch.set(this, void 0);
|
|
50
|
-
_PollingBlockTracker_onNewListener.set(this, void 0);
|
|
51
|
-
_PollingBlockTracker_onRemoveListener.set(this, void 0);
|
|
52
|
-
_PollingBlockTracker_resetCurrentBlock.set(this, void 0);
|
|
53
39
|
// config
|
|
54
|
-
|
|
55
|
-
|
|
40
|
+
this._blockResetDuration = opts.blockResetDuration || 20 * sec;
|
|
41
|
+
this._usePastBlocks = opts.usePastBlocks || false;
|
|
56
42
|
// state
|
|
57
|
-
|
|
58
|
-
|
|
43
|
+
this._currentBlock = null;
|
|
44
|
+
this._isRunning = false;
|
|
59
45
|
// bind functions for internal use
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
46
|
+
this._onNewListener = this._onNewListener.bind(this);
|
|
47
|
+
this._onRemoveListener = this._onRemoveListener.bind(this);
|
|
48
|
+
this._resetCurrentBlock = this._resetCurrentBlock.bind(this);
|
|
63
49
|
// listen for handler changes
|
|
64
|
-
|
|
50
|
+
this._setupInternalEvents();
|
|
65
51
|
// config
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
52
|
+
this._provider = opts.provider;
|
|
53
|
+
this._pollingInterval = opts.pollingInterval || 20 * sec;
|
|
54
|
+
this._retryTimeout = opts.retryTimeout || this._pollingInterval / 10;
|
|
55
|
+
this._keepEventLoopActive =
|
|
56
|
+
opts.keepEventLoopActive === undefined ? true : opts.keepEventLoopActive;
|
|
57
|
+
this._setSkipCacheFlag = opts.setSkipCacheFlag || false;
|
|
71
58
|
}
|
|
72
59
|
async destroy() {
|
|
73
|
-
|
|
60
|
+
this._cancelBlockResetTimeout();
|
|
74
61
|
super.removeAllListeners();
|
|
75
|
-
|
|
62
|
+
this._maybeEnd();
|
|
76
63
|
}
|
|
77
64
|
isRunning() {
|
|
78
|
-
return
|
|
65
|
+
return this._isRunning;
|
|
79
66
|
}
|
|
80
67
|
getCurrentBlock() {
|
|
81
|
-
return
|
|
68
|
+
return this._currentBlock;
|
|
82
69
|
}
|
|
83
70
|
async getLatestBlock({ useCache = true, } = {}) {
|
|
84
71
|
// return if available
|
|
85
|
-
if (
|
|
86
|
-
return
|
|
72
|
+
if (this._currentBlock && useCache) {
|
|
73
|
+
return this._currentBlock;
|
|
87
74
|
}
|
|
88
75
|
if (__classPrivateFieldGet(this, _PollingBlockTracker_pendingLatestBlock, "f")) {
|
|
89
76
|
return await __classPrivateFieldGet(this, _PollingBlockTracker_pendingLatestBlock, "f").promise;
|
|
@@ -92,7 +79,7 @@ export class PollingBlockTracker extends SafeEventEmitter {
|
|
|
92
79
|
suppressUnhandledRejection: true,
|
|
93
80
|
});
|
|
94
81
|
__classPrivateFieldSet(this, _PollingBlockTracker_pendingLatestBlock, { reject, promise }, "f");
|
|
95
|
-
if (
|
|
82
|
+
if (this._isRunning) {
|
|
96
83
|
try {
|
|
97
84
|
// If tracker is running, wait for next block with timeout
|
|
98
85
|
const onLatestBlock = (value) => {
|
|
@@ -115,7 +102,7 @@ export class PollingBlockTracker extends SafeEventEmitter {
|
|
|
115
102
|
else {
|
|
116
103
|
// If tracker isn't running, just fetch directly
|
|
117
104
|
try {
|
|
118
|
-
const latestBlock = await
|
|
105
|
+
const latestBlock = await this._updateLatestBlock();
|
|
119
106
|
resolve(latestBlock);
|
|
120
107
|
return latestBlock;
|
|
121
108
|
}
|
|
@@ -129,11 +116,11 @@ export class PollingBlockTracker extends SafeEventEmitter {
|
|
|
129
116
|
// achieve this by delaying the unsetting of the #pendingLatestBlock promise.
|
|
130
117
|
setTimeout(() => {
|
|
131
118
|
__classPrivateFieldSet(this, _PollingBlockTracker_pendingLatestBlock, undefined, "f");
|
|
132
|
-
},
|
|
119
|
+
}, this._pollingInterval);
|
|
133
120
|
}
|
|
134
121
|
}
|
|
135
122
|
}
|
|
136
|
-
//
|
|
123
|
+
// dont allow module consumer to remove our internal event listeners
|
|
137
124
|
removeAllListeners(eventName) {
|
|
138
125
|
// perform default behavior, preserve fn arity
|
|
139
126
|
if (eventName) {
|
|
@@ -143,191 +130,208 @@ export class PollingBlockTracker extends SafeEventEmitter {
|
|
|
143
130
|
super.removeAllListeners();
|
|
144
131
|
}
|
|
145
132
|
// re-add internal events
|
|
146
|
-
|
|
133
|
+
this._setupInternalEvents();
|
|
147
134
|
// trigger stop check just in case
|
|
148
|
-
|
|
135
|
+
this._onRemoveListener();
|
|
149
136
|
return this;
|
|
150
137
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
async checkForLatestBlock() {
|
|
159
|
-
await __classPrivateFieldGet(this, _PollingBlockTracker_instances, "m", _PollingBlockTracker_updateLatestBlock).call(this);
|
|
160
|
-
return await this.getLatestBlock();
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
_PollingBlockTracker_isRunning = new WeakMap(), _PollingBlockTracker_blockResetDuration = new WeakMap(), _PollingBlockTracker_usePastBlocks = new WeakMap(), _PollingBlockTracker_currentBlock = new WeakMap(), _PollingBlockTracker_blockResetTimeout = new WeakMap(), _PollingBlockTracker_pollingTimeout = new WeakMap(), _PollingBlockTracker_provider = new WeakMap(), _PollingBlockTracker_pollingInterval = new WeakMap(), _PollingBlockTracker_retryTimeout = new WeakMap(), _PollingBlockTracker_keepEventLoopActive = new WeakMap(), _PollingBlockTracker_setSkipCacheFlag = new WeakMap(), _PollingBlockTracker_internalEventListeners = new WeakMap(), _PollingBlockTracker_pendingLatestBlock = new WeakMap(), _PollingBlockTracker_pendingFetch = new WeakMap(), _PollingBlockTracker_onNewListener = new WeakMap(), _PollingBlockTracker_onRemoveListener = new WeakMap(), _PollingBlockTracker_resetCurrentBlock = new WeakMap(), _PollingBlockTracker_instances = new WeakSet(), _PollingBlockTracker_setupInternalEvents = function _PollingBlockTracker_setupInternalEvents() {
|
|
164
|
-
// first remove listeners for idempotence
|
|
165
|
-
this.removeListener('newListener', __classPrivateFieldGet(this, _PollingBlockTracker_onNewListener, "f"));
|
|
166
|
-
this.removeListener('removeListener', __classPrivateFieldGet(this, _PollingBlockTracker_onRemoveListener, "f"));
|
|
167
|
-
// then add them
|
|
168
|
-
this.on('newListener', __classPrivateFieldGet(this, _PollingBlockTracker_onNewListener, "f"));
|
|
169
|
-
this.on('removeListener', __classPrivateFieldGet(this, _PollingBlockTracker_onRemoveListener, "f"));
|
|
170
|
-
}, _PollingBlockTracker_onNewListenerUnbound = function _PollingBlockTracker_onNewListenerUnbound(eventName) {
|
|
171
|
-
// `newListener` is called *before* the listener is added
|
|
172
|
-
if (blockTrackerEvents.includes(eventName)) {
|
|
173
|
-
// TODO: Handle dangling promise
|
|
174
|
-
__classPrivateFieldGet(this, _PollingBlockTracker_instances, "m", _PollingBlockTracker_maybeStart).call(this);
|
|
138
|
+
_setupInternalEvents() {
|
|
139
|
+
// first remove listeners for idempotence
|
|
140
|
+
this.removeListener('newListener', this._onNewListener);
|
|
141
|
+
this.removeListener('removeListener', this._onRemoveListener);
|
|
142
|
+
// then add them
|
|
143
|
+
this.on('newListener', this._onNewListener);
|
|
144
|
+
this.on('removeListener', this._onRemoveListener);
|
|
175
145
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
146
|
+
_onNewListener(eventName) {
|
|
147
|
+
// `newListener` is called *before* the listener is added
|
|
148
|
+
if (blockTrackerEvents.includes(eventName)) {
|
|
149
|
+
// TODO: Handle dangling promise
|
|
150
|
+
this._maybeStart();
|
|
151
|
+
}
|
|
180
152
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
153
|
+
_onRemoveListener() {
|
|
154
|
+
// `removeListener` is called *after* the listener is removed
|
|
155
|
+
if (this._getBlockTrackerEventCount() > 0) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
this._maybeEnd();
|
|
185
159
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
160
|
+
_maybeStart() {
|
|
161
|
+
if (this._isRunning) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
this._isRunning = true;
|
|
165
|
+
// cancel setting latest block to stale
|
|
166
|
+
this._cancelBlockResetTimeout();
|
|
167
|
+
this._start();
|
|
168
|
+
this.emit('_started');
|
|
194
169
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
.
|
|
203
|
-
.
|
|
204
|
-
// internal listeners are not included in the count
|
|
205
|
-
.filter((listener) => __classPrivateFieldGet(this, _PollingBlockTracker_internalEventListeners, "f").every((internalListener) => !Object.is(internalListener, listener))).length);
|
|
206
|
-
}, _PollingBlockTracker_shouldUseNewBlock = function _PollingBlockTracker_shouldUseNewBlock(newBlock) {
|
|
207
|
-
const currentBlock = __classPrivateFieldGet(this, _PollingBlockTracker_currentBlock, "f");
|
|
208
|
-
if (!currentBlock) {
|
|
209
|
-
return true;
|
|
170
|
+
_maybeEnd() {
|
|
171
|
+
if (!this._isRunning) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
this._isRunning = false;
|
|
175
|
+
this._setupBlockResetTimeout();
|
|
176
|
+
this._end();
|
|
177
|
+
__classPrivateFieldGet(this, _PollingBlockTracker_instances, "m", _PollingBlockTracker_rejectPendingLatestBlock).call(this, new Error('Block tracker destroyed'));
|
|
178
|
+
this.emit('_ended');
|
|
210
179
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
return;
|
|
180
|
+
_getBlockTrackerEventCount() {
|
|
181
|
+
return (blockTrackerEvents
|
|
182
|
+
.map((eventName) => this.listeners(eventName))
|
|
183
|
+
.flat()
|
|
184
|
+
// internal listeners are not included in the count
|
|
185
|
+
.filter((listener) => __classPrivateFieldGet(this, _PollingBlockTracker_internalEventListeners, "f").every((internalListener) => !Object.is(internalListener, listener))).length);
|
|
218
186
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
// clear latest block when stale
|
|
229
|
-
__classPrivateFieldSet(this, _PollingBlockTracker_blockResetTimeout, setTimeout(__classPrivateFieldGet(this, _PollingBlockTracker_resetCurrentBlock, "f"), __classPrivateFieldGet(this, _PollingBlockTracker_blockResetDuration, "f")), "f");
|
|
230
|
-
// nodejs - dont hold process open
|
|
231
|
-
if (__classPrivateFieldGet(this, _PollingBlockTracker_blockResetTimeout, "f").unref) {
|
|
232
|
-
__classPrivateFieldGet(this, _PollingBlockTracker_blockResetTimeout, "f").unref();
|
|
187
|
+
_shouldUseNewBlock(newBlock) {
|
|
188
|
+
const currentBlock = this._currentBlock;
|
|
189
|
+
if (!currentBlock) {
|
|
190
|
+
return true;
|
|
191
|
+
}
|
|
192
|
+
const newBlockInt = hexToInt(newBlock);
|
|
193
|
+
const currentBlockInt = hexToInt(currentBlock);
|
|
194
|
+
return ((this._usePastBlocks && newBlockInt < currentBlockInt) ||
|
|
195
|
+
newBlockInt > currentBlockInt);
|
|
233
196
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
197
|
+
_newPotentialLatest(newBlock) {
|
|
198
|
+
if (!this._shouldUseNewBlock(newBlock)) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
this._setCurrentBlock(newBlock);
|
|
237
202
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
__classPrivateFieldGet(this, _PollingBlockTracker_instances, "m", _PollingBlockTracker_updateAndQueue).call(this);
|
|
244
|
-
}, _PollingBlockTracker_end = function _PollingBlockTracker_end() {
|
|
245
|
-
__classPrivateFieldGet(this, _PollingBlockTracker_instances, "m", _PollingBlockTracker_clearPollingTimeout).call(this);
|
|
246
|
-
}, _PollingBlockTracker_updateLatestBlock = async function _PollingBlockTracker_updateLatestBlock() {
|
|
247
|
-
// fetch + set latest block
|
|
248
|
-
const latestBlock = await __classPrivateFieldGet(this, _PollingBlockTracker_instances, "m", _PollingBlockTracker_fetchLatestBlock).call(this);
|
|
249
|
-
__classPrivateFieldGet(this, _PollingBlockTracker_instances, "m", _PollingBlockTracker_newPotentialLatest).call(this, latestBlock);
|
|
250
|
-
if (!__classPrivateFieldGet(this, _PollingBlockTracker_isRunning, "f")) {
|
|
251
|
-
// Ensure the one-time update is eventually reset once it's stale
|
|
252
|
-
__classPrivateFieldGet(this, _PollingBlockTracker_instances, "m", _PollingBlockTracker_setupBlockResetTimeout).call(this);
|
|
203
|
+
_setCurrentBlock(newBlock) {
|
|
204
|
+
const oldBlock = this._currentBlock;
|
|
205
|
+
this._currentBlock = newBlock;
|
|
206
|
+
this.emit('latest', newBlock);
|
|
207
|
+
this.emit('sync', { oldBlock, newBlock });
|
|
253
208
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
209
|
+
_setupBlockResetTimeout() {
|
|
210
|
+
// clear any existing timeout
|
|
211
|
+
this._cancelBlockResetTimeout();
|
|
212
|
+
// clear latest block when stale
|
|
213
|
+
this._blockResetTimeout = setTimeout(this._resetCurrentBlock, this._blockResetDuration);
|
|
214
|
+
// nodejs - dont hold process open
|
|
215
|
+
if (this._blockResetTimeout.unref) {
|
|
216
|
+
this._blockResetTimeout.unref();
|
|
217
|
+
}
|
|
261
218
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
});
|
|
266
|
-
__classPrivateFieldSet(this, _PollingBlockTracker_pendingFetch, { reject, promise }, "f");
|
|
267
|
-
try {
|
|
268
|
-
const req = {
|
|
269
|
-
jsonrpc: '2.0',
|
|
270
|
-
id: createRandomId(),
|
|
271
|
-
method: 'eth_blockNumber',
|
|
272
|
-
params: [],
|
|
273
|
-
};
|
|
274
|
-
if (__classPrivateFieldGet(this, _PollingBlockTracker_setSkipCacheFlag, "f")) {
|
|
275
|
-
req.skipCache = true;
|
|
219
|
+
_cancelBlockResetTimeout() {
|
|
220
|
+
if (this._blockResetTimeout) {
|
|
221
|
+
clearTimeout(this._blockResetTimeout);
|
|
276
222
|
}
|
|
277
|
-
log('Making request', req);
|
|
278
|
-
const result = await __classPrivateFieldGet(this, _PollingBlockTracker_provider, "f").request(req);
|
|
279
|
-
log('Got result', result);
|
|
280
|
-
resolve(result);
|
|
281
|
-
return result;
|
|
282
223
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
reject(error);
|
|
286
|
-
__classPrivateFieldGet(this, _PollingBlockTracker_instances, "m", _PollingBlockTracker_rejectPendingLatestBlock).call(this, error);
|
|
287
|
-
throw error;
|
|
224
|
+
_resetCurrentBlock() {
|
|
225
|
+
this._currentBlock = null;
|
|
288
226
|
}
|
|
289
|
-
|
|
290
|
-
|
|
227
|
+
/**
|
|
228
|
+
* Checks for the latest block, updates the internal state, and returns the
|
|
229
|
+
* value immediately rather than waiting for the next polling interval.
|
|
230
|
+
*
|
|
231
|
+
* @deprecated Use {@link getLatestBlock} instead.
|
|
232
|
+
* @returns A promise that resolves to the latest block number.
|
|
233
|
+
*/
|
|
234
|
+
async checkForLatestBlock() {
|
|
235
|
+
await this._updateLatestBlock();
|
|
236
|
+
return await this.getLatestBlock();
|
|
291
237
|
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
*/
|
|
297
|
-
async function _PollingBlockTracker_updateAndQueue() {
|
|
298
|
-
let interval = __classPrivateFieldGet(this, _PollingBlockTracker_pollingInterval, "f");
|
|
299
|
-
try {
|
|
300
|
-
await __classPrivateFieldGet(this, _PollingBlockTracker_instances, "m", _PollingBlockTracker_updateLatestBlock).call(this);
|
|
238
|
+
_start() {
|
|
239
|
+
// Intentionally not awaited as this starts the polling via a timeout chain.
|
|
240
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
241
|
+
this._updateAndQueue();
|
|
301
242
|
}
|
|
302
|
-
|
|
243
|
+
_end() {
|
|
244
|
+
this._clearPollingTimeout();
|
|
245
|
+
}
|
|
246
|
+
async _updateLatestBlock() {
|
|
247
|
+
// fetch + set latest block
|
|
248
|
+
const latestBlock = await this._fetchLatestBlock();
|
|
249
|
+
this._newPotentialLatest(latestBlock);
|
|
250
|
+
if (!this._isRunning) {
|
|
251
|
+
// Ensure the one-time update is eventually reset once it's stale
|
|
252
|
+
this._setupBlockResetTimeout();
|
|
253
|
+
}
|
|
254
|
+
// _newPotentialLatest() ensures that this._currentBlock is not null
|
|
255
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
256
|
+
return this._currentBlock;
|
|
257
|
+
}
|
|
258
|
+
async _fetchLatestBlock() {
|
|
259
|
+
// If there's already a pending fetch, reuse it
|
|
260
|
+
if (__classPrivateFieldGet(this, _PollingBlockTracker_pendingFetch, "f")) {
|
|
261
|
+
return await __classPrivateFieldGet(this, _PollingBlockTracker_pendingFetch, "f").promise;
|
|
262
|
+
}
|
|
263
|
+
// Create a new deferred promise for this request
|
|
264
|
+
const { promise, resolve, reject } = createDeferredPromise({
|
|
265
|
+
suppressUnhandledRejection: true,
|
|
266
|
+
});
|
|
267
|
+
__classPrivateFieldSet(this, _PollingBlockTracker_pendingFetch, { reject, promise }, "f");
|
|
303
268
|
try {
|
|
304
|
-
|
|
269
|
+
const req = {
|
|
270
|
+
jsonrpc: '2.0',
|
|
271
|
+
id: createRandomId(),
|
|
272
|
+
method: 'eth_blockNumber',
|
|
273
|
+
params: [],
|
|
274
|
+
};
|
|
275
|
+
if (this._setSkipCacheFlag) {
|
|
276
|
+
req.skipCache = true;
|
|
277
|
+
}
|
|
278
|
+
log('Making request', req);
|
|
279
|
+
const result = await this._provider.request(req);
|
|
280
|
+
log('Got result', result);
|
|
281
|
+
resolve(result);
|
|
282
|
+
return result;
|
|
305
283
|
}
|
|
306
|
-
catch {
|
|
307
|
-
|
|
284
|
+
catch (error) {
|
|
285
|
+
log('Encountered error fetching block', getErrorMessage(error));
|
|
286
|
+
reject(error);
|
|
287
|
+
__classPrivateFieldGet(this, _PollingBlockTracker_instances, "m", _PollingBlockTracker_rejectPendingLatestBlock).call(this, error);
|
|
288
|
+
throw error;
|
|
289
|
+
}
|
|
290
|
+
finally {
|
|
291
|
+
__classPrivateFieldSet(this, _PollingBlockTracker_pendingFetch, undefined, "f");
|
|
308
292
|
}
|
|
309
|
-
interval = __classPrivateFieldGet(this, _PollingBlockTracker_retryTimeout, "f");
|
|
310
|
-
}
|
|
311
|
-
if (!__classPrivateFieldGet(this, _PollingBlockTracker_isRunning, "f")) {
|
|
312
|
-
return;
|
|
313
293
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
294
|
+
/**
|
|
295
|
+
* The core polling function that runs after each interval.
|
|
296
|
+
* Updates the latest block and then queues the next update.
|
|
297
|
+
*/
|
|
298
|
+
async _updateAndQueue() {
|
|
299
|
+
let interval = this._pollingInterval;
|
|
300
|
+
try {
|
|
301
|
+
await this._updateLatestBlock();
|
|
302
|
+
}
|
|
303
|
+
catch (error) {
|
|
304
|
+
try {
|
|
305
|
+
this.emit('error', error);
|
|
306
|
+
}
|
|
307
|
+
catch {
|
|
308
|
+
console.error(`Error updating latest block: ${getErrorMessage(error)}`);
|
|
309
|
+
}
|
|
310
|
+
interval = this._retryTimeout;
|
|
311
|
+
}
|
|
312
|
+
if (!this._isRunning) {
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
this._clearPollingTimeout();
|
|
316
|
+
const timeoutRef = setTimeout(() => {
|
|
317
|
+
// Intentionally not awaited as this just continues the polling loop.
|
|
318
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
319
|
+
this._updateAndQueue();
|
|
320
|
+
}, interval);
|
|
321
|
+
if (timeoutRef.unref && !this._keepEventLoopActive) {
|
|
322
|
+
timeoutRef.unref();
|
|
323
|
+
}
|
|
324
|
+
this._pollingTimeout = timeoutRef;
|
|
325
|
+
this.emit('_waitingForNextIteration');
|
|
322
326
|
}
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
__classPrivateFieldSet(this, _PollingBlockTracker_pollingTimeout, undefined, "f");
|
|
327
|
+
_clearPollingTimeout() {
|
|
328
|
+
if (this._pollingTimeout) {
|
|
329
|
+
clearTimeout(this._pollingTimeout);
|
|
330
|
+
this._pollingTimeout = undefined;
|
|
331
|
+
}
|
|
329
332
|
}
|
|
330
|
-
}
|
|
333
|
+
}
|
|
334
|
+
_PollingBlockTracker_internalEventListeners = new WeakMap(), _PollingBlockTracker_pendingLatestBlock = new WeakMap(), _PollingBlockTracker_pendingFetch = new WeakMap(), _PollingBlockTracker_instances = new WeakSet(), _PollingBlockTracker_addInternalListener = function _PollingBlockTracker_addInternalListener(listener) {
|
|
331
335
|
__classPrivateFieldGet(this, _PollingBlockTracker_internalEventListeners, "f").push(listener);
|
|
332
336
|
}, _PollingBlockTracker_removeInternalListener = function _PollingBlockTracker_removeInternalListener(listener) {
|
|
333
337
|
__classPrivateFieldGet(this, _PollingBlockTracker_internalEventListeners, "f").splice(__classPrivateFieldGet(this, _PollingBlockTracker_internalEventListeners, "f").indexOf(listener), 1);
|