@@ -51,7 +51,7 @@ use crate::sync::RwLock;
5151use crate :: types:: features:: { ChannelFeatures , InitFeatures , NodeFeatures } ;
5252use crate :: util:: config:: UserConfig ;
5353use crate :: util:: logger:: { Logger , Record } ;
54- use crate :: util:: persist:: KVStore ;
54+ use crate :: util:: persist:: { KVStore , MonitorName } ;
5555use crate :: util:: ser:: { Readable , ReadableArgs , Writeable , Writer } ;
5656use crate :: util:: test_channel_signer:: { EnforcementState , TestChannelSigner } ;
5757
@@ -663,8 +663,11 @@ impl<Signer: sign::ecdsa::EcdsaChannelSigner> Persist<Signer> for WatchtowerPers
663663 res
664664 }
665665
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+ ) ;
668671 }
669672}
670673
@@ -674,10 +677,10 @@ pub struct TestPersister {
674677 pub update_rets : Mutex < VecDeque < chain:: ChannelMonitorUpdateStatus > > ,
675678 /// When we get an update_persisted_channel call *with* a ChannelMonitorUpdate, we insert the
676679 /// [`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 > > > ,
678681 /// When we get an update_persisted_channel call with no ChannelMonitorUpdate, we insert the
679682 /// monitor's funding outpoint here.
680- pub chain_sync_monitor_persistences : Mutex < VecDeque < ChannelId > > ,
683+ pub chain_sync_monitor_persistences : Mutex < VecDeque < MonitorName > > ,
681684}
682685impl TestPersister {
683686 pub fn new ( ) -> Self {
@@ -710,23 +713,24 @@ impl<Signer: sign::ecdsa::EcdsaChannelSigner> Persist<Signer> for TestPersister
710713 ret = update_ret;
711714 }
712715
716+ let monitor_name = data. persistence_key ( ) ;
713717 if let Some ( update) = update {
714718 self . offchain_monitor_updates
715719 . lock ( )
716720 . unwrap ( )
717- . entry ( data . channel_id ( ) )
721+ . entry ( monitor_name )
718722 . or_insert ( new_hash_set ( ) )
719723 . insert ( update. update_id ) ;
720724 } 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 ) ;
722726 }
723727 ret
724728 }
725729
726- fn archive_persisted_channel ( & self , data : & ChannelMonitor < Signer > ) {
730+ fn archive_persisted_channel ( & self , monitor_name : MonitorName ) {
727731 // 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 ) ;
730734 }
731735}
732736
0 commit comments