Skip to content

Commit 0dee04e

Browse files
Aditya SharmaAditya Sharma
Aditya Sharma
authored and
Aditya Sharma
committed
add to Handle peer storage message
1 parent 6c831ba commit 0dee04e

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

lightning/src/ln/channel.rs

+16-5
Original file line numberDiff line numberDiff line change
@@ -2109,11 +2109,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
21092109
self.channel_keys_id
21102110
}
21112111

2112-
pub fn increment_and_fetch_monitor_update_id(&mut self) -> u64 {
2113-
self.latest_monitor_update_id +=1;
2114-
self.latest_monitor_update_id
2115-
}
2116-
21172112
pub fn get_latest_monitor_update_id(&self) -> u64 {
21182113
self.latest_monitor_update_id
21192114
}
@@ -4544,6 +4539,22 @@ impl<SP: Deref> Channel<SP> where
45444539
return Ok(self.push_ret_blockable_mon_update(monitor_update));
45454540
}
45464541

4542+
/// Used to send LatestPeerStorage to the corresponding `ChannelMonitor`
4543+
pub fn update_peer_storage(&mut self, data: Vec<u8>) -> ChannelMonitorUpdate {
4544+
self.context.latest_monitor_update_id += 1;
4545+
let monitor_update = ChannelMonitorUpdate {
4546+
update_id: self.context.latest_monitor_update_id,
4547+
counterparty_node_id: None,
4548+
updates: vec![ChannelMonitorUpdateStep::LatestPeerStorage {
4549+
data,
4550+
}],
4551+
channel_id: Some(self.context.channel_id()),
4552+
};
4553+
self.monitor_updating_paused(false, false, false, Vec::new(), Vec::new(), Vec::new());
4554+
4555+
monitor_update
4556+
}
4557+
45474558
/// Public version of the below, checking relevant preconditions first.
45484559
/// If we're not in a state where freeing the holding cell makes sense, this is a no-op and
45494560
/// returns `(None, Vec::new())`.

lightning/src/ln/channelmanager.rs

+2-10
Original file line numberDiff line numberDiff line change
@@ -6789,17 +6789,9 @@ where
67896789
.iter_mut()
67906790
.min_by_key(|s| s.context.get_funding_txo().unwrap().get_txid())
67916791
.unwrap();
6792-
6792+
67936793
// Send ChannelMonitor Update.
6794-
let peer_storage_update = ChannelMonitorUpdate {
6795-
update_id: min_funded_chan.context.increment_and_fetch_monitor_update_id(),
6796-
counterparty_node_id: None,
6797-
updates: vec![ChannelMonitorUpdateStep::LatestPeerStorage {
6798-
data: msg.data.clone(),
6799-
}],
6800-
channel_id: Some(min_funded_chan.context.channel_id()),
6801-
};
6802-
6794+
let peer_storage_update = min_funded_chan.update_peer_storage(msg.data.clone());
68036795
// Update the store.
68046796
peer_state.peer_storage = msg.data.clone();
68056797

0 commit comments

Comments
 (0)