@@ -51,7 +51,7 @@ use crate::sync::RwLock;
51
51
use crate :: types:: features:: { ChannelFeatures , InitFeatures , NodeFeatures } ;
52
52
use crate :: util:: config:: UserConfig ;
53
53
use crate :: util:: logger:: { Logger , Record } ;
54
- use crate :: util:: persist:: KVStore ;
54
+ use crate :: util:: persist:: { KVStore , MonitorName } ;
55
55
use crate :: util:: ser:: { Readable , ReadableArgs , Writeable , Writer } ;
56
56
use crate :: util:: test_channel_signer:: { EnforcementState , TestChannelSigner } ;
57
57
@@ -663,8 +663,11 @@ impl<Signer: sign::ecdsa::EcdsaChannelSigner> Persist<Signer> for WatchtowerPers
663
663
res
664
664
}
665
665
666
- fn archive_persisted_channel ( & self , data : & ChannelMonitor < Signer > ) {
667
- self . persister . archive_persisted_channel ( data) ;
666
+ fn archive_persisted_channel ( & self , monitor_name : MonitorName ) {
667
+ <TestPersister as Persist < TestChannelSigner > >:: archive_persisted_channel (
668
+ & self . persister ,
669
+ monitor_name,
670
+ ) ;
668
671
}
669
672
}
670
673
@@ -674,10 +677,10 @@ pub struct TestPersister {
674
677
pub update_rets : Mutex < VecDeque < chain:: ChannelMonitorUpdateStatus > > ,
675
678
/// When we get an update_persisted_channel call *with* a ChannelMonitorUpdate, we insert the
676
679
/// [`ChannelMonitor::get_latest_update_id`] here.
677
- pub offchain_monitor_updates : Mutex < HashMap < ChannelId , HashSet < u64 > > > ,
680
+ pub offchain_monitor_updates : Mutex < HashMap < MonitorName , HashSet < u64 > > > ,
678
681
/// When we get an update_persisted_channel call with no ChannelMonitorUpdate, we insert the
679
682
/// monitor's funding outpoint here.
680
- pub chain_sync_monitor_persistences : Mutex < VecDeque < ChannelId > > ,
683
+ pub chain_sync_monitor_persistences : Mutex < VecDeque < MonitorName > > ,
681
684
}
682
685
impl TestPersister {
683
686
pub fn new ( ) -> Self {
@@ -710,23 +713,24 @@ impl<Signer: sign::ecdsa::EcdsaChannelSigner> Persist<Signer> for TestPersister
710
713
ret = update_ret;
711
714
}
712
715
716
+ let monitor_name = data. persistence_key ( ) ;
713
717
if let Some ( update) = update {
714
718
self . offchain_monitor_updates
715
719
. lock ( )
716
720
. unwrap ( )
717
- . entry ( data . channel_id ( ) )
721
+ . entry ( monitor_name )
718
722
. or_insert ( new_hash_set ( ) )
719
723
. insert ( update. update_id ) ;
720
724
} else {
721
- self . chain_sync_monitor_persistences . lock ( ) . unwrap ( ) . push_back ( data . channel_id ( ) ) ;
725
+ self . chain_sync_monitor_persistences . lock ( ) . unwrap ( ) . push_back ( monitor_name ) ;
722
726
}
723
727
ret
724
728
}
725
729
726
- fn archive_persisted_channel ( & self , data : & ChannelMonitor < Signer > ) {
730
+ fn archive_persisted_channel ( & self , monitor_name : MonitorName ) {
727
731
// remove the channel from the offchain_monitor_updates and chain_sync_monitor_persistences.
728
- self . offchain_monitor_updates . lock ( ) . unwrap ( ) . remove ( & data . channel_id ( ) ) ;
729
- self . chain_sync_monitor_persistences . lock ( ) . unwrap ( ) . retain ( |x| x != & data . channel_id ( ) ) ;
732
+ self . offchain_monitor_updates . lock ( ) . unwrap ( ) . remove ( & monitor_name ) ;
733
+ self . chain_sync_monitor_persistences . lock ( ) . unwrap ( ) . retain ( |x| x != & monitor_name ) ;
730
734
}
731
735
}
732
736
0 commit comments