mirror of
https://github.com/mempool/mempool.git
synced 2025-01-18 05:12:35 +01:00
Drop legacy blocks
table during migration - Fix linter issues
This commit is contained in:
parent
b8410f00d9
commit
aa457e316b
@ -17,6 +17,6 @@ sudo npm install -g ts-node nodemon
|
|||||||
> Note: You can find your npm global binary folder using `npm -g bin`, where nodemon will be installed.
|
> Note: You can find your npm global binary folder using `npm -g bin`, where nodemon will be installed.
|
||||||
|
|
||||||
```
|
```
|
||||||
nodemon src/index.ts --ignore cache/
|
nodemon src/index.ts --ignore cache/ --ignore pools.json
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -124,15 +124,15 @@ class Blocks {
|
|||||||
const pools: PoolTag[] = await poolsRepository.$getPools();
|
const pools: PoolTag[] = await poolsRepository.$getPools();
|
||||||
for (let i = 0; i < pools.length; ++i) {
|
for (let i = 0; i < pools.length; ++i) {
|
||||||
if (address !== undefined) {
|
if (address !== undefined) {
|
||||||
let addresses: string[] = JSON.parse(pools[i].addresses);
|
const addresses: string[] = JSON.parse(pools[i].addresses);
|
||||||
if (addresses.indexOf(address) !== -1) {
|
if (addresses.indexOf(address) !== -1) {
|
||||||
return pools[i];
|
return pools[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let regexes: string[] = JSON.parse(pools[i].regexes);
|
const regexes: string[] = JSON.parse(pools[i].regexes);
|
||||||
for (let y = 0; y < regexes.length; ++y) {
|
for (let y = 0; y < regexes.length; ++y) {
|
||||||
let match = asciiScriptSig.match(regexes[y]);
|
const match = asciiScriptSig.match(regexes[y]);
|
||||||
if (match !== null) {
|
if (match !== null) {
|
||||||
return pools[i];
|
return pools[i];
|
||||||
}
|
}
|
||||||
|
@ -87,6 +87,7 @@ class DatabaseMigration {
|
|||||||
await this.$executeQuery(connection, this.getCreatePoolsTableQuery(), await this.$checkIfTableExists('pools'));
|
await this.$executeQuery(connection, this.getCreatePoolsTableQuery(), await this.$checkIfTableExists('pools'));
|
||||||
}
|
}
|
||||||
if (databaseSchemaVersion < 4) {
|
if (databaseSchemaVersion < 4) {
|
||||||
|
await this.$executeQuery(connection, 'DROP table blocks;');
|
||||||
await this.$executeQuery(connection, this.getCreateBlocksTableQuery(), await this.$checkIfTableExists('blocks'));
|
await this.$executeQuery(connection, this.getCreateBlocksTableQuery(), await this.$checkIfTableExists('blocks'));
|
||||||
}
|
}
|
||||||
connection.release();
|
connection.release();
|
||||||
|
@ -38,7 +38,7 @@ class BlocksRepository {
|
|||||||
|
|
||||||
await connection.query(query, params);
|
await connection.query(query, params);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.err('$updateBlocksDatabase() error' + (e instanceof Error ? e.message : e));
|
logger.err('$saveBlockInDatabase() error' + (e instanceof Error ? e.message : e));
|
||||||
}
|
}
|
||||||
|
|
||||||
connection.release();
|
connection.release();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { DB } from "../database";
|
import { DB } from '../database';
|
||||||
import { PoolInfo, PoolTag } from "../mempool.interfaces"
|
import { PoolInfo, PoolTag } from '../mempool.interfaces';
|
||||||
|
|
||||||
class PoolsRepository {
|
class PoolsRepository {
|
||||||
/**
|
/**
|
||||||
@ -7,7 +7,7 @@ class PoolsRepository {
|
|||||||
*/
|
*/
|
||||||
public async $getPools(): Promise<PoolTag[]> {
|
public async $getPools(): Promise<PoolTag[]> {
|
||||||
const connection = await DB.pool.getConnection();
|
const connection = await DB.pool.getConnection();
|
||||||
const [rows] = await connection.query("SELECT * FROM pools;");
|
const [rows] = await connection.query('SELECT * FROM pools;');
|
||||||
connection.release();
|
connection.release();
|
||||||
return <PoolTag[]>rows;
|
return <PoolTag[]>rows;
|
||||||
}
|
}
|
||||||
@ -17,7 +17,7 @@ class PoolsRepository {
|
|||||||
*/
|
*/
|
||||||
public async $getUnknownPool(): Promise<PoolTag> {
|
public async $getUnknownPool(): Promise<PoolTag> {
|
||||||
const connection = await DB.pool.getConnection();
|
const connection = await DB.pool.getConnection();
|
||||||
const [rows] = await connection.query("SELECT * FROM pools where name = 'Unknown'");
|
const [rows] = await connection.query('SELECT * FROM pools where name = "Unknown"');
|
||||||
connection.release();
|
connection.release();
|
||||||
return <PoolTag>rows[0];
|
return <PoolTag>rows[0];
|
||||||
}
|
}
|
||||||
@ -25,7 +25,7 @@ class PoolsRepository {
|
|||||||
/**
|
/**
|
||||||
* Get basic pool info and block count
|
* Get basic pool info and block count
|
||||||
*/
|
*/
|
||||||
public async $getPoolsInfo(interval: string = "100 YEARS"): Promise<PoolInfo[]> {
|
public async $getPoolsInfo(interval: string = '100 YEARS'): Promise<PoolInfo[]> {
|
||||||
const connection = await DB.pool.getConnection();
|
const connection = await DB.pool.getConnection();
|
||||||
const [rows] = await connection.query(`
|
const [rows] = await connection.query(`
|
||||||
SELECT COUNT(height) as blockCount, pool_id as poolId, pools.name as name, pools.link as link
|
SELECT COUNT(height) as blockCount, pool_id as poolId, pools.name as name, pools.link as link
|
||||||
|
Loading…
Reference in New Issue
Block a user