@@ -180,6 +180,9 @@ async function batchGetOrCreateNodeIds(publicKeys: string[]): Promise<Map<string
180180
181181 try {
182182 // Batch query database
183+ if ( uncachedKeys . length === 0 ) {
184+ return result
185+ }
183186 const placeholders = uncachedKeys . map ( ( ) => '?' ) . join ( ',' )
184187 const rows = await dbAll (
185188 receiptDatabase ,
@@ -199,8 +202,9 @@ async function batchGetOrCreateNodeIds(publicKeys: string[]): Promise<Map<string
199202 const newKeys = uncachedKeys . filter ( key => ! existingKeys . has ( key ) )
200203 if ( newKeys . length > 0 ) {
201204 const firstSeen = Date . now ( )
202- const insertValues = newKeys . map ( key => `('${ key } ', ${ firstSeen } )` ) . join ( ',' )
203- await dbRun ( receiptDatabase , `INSERT INTO nodes (public_key, first_seen) VALUES ${ insertValues } ` , [ ] )
205+ const insertPlaceholders = newKeys . map ( ( ) => '(?, ?)' ) . join ( ',' )
206+ const insertParams = newKeys . flatMap ( key => [ key , firstSeen ] )
207+ await dbRun ( receiptDatabase , `INSERT INTO nodes (public_key, first_seen) VALUES ${ insertPlaceholders } ` , insertParams )
204208
205209 // Query newly inserted nodes
206210 const newPlaceholders = newKeys . map ( ( ) => '?' ) . join ( ',' )
@@ -295,6 +299,9 @@ export async function decompressReceiptSignatures(receipt: ArchiverReceipt): Pro
295299 const uniqueNodeIds = [ ...new Set ( nodeIds ) ]
296300
297301 // Batch query
302+ if ( uniqueNodeIds . length === 0 ) {
303+ return receipt
304+ }
298305 const placeholders = uniqueNodeIds . map ( ( ) => '?' ) . join ( ',' )
299306 const rows = await dbAll (
300307 receiptDatabase ,
0 commit comments