mirror of
https://github.com/alexgo-io/stacks-blockchain-api.git
synced 2026-01-12 22:43:34 +08:00
feat: add indexes for index_block_hash on BNS tables (#1304)
* feat: add bns indexes for index_block_hash * fix: go back to default log level before importing subdomains
This commit is contained in:
@@ -2,7 +2,7 @@ import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
import { cycleMigrations, dangerousDropAllTables, PgDataStore } from '../datastore/postgres-store';
|
||||
import { startEventServer } from '../event-stream/event-server';
|
||||
import { getApiConfiguredChainID, httpPostRequest, logger } from '../helpers';
|
||||
import { defaultLogLevel, getApiConfiguredChainID, httpPostRequest, logger } from '../helpers';
|
||||
import { findBnsGenesisBlockData, findTsvBlockHeight, getDbBlockHeight } from './helpers';
|
||||
import { importV1BnsNames, importV1BnsSubdomains, importV1TokenOfferingData } from '../import-v1';
|
||||
|
||||
@@ -179,6 +179,7 @@ export async function importEventsFromTsv(
|
||||
}
|
||||
await db.finishEventReplay();
|
||||
if (process.env.BNS_IMPORT_DIR) {
|
||||
logger.level = defaultLogLevel;
|
||||
await importV1BnsSubdomains(db, process.env.BNS_IMPORT_DIR, tsvGenesisBlockData);
|
||||
}
|
||||
console.log(`Event import and playback successful.`);
|
||||
|
||||
@@ -91,6 +91,7 @@ export async function up(pgm: MigrationBuilder): Promise<void> {
|
||||
},
|
||||
});
|
||||
|
||||
pgm.createIndex('namespaces', 'index_block_hash');
|
||||
pgm.createIndex('namespaces', [
|
||||
{ name: 'ready_block', sort: 'DESC' },
|
||||
{ name: 'microblock_sequence', sort: 'DESC' },
|
||||
|
||||
@@ -84,6 +84,7 @@ export async function up(pgm: MigrationBuilder): Promise<void> {
|
||||
});
|
||||
|
||||
pgm.createIndex('names', 'namespace_id');
|
||||
pgm.createIndex('names', 'index_block_hash');
|
||||
pgm.createIndex('names', [
|
||||
{ name: 'registered_at', sort: 'DESC' },
|
||||
{ name: 'microblock_sequence', sort: 'DESC' },
|
||||
|
||||
@@ -85,6 +85,7 @@ export async function up(pgm: MigrationBuilder): Promise<void> {
|
||||
});
|
||||
|
||||
pgm.createIndex('subdomains', 'name');
|
||||
pgm.createIndex('subdomains', 'index_block_hash');
|
||||
pgm.createIndex('subdomains', [
|
||||
{ name: 'block_height', sort: 'DESC' },
|
||||
{ name: 'microblock_sequence', sort: 'DESC' },
|
||||
|
||||
Reference in New Issue
Block a user