1.20.14 • Published 5 months ago

@ocap/indexdb-prune v1.20.14

Weekly downloads
-
License
ISC
Repository
-
Last release
5 months ago

IndexDB Prune Tool

This tool helps identify and remove records from Elasticsearch-based IndexDB that do not exist in the StateDB. The process is now streamlined with an API-based approach for better integration with other systems.

Usage

Programmatic API

You can use the tool programmatically by importing it:

const pruneIndexDB = require('@ocap/tools-indexdb-prune');

async function runPrune() {
  try {
    const deletedRecords = await pruneIndexDB();
    console.log('Pruning completed successfully');
    console.log('Deleted records:', deletedRecords);
    // deletedRecords format: { account: ['id1', 'id2'], tx: ['txid1', 'txid2'] }
  } catch (err) {
    console.error('Pruning failed:', err);
  }
}

runPrune();

Process

The tool now performs these operations in a single flow:

  1. Establishes connections to both IndexDB (Elasticsearch) and StateDB (Dolt)
  2. Scans all tables in IndexDB (tx, account, asset, delegation, token, factory, stake, rollup, rollupBlock)
  3. For each record, verifies if it exists in StateDB
  4. Automatically deletes records that exist in IndexDB but not in StateDB
  5. Returns a map of deleted record IDs by table

Return Value

The function returns an object with tables as keys and arrays of deleted IDs as values:

{
  account: ['accountId1', 'accountId2', ...],
  tx: ['txId1', 'txId2', ...],
  asset: ['assetId1', 'assetId2', ...],
  // other tables...
}
1.20.14

5 months ago

1.20.13

5 months ago

1.20.12

5 months ago

1.20.11

5 months ago

1.20.10

5 months ago

1.20.9

5 months ago

1.20.8

6 months ago

1.20.7

6 months ago