File tree 2 files changed +22
-0
lines changed
2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ use anyhow::Result;
3
3
use bitcoin:: key:: XOnlyPublicKey ;
4
4
use coordinator:: backup:: SledBackup ;
5
5
use coordinator:: cli:: Opts ;
6
+ use coordinator:: db;
6
7
use coordinator:: dlc_handler;
7
8
use coordinator:: dlc_handler:: DlcHandler ;
8
9
use coordinator:: logger;
@@ -356,6 +357,20 @@ async fn main() -> Result<()> {
356
357
}
357
358
} ) ;
358
359
360
+ if let Err ( e) = spawn_blocking ( {
361
+ let pool = pool. clone ( ) ;
362
+ move || {
363
+ let mut conn = pool. get ( ) ?;
364
+ db:: hodl_invoice:: cancel_pending_hodl_invoices ( & mut conn) ?;
365
+ anyhow:: Ok ( ( ) )
366
+ }
367
+ } )
368
+ . await
369
+ . expect ( "task to finish" )
370
+ {
371
+ tracing:: error!( "Failed to set expired hodl invoices to canceled. Error: {e:#}" ) ;
372
+ }
373
+
359
374
tracing:: debug!( "Listening on http://{}" , http_address) ;
360
375
361
376
match axum:: Server :: bind ( & http_address)
Original file line number Diff line number Diff line change @@ -35,6 +35,13 @@ impl QueryId for InvoiceStateType {
35
35
}
36
36
}
37
37
38
+ pub fn cancel_pending_hodl_invoices ( conn : & mut PgConnection ) -> QueryResult < usize > {
39
+ diesel:: update ( hodl_invoices:: table)
40
+ . filter ( hodl_invoices:: invoice_state. eq_any ( [ InvoiceState :: Open , InvoiceState :: Accepted ] ) )
41
+ . set ( hodl_invoices:: invoice_state. eq ( InvoiceState :: Canceled ) )
42
+ . execute ( conn)
43
+ }
44
+
38
45
pub fn create_hodl_invoice (
39
46
conn : & mut PgConnection ,
40
47
r_hash : & str ,
You can’t perform that action at this time.
0 commit comments