[blocks] save pools-v2.json hash in blocks table
This commit is contained in:
parent
14e49126c3
commit
c8e967cc0c
@ -7,7 +7,7 @@ import cpfpRepository from '../repositories/CpfpRepository';
|
|||||||
import { RowDataPacket } from 'mysql2';
|
import { RowDataPacket } from 'mysql2';
|
||||||
|
|
||||||
class DatabaseMigration {
|
class DatabaseMigration {
|
||||||
private static currentVersion = 91;
|
private static currentVersion = 92;
|
||||||
private queryTimeout = 3600_000;
|
private queryTimeout = 3600_000;
|
||||||
private statisticsAddedIndexed = false;
|
private statisticsAddedIndexed = false;
|
||||||
private uniqueLogs: string[] = [];
|
private uniqueLogs: string[] = [];
|
||||||
@ -775,6 +775,12 @@ class DatabaseMigration {
|
|||||||
await this.$executeQuery('ALTER TABLE `blocks_audits` ADD INDEX `time` (`time`)');
|
await this.$executeQuery('ALTER TABLE `blocks_audits` ADD INDEX `time` (`time`)');
|
||||||
await this.updateToSchemaVersion(91);
|
await this.updateToSchemaVersion(91);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// blocks pools-v2.json hash
|
||||||
|
if (databaseSchemaVersion < 92) {
|
||||||
|
await this.$executeQuery('ALTER TABLE `blocks` ADD definition_hash varchar(255) NOT NULL DEFAULT "5f32a67401929169f225f5db43c9efa795d1b159"');
|
||||||
|
await this.updateToSchemaVersion(92);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,15 +19,6 @@ class PoolsParser {
|
|||||||
'addresses': '[]',
|
'addresses': '[]',
|
||||||
'slug': 'unknown'
|
'slug': 'unknown'
|
||||||
};
|
};
|
||||||
private uniqueLogs: string[] = [];
|
|
||||||
|
|
||||||
private uniqueLog(loggerFunction: any, msg: string): void {
|
|
||||||
if (this.uniqueLogs.includes(msg)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.uniqueLogs.push(msg);
|
|
||||||
loggerFunction(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
public setMiningPools(pools): void {
|
public setMiningPools(pools): void {
|
||||||
for (const pool of pools) {
|
for (const pool of pools) {
|
||||||
|
@ -15,6 +15,7 @@ import blocks from '../api/blocks';
|
|||||||
import BlocksAuditsRepository from './BlocksAuditsRepository';
|
import BlocksAuditsRepository from './BlocksAuditsRepository';
|
||||||
import transactionUtils from '../api/transaction-utils';
|
import transactionUtils from '../api/transaction-utils';
|
||||||
import { parseDATUMTemplateCreator } from '../utils/bitcoin-script';
|
import { parseDATUMTemplateCreator } from '../utils/bitcoin-script';
|
||||||
|
import poolsUpdater from '../tasks/pools-updater';
|
||||||
|
|
||||||
interface DatabaseBlock {
|
interface DatabaseBlock {
|
||||||
id: string;
|
id: string;
|
||||||
@ -114,16 +115,16 @@ class BlocksRepository {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const query = `INSERT INTO blocks(
|
const query = `INSERT INTO blocks(
|
||||||
height, hash, blockTimestamp, size,
|
height, hash, blockTimestamp, size,
|
||||||
weight, tx_count, coinbase_raw, difficulty,
|
weight, tx_count, coinbase_raw, difficulty,
|
||||||
pool_id, fees, fee_span, median_fee,
|
pool_id, fees, fee_span, median_fee,
|
||||||
reward, version, bits, nonce,
|
reward, version, bits, nonce,
|
||||||
merkle_root, previous_block_hash, avg_fee, avg_fee_rate,
|
merkle_root, previous_block_hash, avg_fee, avg_fee_rate,
|
||||||
median_timestamp, header, coinbase_address, coinbase_addresses,
|
median_timestamp, header, coinbase_address, coinbase_addresses,
|
||||||
coinbase_signature, utxoset_size, utxoset_change, avg_tx_size,
|
coinbase_signature, utxoset_size, utxoset_change, avg_tx_size,
|
||||||
total_inputs, total_outputs, total_input_amt, total_output_amt,
|
total_inputs, total_outputs, total_input_amt, total_output_amt,
|
||||||
fee_percentiles, segwit_total_txs, segwit_total_size, segwit_total_weight,
|
fee_percentiles, segwit_total_txs, segwit_total_size, segwit_total_weight,
|
||||||
median_fee_amt, coinbase_signature_ascii
|
median_fee_amt, coinbase_signature_ascii, definition_hash
|
||||||
) VALUE (
|
) VALUE (
|
||||||
?, ?, FROM_UNIXTIME(?), ?,
|
?, ?, FROM_UNIXTIME(?), ?,
|
||||||
?, ?, ?, ?,
|
?, ?, ?, ?,
|
||||||
@ -134,7 +135,7 @@ class BlocksRepository {
|
|||||||
?, ?, ?, ?,
|
?, ?, ?, ?,
|
||||||
?, ?, ?, ?,
|
?, ?, ?, ?,
|
||||||
?, ?, ?, ?,
|
?, ?, ?, ?,
|
||||||
?, ?
|
?, ?, ?
|
||||||
)`;
|
)`;
|
||||||
|
|
||||||
const poolDbId = await PoolsRepository.$getPoolByUniqueId(block.extras.pool.id);
|
const poolDbId = await PoolsRepository.$getPoolByUniqueId(block.extras.pool.id);
|
||||||
@ -181,6 +182,7 @@ class BlocksRepository {
|
|||||||
block.extras.segwitTotalWeight,
|
block.extras.segwitTotalWeight,
|
||||||
block.extras.medianFeeAmt,
|
block.extras.medianFeeAmt,
|
||||||
truncatedCoinbaseSignatureAscii,
|
truncatedCoinbaseSignatureAscii,
|
||||||
|
poolsUpdater.currentSha
|
||||||
];
|
];
|
||||||
|
|
||||||
await DB.query(query, params);
|
await DB.query(query, params);
|
||||||
@ -1013,9 +1015,9 @@ class BlocksRepository {
|
|||||||
public async $savePool(id: string, poolId: number): Promise<void> {
|
public async $savePool(id: string, poolId: number): Promise<void> {
|
||||||
try {
|
try {
|
||||||
await DB.query(`
|
await DB.query(`
|
||||||
UPDATE blocks SET pool_id = ?
|
UPDATE blocks SET pool_id = ?, definition_hash = ?
|
||||||
WHERE hash = ?`,
|
WHERE hash = ?`,
|
||||||
[poolId, id]
|
[poolId, poolsUpdater.currentSha, id]
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.err(`Cannot update block pool. Reason: ` + (e instanceof Error ? e.message : e));
|
logger.err(`Cannot update block pool. Reason: ` + (e instanceof Error ? e.message : e));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user