mirror of
https://github.com/Cuprate/cuprate.git
synced 2024-12-23 03:59:31 +00:00
add dandelion start function
This commit is contained in:
parent
adf592e530
commit
d2c7e49e80
2 changed files with 30 additions and 6 deletions
|
@ -1,26 +1,50 @@
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
|
use cuprate_dandelion_tower::pool::DandelionPoolService;
|
||||||
use cuprate_dandelion_tower::{DandelionConfig, DandelionRouter};
|
use cuprate_dandelion_tower::{DandelionConfig, DandelionRouter};
|
||||||
use cuprate_p2p::NetworkInterface;
|
use cuprate_p2p::NetworkInterface;
|
||||||
use cuprate_p2p_core::ClearNet;
|
use cuprate_p2p_core::ClearNet;
|
||||||
|
use cuprate_txpool::service::{TxpoolReadHandle, TxpoolWriteHandle};
|
||||||
use cuprate_wire::NetworkAddress;
|
use cuprate_wire::NetworkAddress;
|
||||||
|
|
||||||
mod diffuse_service;
|
mod diffuse_service;
|
||||||
mod stem_service;
|
mod stem_service;
|
||||||
mod tx_store;
|
mod tx_store;
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
struct DandelionTx(Bytes);
|
struct DandelionTx(Bytes);
|
||||||
|
|
||||||
type TxId = [u8; 32];
|
type TxId = [u8; 32];
|
||||||
|
|
||||||
pub fn start_dandelion_router(
|
type ConcreteDandelionRouter = DandelionRouter<
|
||||||
clear_net: NetworkInterface<ClearNet>,
|
|
||||||
) -> DandelionRouter<
|
|
||||||
stem_service::OutboundPeerStream,
|
stem_service::OutboundPeerStream,
|
||||||
diffuse_service::DiffuseService,
|
diffuse_service::DiffuseService,
|
||||||
NetworkAddress,
|
NetworkAddress,
|
||||||
stem_service::StemPeerService<ClearNet>,
|
stem_service::StemPeerService<ClearNet>,
|
||||||
DandelionTx,
|
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(
|
DandelionRouter::new(
|
||||||
diffuse_service::DiffuseService {
|
diffuse_service::DiffuseService {
|
||||||
clear_net_broadcast_service: clear_net.broadcast_svc(),
|
clear_net_broadcast_service: clear_net.broadcast_svc(),
|
||||||
|
|
|
@ -11,8 +11,8 @@ use tower::util::Oneshot;
|
||||||
use tower::{Service, ServiceExt};
|
use tower::{Service, ServiceExt};
|
||||||
|
|
||||||
pub struct TxStoreService {
|
pub struct TxStoreService {
|
||||||
txpool_read_handle: TxpoolReadHandle,
|
pub txpool_read_handle: TxpoolReadHandle,
|
||||||
txpool_write_handle: TxpoolWriteHandle,
|
pub txpool_write_handle: TxpoolWriteHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Service<TxStoreRequest<TxId>> for TxStoreService {
|
impl Service<TxStoreRequest<TxId>> for TxStoreService {
|
||||||
|
|
Loading…
Reference in a new issue