Skip to content

Commit

Permalink
Added reorg flag to RuneUpdater/RuneBlockIndex (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
summraznboi authored Apr 16, 2024
1 parent 669c472 commit fc61296
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@magiceden-oss/runestone-lib",
"version": "0.7.1-alpha",
"version": "0.7.2-alpha",
"description": "",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
3 changes: 2 additions & 1 deletion src/indexer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,9 @@ export class RunestoneIndexer {
throw blockResult.error;
}
const block = blockResult.result;
const reorg = currentStorageBlock ? currentStorageBlock.height >= block.height : false;

const runeUpdater = new RuneUpdater(this._network, block, this._storage, this._rpc);
const runeUpdater = new RuneUpdater(this._network, block, reorg, this._storage, this._rpc);

for (const [txIndex, tx] of block.tx.entries()) {
await runeUpdater.indexRunes(tx, txIndex);
Expand Down
1 change: 1 addition & 0 deletions src/indexer/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export type RuneEtching = ({ valid: false } | ({ valid: true } & RuneEtchingBase

export type RuneBlockIndex = {
block: BlockInfo;
reorg: boolean;
etchings: RuneEtching[];
mintCounts: RuneMintCount[];
utxoBalances: RuneUtxoBalance[];
Expand Down
1 change: 1 addition & 0 deletions src/indexer/updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export class RuneUpdater implements RuneBlockIndex {
constructor(
network: Network,
block: BlockInfo,
readonly reorg: boolean,
private readonly _storage: RunestoneStorage,
private readonly _rpc: BitcoinRpcClient
) {
Expand Down
2 changes: 1 addition & 1 deletion test/updater.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function getDefaultRuneUpdaterContext() {

const rpc = mock<BitcoinRpcClient>();

const runeUpdater = new RuneUpdater(Network.MAINNET, block, storage, rpc);
const runeUpdater = new RuneUpdater(Network.MAINNET, block, false, storage, rpc);

return { runeUpdater, block, storage, rpc };
}
Expand Down

0 comments on commit fc61296

Please sign in to comment.