add dandelion start function

This commit is contained in:
Boog900 2024-10-10 21:14:22 +01:00
parent adf592e530
commit d2c7e49e80
No known key found for this signature in database
GPG key ID: 42AB1287CB0041C2
2 changed files with 30 additions and 6 deletions

View file

@ -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<ClearNet>,
) -> DandelionRouter<
type ConcreteDandelionRouter = DandelionRouter<
stem_service::OutboundPeerStream,
diffuse_service::DiffuseService,
NetworkAddress,
stem_service::StemPeerService<ClearNet>,
DandelionTx,
> {
>;
pub fn start_dandelion_pool_manager(
router: ConcreteDandelionRouter,
txpool_read_handle: TxpoolReadHandle,
txpool_write_handle: TxpoolWriteHandle,
) -> DandelionPoolService<DandelionTx, TxId, NetworkAddress> {
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<ClearNet>) -> ConcreteDandelionRouter {
DandelionRouter::new(
diffuse_service::DiffuseService {
clear_net_broadcast_service: clear_net.broadcast_svc(),

View file

@ -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<TxStoreRequest<TxId>> for TxStoreService {