mirror of
https://github.com/mempool/mempool.git
synced 2025-02-24 06:47:52 +01:00
Save goggle flags in audit templates & block summaries
This commit is contained in:
parent
5b622c7786
commit
1507003c19
6 changed files with 22 additions and 16 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
import { IBitcoinApi } from './bitcoin-api.interface';
|
||||||
import { IEsploraApi } from './esplora-api.interface';
|
import { IEsploraApi } from './esplora-api.interface';
|
||||||
|
|
||||||
export interface AbstractBitcoinApi {
|
export interface AbstractBitcoinApi {
|
||||||
|
|
|
@ -2,7 +2,7 @@ import config from '../config';
|
||||||
import bitcoinApi, { bitcoinCoreApi } from './bitcoin/bitcoin-api-factory';
|
import bitcoinApi, { bitcoinCoreApi } from './bitcoin/bitcoin-api-factory';
|
||||||
import logger from '../logger';
|
import logger from '../logger';
|
||||||
import memPool from './mempool';
|
import memPool from './mempool';
|
||||||
import { BlockExtended, BlockExtension, BlockSummary, PoolTag, TransactionExtended, TransactionStripped, TransactionMinerInfo, CpfpSummary, MempoolTransactionExtended } from '../mempool.interfaces';
|
import { BlockExtended, BlockExtension, BlockSummary, PoolTag, TransactionExtended, TransactionMinerInfo, CpfpSummary, MempoolTransactionExtended, TransactionClassified } from '../mempool.interfaces';
|
||||||
import { Common } from './common';
|
import { Common } from './common';
|
||||||
import diskCache from './disk-cache';
|
import diskCache from './disk-cache';
|
||||||
import transactionUtils from './transaction-utils';
|
import transactionUtils from './transaction-utils';
|
||||||
|
@ -201,7 +201,8 @@ class Blocks {
|
||||||
txid: tx.txid,
|
txid: tx.txid,
|
||||||
vsize: tx.weight / 4,
|
vsize: tx.weight / 4,
|
||||||
fee: tx.fee ? Math.round(tx.fee * 100000000) : 0,
|
fee: tx.fee ? Math.round(tx.fee * 100000000) : 0,
|
||||||
value: Math.round(tx.vout.reduce((acc, vout) => acc + (vout.value ? vout.value : 0), 0) * 100000000)
|
value: Math.round(tx.vout.reduce((acc, vout) => acc + (vout.value ? vout.value : 0), 0) * 100000000),
|
||||||
|
flags: 0,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -214,7 +215,7 @@ class Blocks {
|
||||||
public summarizeBlockTransactions(hash: string, transactions: TransactionExtended[]): BlockSummary {
|
public summarizeBlockTransactions(hash: string, transactions: TransactionExtended[]): BlockSummary {
|
||||||
return {
|
return {
|
||||||
id: hash,
|
id: hash,
|
||||||
transactions: Common.stripTransactions(transactions),
|
transactions: Common.classifyTransactions(transactions),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -945,7 +946,7 @@ class Blocks {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async $getStrippedBlockTransactions(hash: string, skipMemoryCache = false,
|
public async $getStrippedBlockTransactions(hash: string, skipMemoryCache = false,
|
||||||
skipDBLookup = false, cpfpSummary?: CpfpSummary, blockHeight?: number): Promise<TransactionStripped[]>
|
skipDBLookup = false, cpfpSummary?: CpfpSummary, blockHeight?: number): Promise<TransactionClassified[]>
|
||||||
{
|
{
|
||||||
if (skipMemoryCache === false) {
|
if (skipMemoryCache === false) {
|
||||||
// Check the memory cache
|
// Check the memory cache
|
||||||
|
@ -974,7 +975,8 @@ class Blocks {
|
||||||
fee: tx.fee || 0,
|
fee: tx.fee || 0,
|
||||||
vsize: tx.vsize,
|
vsize: tx.vsize,
|
||||||
value: Math.round(tx.vout.reduce((acc, vout) => acc + (vout.value ? vout.value : 0), 0)),
|
value: Math.round(tx.vout.reduce((acc, vout) => acc + (vout.value ? vout.value : 0), 0)),
|
||||||
rate: tx.effectiveFeePerVsize
|
rate: tx.effectiveFeePerVsize,
|
||||||
|
flags: tx.flags || Common.getTransactionFlags(tx),
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
import * as bitcoinjs from 'bitcoinjs-lib';
|
import * as bitcoinjs from 'bitcoinjs-lib';
|
||||||
import { Request } from 'express';
|
import { Request } from 'express';
|
||||||
import { Ancestor, CpfpInfo, CpfpSummary, CpfpCluster, EffectiveFeeStats, MempoolBlockWithTransactions, TransactionExtended, MempoolTransactionExtended, TransactionStripped, WorkingEffectiveFeeStats, TransactionClassified, TransactionFlags } from '../mempool.interfaces';
|
import { CpfpInfo, CpfpSummary, CpfpCluster, EffectiveFeeStats, MempoolBlockWithTransactions, TransactionExtended, MempoolTransactionExtended, TransactionStripped, WorkingEffectiveFeeStats, TransactionClassified, TransactionFlags } from '../mempool.interfaces';
|
||||||
import config from '../config';
|
import config from '../config';
|
||||||
import { NodeSocket } from '../repositories/NodesSocketsRepository';
|
import { NodeSocket } from '../repositories/NodesSocketsRepository';
|
||||||
import { isIP } from 'net';
|
import { isIP } from 'net';
|
||||||
import rbfCache from './rbf-cache';
|
|
||||||
import transactionUtils from './transaction-utils';
|
import transactionUtils from './transaction-utils';
|
||||||
import { isPoint } from '../utils/secp256k1';
|
import { isPoint } from '../utils/secp256k1';
|
||||||
export class Common {
|
export class Common {
|
||||||
|
@ -349,14 +348,18 @@ export class Common {
|
||||||
}
|
}
|
||||||
|
|
||||||
static classifyTransaction(tx: TransactionExtended): TransactionClassified {
|
static classifyTransaction(tx: TransactionExtended): TransactionClassified {
|
||||||
const flags = this.getTransactionFlags(tx);
|
const flags = Common.getTransactionFlags(tx);
|
||||||
tx.flags = flags;
|
tx.flags = flags;
|
||||||
return {
|
return {
|
||||||
...this.stripTransaction(tx),
|
...Common.stripTransaction(tx),
|
||||||
flags,
|
flags,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static classifyTransactions(txs: TransactionExtended[]): TransactionClassified[] {
|
||||||
|
return txs.map(Common.classifyTransaction);
|
||||||
|
}
|
||||||
|
|
||||||
static stripTransaction(tx: TransactionExtended): TransactionStripped {
|
static stripTransaction(tx: TransactionExtended): TransactionStripped {
|
||||||
return {
|
return {
|
||||||
txid: tx.txid,
|
txid: tx.txid,
|
||||||
|
@ -369,7 +372,7 @@ export class Common {
|
||||||
}
|
}
|
||||||
|
|
||||||
static stripTransactions(txs: TransactionExtended[]): TransactionStripped[] {
|
static stripTransactions(txs: TransactionExtended[]): TransactionStripped[] {
|
||||||
return txs.map(this.stripTransaction);
|
return txs.map(Common.stripTransaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
static sleep$(ms: number): Promise<void> {
|
static sleep$(ms: number): Promise<void> {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { GbtGenerator, GbtResult, ThreadTransaction as RustThreadTransaction, ThreadAcceleration as RustThreadAcceleration } from 'rust-gbt';
|
import { GbtGenerator, GbtResult, ThreadTransaction as RustThreadTransaction, ThreadAcceleration as RustThreadAcceleration } from 'rust-gbt';
|
||||||
import logger from '../logger';
|
import logger from '../logger';
|
||||||
import { MempoolBlock, MempoolTransactionExtended, TransactionStripped, MempoolBlockWithTransactions, MempoolBlockDelta, Ancestor, CompactThreadTransaction, EffectiveFeeStats, PoolTag, TransactionClassified } from '../mempool.interfaces';
|
import { MempoolBlock, MempoolTransactionExtended, MempoolBlockWithTransactions, MempoolBlockDelta, Ancestor, CompactThreadTransaction, EffectiveFeeStats, PoolTag, TransactionClassified } from '../mempool.interfaces';
|
||||||
import { Common, OnlineFeeStatsCalculator } from './common';
|
import { Common, OnlineFeeStatsCalculator } from './common';
|
||||||
import config from '../config';
|
import config from '../config';
|
||||||
import { Worker } from 'worker_threads';
|
import { Worker } from 'worker_threads';
|
||||||
|
|
|
@ -280,7 +280,7 @@ export interface BlockExtended extends IEsploraApi.Block {
|
||||||
|
|
||||||
export interface BlockSummary {
|
export interface BlockSummary {
|
||||||
id: string;
|
id: string;
|
||||||
transactions: TransactionStripped[];
|
transactions: TransactionClassified[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AuditSummary extends BlockAudit {
|
export interface AuditSummary extends BlockAudit {
|
||||||
|
@ -288,8 +288,8 @@ export interface AuditSummary extends BlockAudit {
|
||||||
size?: number,
|
size?: number,
|
||||||
weight?: number,
|
weight?: number,
|
||||||
tx_count?: number,
|
tx_count?: number,
|
||||||
transactions: TransactionStripped[];
|
transactions: TransactionClassified[];
|
||||||
template?: TransactionStripped[];
|
template?: TransactionClassified[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BlockPrice {
|
export interface BlockPrice {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import DB from '../database';
|
import DB from '../database';
|
||||||
import logger from '../logger';
|
import logger from '../logger';
|
||||||
import { BlockSummary, TransactionStripped } from '../mempool.interfaces';
|
import { BlockSummary, TransactionClassified } from '../mempool.interfaces';
|
||||||
|
|
||||||
class BlocksSummariesRepository {
|
class BlocksSummariesRepository {
|
||||||
public async $getByBlockId(id: string): Promise<BlockSummary | undefined> {
|
public async $getByBlockId(id: string): Promise<BlockSummary | undefined> {
|
||||||
|
@ -17,7 +17,7 @@ class BlocksSummariesRepository {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async $saveTransactions(blockHeight: number, blockId: string, transactions: TransactionStripped[]): Promise<void> {
|
public async $saveTransactions(blockHeight: number, blockId: string, transactions: TransactionClassified[]): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const transactionsStr = JSON.stringify(transactions);
|
const transactionsStr = JSON.stringify(transactions);
|
||||||
await DB.query(`
|
await DB.query(`
|
||||||
|
|
Loading…
Add table
Reference in a new issue