You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit introduces the handling and persistence of PeerStorage messages on a per-peer basis.
The peer storage is stored within the PeerState to simplify management, ensuring we do not need to remove it
when there are no active channels with the peer.
Key changes include:
- Add PeerStorage to PeerState for persistent storage.
- Implement internal_peer_storage to manage PeerStorage and its updates.
- Add resend logic in peer_connected() to resend PeerStorage before sending the channel reestablish message upon reconnection.
- Update PeerState's write() and read() methods to support PeerStorage persistence.
let per_peer_state = self.per_peer_state.read().unwrap();
8178
+
let peer_state_mutex = match per_peer_state.get(counterparty_node_id) {
8179
+
Some(peer_state_mutex) => peer_state_mutex,
8180
+
None => return,
8181
+
};
8182
+
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
8183
+
let peer_state = &mut *peer_state_lock;
8184
+
let logger = WithContext::from(&self.logger, Some(*counterparty_node_id), None, None);
8185
+
8186
+
// Check if we have any channels with the peer (Currently we only provide the servie to peers we have a channel with).
8187
+
if !peer_state.channel_by_id.values().any(|phase| phase.is_funded()) {
8188
+
log_debug!(logger, "We do not have any channel with {}", log_pubkey!(counterparty_node_id));
8189
+
return;
8190
+
}
8191
+
8192
+
#[cfg(not(test))]
8193
+
if msg.data.len() > 1024 {
8194
+
log_debug!(logger, "We do not allow more than 1 KiB of data for each peer in peer storage. Sending warning to peer {}", log_pubkey!(counterparty_node_id));
0 commit comments