@@ -16,7 +16,7 @@ use crate::chain::chaininterface::ConfirmationTarget;
16
16
#[ cfg( test) ]
17
17
use crate :: chain:: chaininterface:: FEERATE_FLOOR_SATS_PER_KW ;
18
18
use crate :: chain:: chainmonitor;
19
- use crate :: chain:: chainmonitor:: { MonitorUpdateId , UpdateOrigin } ;
19
+ use crate :: chain:: chainmonitor:: { MonitorUpdateId } ;
20
20
use crate :: chain:: channelmonitor;
21
21
use crate :: chain:: channelmonitor:: MonitorEvent ;
22
22
use crate :: chain:: transaction:: OutPoint ;
@@ -516,7 +516,7 @@ pub struct TestPersister {
516
516
pub update_rets : Mutex < VecDeque < chain:: ChannelMonitorUpdateStatus > > ,
517
517
/// When we get an update_persisted_channel call with no ChannelMonitorUpdate, we insert the
518
518
/// MonitorUpdateId here.
519
- pub chain_sync_monitor_persistences : Mutex < HashMap < OutPoint , HashSet < MonitorUpdateId > > > ,
519
+ pub chain_sync_monitor_persistences : Mutex < VecDeque < OutPoint > > ,
520
520
/// When we get an update_persisted_channel call *with* a ChannelMonitorUpdate, we insert the
521
521
/// MonitorUpdateId here.
522
522
pub offchain_monitor_updates : Mutex < HashMap < OutPoint , HashSet < MonitorUpdateId > > > ,
@@ -525,7 +525,7 @@ impl TestPersister {
525
525
pub fn new ( ) -> Self {
526
526
Self {
527
527
update_rets : Mutex :: new ( VecDeque :: new ( ) ) ,
528
- chain_sync_monitor_persistences : Mutex :: new ( new_hash_map ( ) ) ,
528
+ chain_sync_monitor_persistences : Mutex :: new ( VecDeque :: new ( ) ) ,
529
529
offchain_monitor_updates : Mutex :: new ( new_hash_map ( ) ) ,
530
530
}
531
531
}
@@ -543,16 +543,16 @@ impl<Signer: sign::ecdsa::WriteableEcdsaChannelSigner> chainmonitor::Persist<Sig
543
543
chain:: ChannelMonitorUpdateStatus :: Completed
544
544
}
545
545
546
- fn update_persisted_channel ( & self , funding_txo : OutPoint , _update : Option < & channelmonitor:: ChannelMonitorUpdate > , _data : & channelmonitor:: ChannelMonitor < Signer > , update_id : MonitorUpdateId ) -> chain:: ChannelMonitorUpdateStatus {
546
+ fn update_persisted_channel ( & self , funding_txo : OutPoint , update : Option < & channelmonitor:: ChannelMonitorUpdate > , _data : & channelmonitor:: ChannelMonitor < Signer > , update_id : MonitorUpdateId ) -> chain:: ChannelMonitorUpdateStatus {
547
547
let mut ret = chain:: ChannelMonitorUpdateStatus :: Completed ;
548
548
if let Some ( update_ret) = self . update_rets . lock ( ) . unwrap ( ) . pop_front ( ) {
549
549
ret = update_ret;
550
550
}
551
- let is_chain_sync = if let UpdateOrigin :: ChainSync ( _) = update_id. contents { true } else { false } ;
552
- if is_chain_sync {
553
- self . chain_sync_monitor_persistences . lock ( ) . unwrap ( ) . entry ( funding_txo) . or_insert ( new_hash_set ( ) ) . insert ( update_id) ;
554
- } else {
551
+
552
+ if update. is_some ( ) {
555
553
self . offchain_monitor_updates . lock ( ) . unwrap ( ) . entry ( funding_txo) . or_insert ( new_hash_set ( ) ) . insert ( update_id) ;
554
+ } else {
555
+ self . chain_sync_monitor_persistences . lock ( ) . unwrap ( ) . push_back ( funding_txo) ;
556
556
}
557
557
ret
558
558
}
@@ -564,7 +564,7 @@ impl<Signer: sign::ecdsa::WriteableEcdsaChannelSigner> chainmonitor::Persist<Sig
564
564
None => {
565
565
// If the channel was not in the offchain_monitor_updates map, it should be in the
566
566
// chain_sync_monitor_persistences map.
567
- assert ! ( self . chain_sync_monitor_persistences. lock( ) . unwrap( ) . remove ( & funding_txo) . is_some ( ) ) ;
567
+ self . chain_sync_monitor_persistences . lock ( ) . unwrap ( ) . retain ( |x| x != & funding_txo) ;
568
568
}
569
569
} ;
570
570
}
0 commit comments