-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mempool_p2p): create p2p sender and receiver
- Loading branch information
1 parent
669bb91
commit ea5e30d
Showing
1 changed file
with
21 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,32 @@ | ||
pub mod receiver; | ||
pub mod sender; | ||
|
||
use papyrus_network::gossipsub_impl::Topic; | ||
use papyrus_network::network_manager::{BroadcastTopicChannels, NetworkManager}; | ||
use papyrus_network::NetworkConfig; | ||
use starknet_gateway_types::communication::SharedGatewayClient; | ||
|
||
use crate::receiver::MempoolP2pReceiver; | ||
use crate::sender::MempoolP2pSender; | ||
|
||
pub fn create_p2p_sender_and_receiver( | ||
_network_config: NetworkConfig, | ||
network_config: NetworkConfig, | ||
gateway_client: SharedGatewayClient, | ||
version: Option<String>, | ||
buffer_size: usize, | ||
topic: Topic, | ||
) -> (MempoolP2pSender, MempoolP2pReceiver) { | ||
unimplemented!() | ||
let mut network_manager = NetworkManager::new(network_config, version); | ||
let BroadcastTopicChannels { broadcasted_messages_receiver, broadcast_topic_client } = | ||
network_manager | ||
.register_broadcast_topic(topic, buffer_size) | ||
.expect("Failed to register broadcast topic"); | ||
let mempool_p2p_sender = MempoolP2pSender::new(broadcast_topic_client.clone()); | ||
let mempool_p2p_receiver = MempoolP2pReceiver::new( | ||
Some(network_manager), | ||
broadcasted_messages_receiver, | ||
broadcast_topic_client, | ||
gateway_client, | ||
); | ||
(mempool_p2p_sender, mempool_p2p_receiver) | ||
} |