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 {