Merge branch 'origin/HEAD' into natsoni/more-fiat-currencies and fix db version conflicts
This commit is contained in:
@@ -33,7 +33,7 @@ interface GraphTx {
|
||||
vsize: number;
|
||||
weight: number;
|
||||
fees: {
|
||||
base: number;
|
||||
base: number; // in sats
|
||||
};
|
||||
depends: string[];
|
||||
spentby: string[];
|
||||
@@ -42,7 +42,7 @@ interface GraphTx {
|
||||
interface MempoolTx extends GraphTx {
|
||||
ancestorcount: number;
|
||||
ancestorsize: number;
|
||||
fees: {
|
||||
fees: { // in sats
|
||||
base: number;
|
||||
ancestor: number;
|
||||
};
|
||||
@@ -317,7 +317,7 @@ class AccelerationCosts {
|
||||
throw new Error('invalid_tx_dependencies');
|
||||
}
|
||||
|
||||
let totalFee = Math.round(tx.fees.ancestor * 100_000_000);
|
||||
let totalFee = tx.fees.ancestor;
|
||||
|
||||
// transaction is already CPFP-d above the target rate by some descendant
|
||||
if (includedInCluster) {
|
||||
@@ -325,7 +325,7 @@ class AccelerationCosts {
|
||||
let clusterFee = 0;
|
||||
includedInCluster.forEach(entry => {
|
||||
clusterSize += entry.vsize;
|
||||
clusterFee += (entry.fees.base * 100_000_000);
|
||||
clusterFee += entry.fees.base;
|
||||
});
|
||||
const clusterRate = clusterFee / clusterSize;
|
||||
totalFee = Math.ceil(tx.ancestorsize * clusterRate);
|
||||
@@ -448,8 +448,8 @@ class AccelerationCosts {
|
||||
* @param tx
|
||||
*/
|
||||
private setAncestorScores(tx: MempoolTx): void {
|
||||
tx.individualRate = (tx.fees.base * 100_000_000) / tx.vsize;
|
||||
tx.ancestorRate = (tx.fees.ancestor * 100_000_000) / tx.ancestorsize;
|
||||
tx.individualRate = tx.fees.base / tx.vsize;
|
||||
tx.ancestorRate = tx.fees.ancestor / tx.ancestorsize;
|
||||
tx.score = Math.min(tx.individualRate, tx.ancestorRate);
|
||||
}
|
||||
|
||||
|
||||
@@ -293,7 +293,6 @@ export class Common {
|
||||
}
|
||||
if (vout.value < (dustSize * DUST_RELAY_TX_FEE)) {
|
||||
// under minimum output size
|
||||
console.log(`NON-STANDARD | dust | ${vout.value} | ${dustSize} ${dustSize * DUST_RELAY_TX_FEE} `, tx.txid);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -456,6 +455,8 @@ export class Common {
|
||||
flags |= TransactionFlags.no_rbf;
|
||||
}
|
||||
let hasFakePubkey = false;
|
||||
let P2WSHCount = 0;
|
||||
let olgaSize = 0;
|
||||
for (const vout of tx.vout) {
|
||||
switch (vout.scriptpubkey_type) {
|
||||
case 'p2pk': {
|
||||
@@ -483,6 +484,20 @@ export class Common {
|
||||
if (vout.scriptpubkey_address) {
|
||||
reusedOutputAddresses[vout.scriptpubkey_address] = (reusedOutputAddresses[vout.scriptpubkey_address] || 0) + 1;
|
||||
}
|
||||
if (vout.scriptpubkey_type === 'v0_p2wsh') {
|
||||
if (!P2WSHCount) {
|
||||
olgaSize = parseInt(vout.scriptpubkey.slice(4, 8), 16);
|
||||
}
|
||||
P2WSHCount++;
|
||||
if (P2WSHCount === Math.ceil((olgaSize + 2) / 32)) {
|
||||
const nullBytes = (P2WSHCount * 32) - olgaSize - 2;
|
||||
if (vout.scriptpubkey.endsWith(''.padEnd(nullBytes * 2, '0'))) {
|
||||
flags |= TransactionFlags.fake_scripthash;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
P2WSHCount = 0;
|
||||
}
|
||||
outValues[vout.value || Math.random()] = (outValues[vout.value || Math.random()] || 0) + 1;
|
||||
}
|
||||
if (hasFakePubkey) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import cpfpRepository from '../repositories/CpfpRepository';
|
||||
import { RowDataPacket } from 'mysql2';
|
||||
|
||||
class DatabaseMigration {
|
||||
private static currentVersion = 72;
|
||||
private static currentVersion = 74;
|
||||
private queryTimeout = 3600_000;
|
||||
private statisticsAddedIndexed = false;
|
||||
private uniqueLogs: string[] = [];
|
||||
@@ -607,7 +607,20 @@ class DatabaseMigration {
|
||||
await this.updateToSchemaVersion(71);
|
||||
}
|
||||
|
||||
if (databaseSchemaVersion < 72) {
|
||||
if (databaseSchemaVersion < 72 && isBitcoin === true) {
|
||||
// reindex Goggles flags for mined block templates above height 832000
|
||||
await this.$executeQuery('UPDATE blocks_summaries SET version = 0 WHERE height >= 832000;');
|
||||
await this.updateToSchemaVersion(72);
|
||||
}
|
||||
|
||||
if (databaseSchemaVersion < 73 && config.MEMPOOL.NETWORK === 'mainnet') {
|
||||
// Clear bad data
|
||||
await this.$executeQuery(`TRUNCATE accelerations`);
|
||||
this.uniqueLog(logger.notice, `'accelerations' table has been truncated`);
|
||||
await this.updateToSchemaVersion(73);
|
||||
}
|
||||
|
||||
if (databaseSchemaVersion < 74) {
|
||||
await this.$executeQuery('ALTER TABLE `prices` ADD `BGN` float DEFAULT "-1"');
|
||||
await this.$executeQuery('ALTER TABLE `prices` ADD `BRL` float DEFAULT "-1"');
|
||||
await this.$executeQuery('ALTER TABLE `prices` ADD `CNY` float DEFAULT "-1"');
|
||||
@@ -634,7 +647,7 @@ class DatabaseMigration {
|
||||
await this.$executeQuery('ALTER TABLE `prices` ADD `THB` float DEFAULT "-1"');
|
||||
await this.$executeQuery('ALTER TABLE `prices` ADD `TRY` float DEFAULT "-1"');
|
||||
await this.$executeQuery('ALTER TABLE `prices` ADD `ZAR` float DEFAULT "-1"');
|
||||
await this.updateToSchemaVersion(72);
|
||||
await this.updateToSchemaVersion(74);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -107,6 +107,7 @@ class Mempool {
|
||||
if (config.MEMPOOL.CACHE_ENABLED && config.REDIS.ENABLED) {
|
||||
await redisCache.$addTransaction(this.mempoolCache[txid]);
|
||||
}
|
||||
this.mempoolCache[txid].flags = Common.getTransactionFlags(this.mempoolCache[txid]);
|
||||
}
|
||||
if (config.MEMPOOL.CACHE_ENABLED && config.REDIS.ENABLED) {
|
||||
await redisCache.$flushTransactions();
|
||||
|
||||
@@ -226,6 +226,7 @@ export const TransactionFlags = {
|
||||
op_return: 0b00000001_00000000_00000000_00000000n,
|
||||
fake_pubkey: 0b00000010_00000000_00000000_00000000n,
|
||||
inscription: 0b00000100_00000000_00000000_00000000n,
|
||||
fake_scripthash: 0b00001000_00000000_00000000_00000000n,
|
||||
// heuristics
|
||||
coinjoin: 0b00000001_00000000_00000000_00000000_00000000n,
|
||||
consolidation: 0b00000010_00000000_00000000_00000000_00000000n,
|
||||
|
||||
@@ -70,14 +70,26 @@ class AccelerationRepository {
|
||||
JOIN pools on pools.unique_id = accelerations.pool
|
||||
`;
|
||||
let params: any[] = [];
|
||||
let hasFilter = false;
|
||||
|
||||
if (interval) {
|
||||
query += ` WHERE accelerations.added BETWEEN DATE_SUB(NOW(), INTERVAL ${interval}) AND NOW() `;
|
||||
} else if (height != null) {
|
||||
query += ` WHERE accelerations.height = ? `;
|
||||
hasFilter = true;
|
||||
}
|
||||
|
||||
if (height != null) {
|
||||
if (hasFilter) {
|
||||
query += ` AND accelerations.height = ? `;
|
||||
} else {
|
||||
query += ` WHERE accelerations.height = ? `;
|
||||
}
|
||||
params.push(height);
|
||||
} else if (poolSlug != null) {
|
||||
query += ` WHERE pools.slug = ? `;
|
||||
if (hasFilter) {
|
||||
query += ` AND pools.slug = ? `;
|
||||
} else {
|
||||
query += ` WHERE pools.slug = ? `;
|
||||
}
|
||||
params.push(poolSlug);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user