Skip to content

Commit 144afec

Browse files
committed
docs(p2p/pubsub): rebroadcast webrtc message to libp2p peers
1 parent b5c83e8 commit 144afec

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

node/src/transition_frontier/transition_frontier_effects.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ fn synced_effects<S: crate::Service>(
307307
best_tip: best_tip.block.clone(),
308308
});
309309
}
310+
// rebroadcast block if received from webrtc network, otherwise noop.
310311
store.dispatch(P2pNetworkPubsubAction::WebRtcRebroadcast {
311312
message: GossipNetMessageV2::NewState(best_tip.block().clone()),
312313
});

p2p/src/channels/snark/p2p_channels_snark_reducer.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ impl P2pChannelsSnarkState {
226226
if is_local {
227227
dispatcher.push(P2pNetworkPubsubAction::Broadcast { message });
228228
} else {
229+
// rebroadcast snark if received from webrtc network, otherwise noop.
229230
dispatcher.push(P2pNetworkPubsubAction::WebRtcRebroadcast { message });
230231
}
231232
Ok(())

p2p/src/channels/transaction/p2p_channels_transaction_reducer.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ impl P2pChannelsTransactionState {
244244
if is_local {
245245
dispatcher.push(P2pNetworkPubsubAction::Broadcast { message });
246246
} else {
247+
// rebroadcast block if received from webrtc network, otherwise noop.
247248
dispatcher.push(P2pNetworkPubsubAction::WebRtcRebroadcast { message });
248249
}
249250
Ok(())

p2p/src/network/pubsub/p2p_network_pubsub_actions.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ pub enum P2pNetworkPubsubAction {
7878
},
7979

8080
/// Rebroadcast message received from WebRTC connection.
81+
///
82+
/// Expected to be dispatched after the message has been processed,
83+
/// in spite of whether it was received from libp2p or webrtc network.
84+
///
85+
/// If received from libp2p network, or if we have already broadcasted
86+
/// this message, the message will be in the `mcache` state,
87+
/// in which case the action won't be enabled (will be filtered out).
8188
WebRtcRebroadcast {
8289
message: GossipNetMessageV2,
8390
},

0 commit comments

Comments
 (0)