Merge pull request #3886 from mempool/mononaut/hotfix-undefined-cpfp-cluster
Hotfix for undefined cpfp cluster bug
This commit is contained in:
commit
e88cf70719
@ -224,7 +224,12 @@ class BitcoinRoutes {
|
|||||||
} else {
|
} else {
|
||||||
let cpfpInfo;
|
let cpfpInfo;
|
||||||
if (config.DATABASE.ENABLED) {
|
if (config.DATABASE.ENABLED) {
|
||||||
|
try {
|
||||||
cpfpInfo = await transactionRepository.$getCpfpInfo(req.params.txId);
|
cpfpInfo = await transactionRepository.$getCpfpInfo(req.params.txId);
|
||||||
|
} catch (e) {
|
||||||
|
res.status(500).send('failed to get CPFP info');
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (cpfpInfo) {
|
if (cpfpInfo) {
|
||||||
res.json(cpfpInfo);
|
res.json(cpfpInfo);
|
||||||
|
@ -78,14 +78,6 @@ class CpfpRepository {
|
|||||||
|
|
||||||
const maxChunk = 100;
|
const maxChunk = 100;
|
||||||
let chunkIndex = 0;
|
let chunkIndex = 0;
|
||||||
// insert transactions in batches of up to 100 rows
|
|
||||||
while (chunkIndex < txs.length) {
|
|
||||||
const chunk = txs.slice(chunkIndex, chunkIndex + maxChunk);
|
|
||||||
await transactionRepository.$batchSetCluster(chunk);
|
|
||||||
chunkIndex += maxChunk;
|
|
||||||
}
|
|
||||||
|
|
||||||
chunkIndex = 0;
|
|
||||||
// insert clusters in batches of up to 100 rows
|
// insert clusters in batches of up to 100 rows
|
||||||
while (chunkIndex < clusterValues.length) {
|
while (chunkIndex < clusterValues.length) {
|
||||||
const chunk = clusterValues.slice(chunkIndex, chunkIndex + maxChunk);
|
const chunk = clusterValues.slice(chunkIndex, chunkIndex + maxChunk);
|
||||||
@ -103,6 +95,15 @@ class CpfpRepository {
|
|||||||
);
|
);
|
||||||
chunkIndex += maxChunk;
|
chunkIndex += maxChunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
chunkIndex = 0;
|
||||||
|
// insert transactions in batches of up to 100 rows
|
||||||
|
while (chunkIndex < txs.length) {
|
||||||
|
const chunk = txs.slice(chunkIndex, chunkIndex + maxChunk);
|
||||||
|
await transactionRepository.$batchSetCluster(chunk);
|
||||||
|
chunkIndex += maxChunk;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
logger.err(`Cannot save cpfp clusters into db. Reason: ` + (e instanceof Error ? e.message : e));
|
logger.err(`Cannot save cpfp clusters into db. Reason: ` + (e instanceof Error ? e.message : e));
|
||||||
@ -120,8 +121,8 @@ class CpfpRepository {
|
|||||||
[clusterRoot]
|
[clusterRoot]
|
||||||
);
|
);
|
||||||
const cluster = clusterRows[0];
|
const cluster = clusterRows[0];
|
||||||
cluster.effectiveFeePerVsize = cluster.fee_rate;
|
|
||||||
if (cluster?.txs) {
|
if (cluster?.txs) {
|
||||||
|
cluster.effectiveFeePerVsize = cluster.fee_rate;
|
||||||
cluster.txs = this.unpack(cluster.txs);
|
cluster.txs = this.unpack(cluster.txs);
|
||||||
return cluster;
|
return cluster;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user