File tree Expand file tree Collapse file tree 2 files changed +16
-10
lines changed Expand file tree Collapse file tree 2 files changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -224,7 +224,12 @@ class BitcoinRoutes {
224
224
} else {
225
225
let cpfpInfo ;
226
226
if ( config . DATABASE . ENABLED ) {
227
- cpfpInfo = await transactionRepository . $getCpfpInfo ( req . params . txId ) ;
227
+ try {
228
+ cpfpInfo = await transactionRepository . $getCpfpInfo ( req . params . txId ) ;
229
+ } catch ( e ) {
230
+ res . status ( 500 ) . send ( 'failed to get CPFP info' ) ;
231
+ return ;
232
+ }
228
233
}
229
234
if ( cpfpInfo ) {
230
235
res . json ( cpfpInfo ) ;
Original file line number Diff line number Diff line change @@ -78,14 +78,6 @@ class CpfpRepository {
78
78
79
79
const maxChunk = 100 ;
80
80
let chunkIndex = 0 ;
81
- // insert transactions in batches of up to 100 rows
82
- while ( chunkIndex < txs . length ) {
83
- const chunk = txs . slice ( chunkIndex , chunkIndex + maxChunk ) ;
84
- await transactionRepository . $batchSetCluster ( chunk ) ;
85
- chunkIndex += maxChunk ;
86
- }
87
-
88
- chunkIndex = 0 ;
89
81
// insert clusters in batches of up to 100 rows
90
82
while ( chunkIndex < clusterValues . length ) {
91
83
const chunk = clusterValues . slice ( chunkIndex , chunkIndex + maxChunk ) ;
@@ -103,6 +95,15 @@ class CpfpRepository {
103
95
) ;
104
96
chunkIndex += maxChunk ;
105
97
}
98
+
99
+ chunkIndex = 0 ;
100
+ // insert transactions in batches of up to 100 rows
101
+ while ( chunkIndex < txs . length ) {
102
+ const chunk = txs . slice ( chunkIndex , chunkIndex + maxChunk ) ;
103
+ await transactionRepository . $batchSetCluster ( chunk ) ;
104
+ chunkIndex += maxChunk ;
105
+ }
106
+
106
107
return true ;
107
108
} catch ( e : any ) {
108
109
logger . err ( `Cannot save cpfp clusters into db. Reason: ` + ( e instanceof Error ? e . message : e ) ) ;
@@ -120,8 +121,8 @@ class CpfpRepository {
120
121
[ clusterRoot ]
121
122
) ;
122
123
const cluster = clusterRows [ 0 ] ;
123
- cluster . effectiveFeePerVsize = cluster . fee_rate ;
124
124
if ( cluster ?. txs ) {
125
+ cluster . effectiveFeePerVsize = cluster . fee_rate ;
125
126
cluster . txs = this . unpack ( cluster . txs ) ;
126
127
return cluster ;
127
128
}
You can’t perform that action at this time.
0 commit comments