Remove fields that won't be used in the frontend for now

This commit is contained in:
nymkappa 2022-02-10 10:25:14 +09:00
parent aa0e6b807a
commit b8e40494aa
No known key found for this signature in database
GPG Key ID: E155910B16E8BD04
4 changed files with 12 additions and 16 deletions

View File

@ -126,12 +126,10 @@ class Blocks {
} else { } else {
pool = await poolsRepository.$getUnknownPool(); pool = await poolsRepository.$getUnknownPool();
} }
blockExtended.extras.pool = pool; blockExtended.extras.pool = {
id: pool.id,
if (transactions.length > 0) { name: pool.name
const coinbase: IEsploraApi.Transaction = await bitcoinApi.$getRawTransaction(transactions[0].txid, true); };
blockExtended.extras.coinbaseHex = coinbase.hex;
}
} }
return blockExtended; return blockExtended;
@ -404,13 +402,9 @@ class Blocks {
medianFee: block?.medianFee, medianFee: block?.medianFee,
feeRange: block?.feeRange ?? [], // TODO feeRange: block?.feeRange ?? [], // TODO
reward: block?.reward, reward: block?.reward,
coinbaseHex: block?.extras?.coinbaseHex ?? block?.coinbase_raw, // coinbase_raw for indexed block
pool: block?.extras?.pool ?? (block?.pool_id ? { pool: block?.extras?.pool ?? (block?.pool_id ? {
id: block?.pool_id, id: block?.pool_id,
name: block?.pool_name, name: block?.pool_name,
link: block?.pool_link,
regexes: block?.pool_regexes,
addresses: block?.pool_addresses,
} : undefined), } : undefined),
} }
}; };

View File

@ -1,7 +1,7 @@
import { IEsploraApi } from './api/bitcoin/esplora-api.interface'; import { IEsploraApi } from './api/bitcoin/esplora-api.interface';
export interface PoolTag { export interface PoolTag {
id: number | null, // mysql row id id: number, // mysql row id
name: string, name: string,
link: string, link: string,
regexes: string, // JSON array regexes: string, // JSON array
@ -83,8 +83,10 @@ export interface BlockExtension {
reward?: number; reward?: number;
coinbaseTx?: TransactionMinerInfo; coinbaseTx?: TransactionMinerInfo;
matchRate?: number; matchRate?: number;
coinbaseHex?: string; pool?: {
pool?: PoolTag; id: number;
name: string;
}
} }
export interface BlockExtended extends IEsploraApi.Block { export interface BlockExtended extends IEsploraApi.Block {

View File

@ -34,7 +34,7 @@ class BlocksRepository {
block.size, block.size,
block.weight, block.weight,
block.tx_count, block.tx_count,
block.extras?.coinbaseHex ?? '', '',
block.difficulty, block.difficulty,
block.extras?.pool?.id, // Should always be set to something block.extras?.pool?.id, // Should always be set to something
0, 0,

View File

@ -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 id, name, addresses, regexes 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 id, name FROM pools where name = "Unknown"');
connection.release(); connection.release();
return <PoolTag>rows[0]; return <PoolTag>rows[0];
} }