From d2c7e49e8014e34c4971d69d1ad29c59f1818cb1 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Thu, 10 Oct 2024 21:14:22 +0100 Subject: [PATCH] add dandelion start function --- binaries/cuprated/src/txpool/dandelion.rs | 32 ++++++++++++++++--- .../cuprated/src/txpool/dandelion/tx_store.rs | 4 +-- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/binaries/cuprated/src/txpool/dandelion.rs b/binaries/cuprated/src/txpool/dandelion.rs index 47d1ca38..27f1f79d 100644 --- a/binaries/cuprated/src/txpool/dandelion.rs +++ b/binaries/cuprated/src/txpool/dandelion.rs @@ -1,26 +1,50 @@ use bytes::Bytes; +use cuprate_dandelion_tower::pool::DandelionPoolService; use cuprate_dandelion_tower::{DandelionConfig, DandelionRouter}; use cuprate_p2p::NetworkInterface; use cuprate_p2p_core::ClearNet; +use cuprate_txpool::service::{TxpoolReadHandle, TxpoolWriteHandle}; use cuprate_wire::NetworkAddress; mod diffuse_service; mod stem_service; mod tx_store; +#[derive(Clone)] struct DandelionTx(Bytes); type TxId = [u8; 32]; -pub fn start_dandelion_router( - clear_net: NetworkInterface, -) -> DandelionRouter< +type ConcreteDandelionRouter = DandelionRouter< stem_service::OutboundPeerStream, diffuse_service::DiffuseService, NetworkAddress, stem_service::StemPeerService, DandelionTx, -> { +>; + +pub fn start_dandelion_pool_manager( + router: ConcreteDandelionRouter, + txpool_read_handle: TxpoolReadHandle, + txpool_write_handle: TxpoolWriteHandle, +) -> DandelionPoolService { + cuprate_dandelion_tower::pool::start_dandelion_pool_manager( + 12, + router, + tx_store::TxStoreService { + txpool_read_handle, + txpool_write_handle, + }, + DandelionConfig { + time_between_hop: Default::default(), + epoch_duration: Default::default(), + fluff_probability: 0.0, + graph: Default::default(), + }, + ) +} + +pub fn dandelion_router(clear_net: NetworkInterface) -> ConcreteDandelionRouter { DandelionRouter::new( diffuse_service::DiffuseService { clear_net_broadcast_service: clear_net.broadcast_svc(), diff --git a/binaries/cuprated/src/txpool/dandelion/tx_store.rs b/binaries/cuprated/src/txpool/dandelion/tx_store.rs index 98de764b..29f719e5 100644 --- a/binaries/cuprated/src/txpool/dandelion/tx_store.rs +++ b/binaries/cuprated/src/txpool/dandelion/tx_store.rs @@ -11,8 +11,8 @@ use tower::util::Oneshot; use tower::{Service, ServiceExt}; pub struct TxStoreService { - txpool_read_handle: TxpoolReadHandle, - txpool_write_handle: TxpoolWriteHandle, + pub txpool_read_handle: TxpoolReadHandle, + pub txpool_write_handle: TxpoolWriteHandle, } impl Service> for TxStoreService {