@@ -62,7 +62,7 @@ impl OrangeTrigger {
6262impl RebalanceTrigger for OrangeTrigger {
6363 fn needs_trusted_rebalance ( & self ) -> impl Future < Output = Option < TriggerParams > > + Send {
6464 async move {
65- let rebalance_enabled = store:: get_rebalance_enabled ( self . store . as_ref ( ) ) ;
65+ let rebalance_enabled = store:: get_rebalance_enabled ( self . store . as_ref ( ) ) . await ;
6666 if !rebalance_enabled {
6767 return None ;
6868 }
@@ -99,15 +99,17 @@ impl RebalanceTrigger for OrangeTrigger {
9999 payment. id. as_hex( )
100100 ) ;
101101 new_txn. push ( ( payment. amount , & payment. id ) ) ;
102- self . tx_metadata . insert (
103- payment_id,
104- TxMetadata {
105- ty : TxType :: Payment { ty : PaymentType :: IncomingLightning { } } ,
106- time : SystemTime :: now ( )
107- . duration_since ( SystemTime :: UNIX_EPOCH )
108- . unwrap ( ) ,
109- } ,
110- ) ;
102+ self . tx_metadata
103+ . insert (
104+ payment_id,
105+ TxMetadata {
106+ ty : TxType :: Payment { ty : PaymentType :: IncomingLightning { } } ,
107+ time : SystemTime :: now ( )
108+ . duration_since ( SystemTime :: UNIX_EPOCH )
109+ . unwrap ( ) ,
110+ } ,
111+ )
112+ . await ;
111113 }
112114 }
113115
@@ -141,7 +143,7 @@ impl RebalanceTrigger for OrangeTrigger {
141143
142144 fn needs_onchain_rebalance ( & self ) -> impl Future < Output = Option < TriggerParams > > + Send {
143145 async move {
144- let rebalance_enabled = store:: get_rebalance_enabled ( self . store . as_ref ( ) ) ;
146+ let rebalance_enabled = store:: get_rebalance_enabled ( self . store . as_ref ( ) ) . await ;
145147 if !rebalance_enabled {
146148 return None ;
147149 }
@@ -215,19 +217,21 @@ impl RebalanceTrigger for OrangeTrigger {
215217 // make sure we have a metadata entry for the triggering transaction
216218 let trigger = PaymentId :: SelfCustodial ( txid. to_byte_array ( ) ) ;
217219 if self . tx_metadata . read ( ) . get ( & trigger) . is_none ( ) {
218- self . tx_metadata . insert (
219- trigger,
220- TxMetadata {
221- ty : TxType :: Payment {
222- ty : PaymentType :: IncomingOnChain {
223- txid : Some ( txid) ,
220+ self . tx_metadata
221+ . insert (
222+ trigger,
223+ TxMetadata {
224+ ty : TxType :: Payment {
225+ ty : PaymentType :: IncomingOnChain {
226+ txid : Some ( txid) ,
227+ } ,
224228 } ,
229+ time : SystemTime :: now ( )
230+ . duration_since ( SystemTime :: UNIX_EPOCH )
231+ . unwrap ( ) ,
225232 } ,
226- time : SystemTime :: now ( )
227- . duration_since ( SystemTime :: UNIX_EPOCH )
228- . unwrap ( ) ,
229- } ,
230- ) ;
233+ )
234+ . await ;
231235 }
232236
233237 Some ( TriggerParams {
@@ -295,7 +299,8 @@ impl graduated_rebalancer::EventHandler for OrangeRebalanceEventHandler {
295299 time : SystemTime :: now ( ) . duration_since ( SystemTime :: UNIX_EPOCH ) . unwrap ( ) ,
296300 } ;
297301 self . tx_metadata
298- . insert ( PaymentId :: Trusted ( trusted_rebalance_payment_id) , metadata) ;
302+ . insert ( PaymentId :: Trusted ( trusted_rebalance_payment_id) , metadata)
303+ . await ;
299304 if let Err ( e) = self
300305 . event_queue
301306 . add_event ( Event :: RebalanceInitiated {
@@ -318,6 +323,7 @@ impl graduated_rebalancer::EventHandler for OrangeRebalanceEventHandler {
318323 let triggering_transaction_id = PaymentId :: Trusted ( trigger_id) ;
319324 self . tx_metadata
320325 . set_tx_caused_rebalance ( & triggering_transaction_id)
326+ . await
321327 . expect ( "Failed to write metadata for rebalance transaction" ) ;
322328 let metadata = TxMetadata {
323329 ty : TxType :: TrustedToLightning {
@@ -327,8 +333,8 @@ impl graduated_rebalancer::EventHandler for OrangeRebalanceEventHandler {
327333 } ,
328334 time : SystemTime :: now ( ) . duration_since ( SystemTime :: UNIX_EPOCH ) . unwrap ( ) ,
329335 } ;
330- self . tx_metadata . upsert ( PaymentId :: Trusted ( rebalance_id) , metadata) ;
331- self . tx_metadata . insert ( PaymentId :: SelfCustodial ( lightning_id) , metadata) ;
336+ self . tx_metadata . upsert ( PaymentId :: Trusted ( rebalance_id) , metadata) . await ;
337+ self . tx_metadata . insert ( PaymentId :: SelfCustodial ( lightning_id) , metadata) . await ;
332338
333339 let event_queue = Arc :: clone ( & self . event_queue ) ;
334340 let logger = Arc :: clone ( & self . logger ) ;
@@ -357,13 +363,15 @@ impl graduated_rebalancer::EventHandler for OrangeRebalanceEventHandler {
357363 let trigger_id = PaymentId :: SelfCustodial ( triggering_txid. to_byte_array ( ) ) ;
358364 self . tx_metadata
359365 . set_tx_caused_rebalance ( & trigger_id)
366+ . await
360367 . expect ( "Failed to write metadata for onchain rebalance transaction" ) ;
361368 let metadata = TxMetadata {
362369 ty : TxType :: OnchainToLightning { channel_txid : chan_txid, triggering_txid } ,
363370 time : SystemTime :: now ( ) . duration_since ( SystemTime :: UNIX_EPOCH ) . unwrap ( ) ,
364371 } ;
365372 self . tx_metadata
366- . insert ( PaymentId :: SelfCustodial ( chan_txid. to_byte_array ( ) ) , metadata) ;
373+ . insert ( PaymentId :: SelfCustodial ( chan_txid. to_byte_array ( ) ) , metadata)
374+ . await ;
367375 } ,
368376 }
369377 } )
0 commit comments