Skip to content

Commit

Permalink
feat(mempool_p2p): create p2p sender and receiver
Browse files Browse the repository at this point in the history
  • Loading branch information
eitanm-starkware committed Oct 13, 2024
1 parent 669bb91 commit ea5e30d
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions crates/mempool_p2p/src/lib.rs
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)
}

0 comments on commit ea5e30d

Please sign in to comment.