Skip to content

Commit e7bbfc2

Browse files
authored
Removed polling in favor of using updateRuneUtxoBalances directly (#47)
1 parent c156879 commit e7bbfc2

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@magiceden-oss/runestone-lib",
3-
"version": "0.9.1-alpha",
3+
"version": "0.9.2-alpha",
44
"description": "",
55
"main": "./dist/index.js",
66
"types": "./dist/index.d.ts",

src/indexer/index.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export class RunestoneIndexer {
1111
private readonly _storage: RunestoneStorage;
1212
private readonly _rpc: BitcoinRpcClient;
1313
private readonly _network: Network;
14-
private readonly _pollIntervalMs: number | null;
1514

1615
private _started: boolean = false;
1716
private _updateInProgress: Promise<void> | null = null;
@@ -21,8 +20,6 @@ export class RunestoneIndexer {
2120
this._rpc = options.bitcoinRpcClient;
2221
this._storage = options.storage;
2322
this._network = options.network;
24-
this._pollIntervalMs =
25-
options.pollIntervalMs !== null ? Math.max(options.pollIntervalMs ?? 10000, 0) : null;
2623
}
2724

2825
async start(): Promise<void> {
@@ -34,10 +31,6 @@ export class RunestoneIndexer {
3431

3532
this._started = true;
3633

37-
if (this._pollIntervalMs !== null) {
38-
this._intervalId = setInterval(() => this.updateRuneUtxoBalances(), this._pollIntervalMs);
39-
}
40-
4134
if (this._network === Network.MAINNET) {
4235
this._storage.seedEtchings([
4336
{
@@ -68,6 +61,10 @@ export class RunestoneIndexer {
6861
}
6962

7063
async updateRuneUtxoBalances(): Promise<void> {
64+
if (!this._started) {
65+
throw new Error('Runestone indexer is not started');
66+
}
67+
7168
if (this._updateInProgress) {
7269
return;
7370
}

0 commit comments

Comments
 (0)