From b50777801357581480a358f77433888fb772704b Mon Sep 17 00:00:00 2001 From: Robert Wei Date: Wed, 24 Apr 2024 20:54:14 -0400 Subject: [PATCH 1/2] Reverse blockhash to index in reorg --- package.json | 2 +- src/indexer/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 6441ad0..c32756d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@magiceden-oss/runestone-lib", - "version": "1.0.1", + "version": "1.0.2", "description": "", "main": "./dist/index.js", "types": "./dist/index.d.ts", diff --git a/src/indexer/index.ts b/src/indexer/index.ts index 507b783..01a1e4e 100644 --- a/src/indexer/index.ts +++ b/src/indexer/index.ts @@ -90,7 +90,7 @@ export class RunestoneIndexer { } // process blocks that are reorgs - for (const blockhash of reorgBlockhashesToIndex) { + for (const blockhash of reorgBlockhashesToIndex.toReversed()) { const blockResult = await this._rpc.getblock({ blockhash, verbosity: 2 }); if (blockResult.error !== null) { throw blockResult.error; From 9c88383860f5629a860159de80ccba0acf09bf48 Mon Sep 17 00:00:00 2001 From: Robert Wei Date: Wed, 24 Apr 2024 21:40:24 -0400 Subject: [PATCH 2/2] Use inplace reverse --- src/indexer/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/indexer/index.ts b/src/indexer/index.ts index 01a1e4e..f18d595 100644 --- a/src/indexer/index.ts +++ b/src/indexer/index.ts @@ -88,9 +88,10 @@ export class RunestoneIndexer { blockhash = (await this._rpc.getblockhash({ height: blockheight })).result; storageBlockHash = await this._storage.getBlockhash(blockheight); } + reorgBlockhashesToIndex.reverse(); // process blocks that are reorgs - for (const blockhash of reorgBlockhashesToIndex.toReversed()) { + for (const blockhash of reorgBlockhashesToIndex) { const blockResult = await this._rpc.getblock({ blockhash, verbosity: 2 }); if (blockResult.error !== null) { throw blockResult.error;