Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TxPool ServiceBuilder and Context #456

Merged
merged 10 commits into from
Jul 8, 2022
22 changes: 14 additions & 8 deletions fuel-core/src/service/modules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ pub async fn start_modules(config: &Config, database: &Database) -> Result<Modul
let bft = fuel_core_bft::Service::new(&config.bft, db).await?;
let sync = fuel_sync::Service::new(&config.sync).await?;

// create builders
let mut relayer_builder = fuel_relayer::ServiceBuilder::new();
let mut txpool_builder = fuel_txpool::ServiceBuilder::new();

// initiate fields for builders
relayer_builder
.config(config.relayer.clone())
.db(Box::new(database.clone()) as Box<dyn RelayerDb>)
Expand All @@ -52,18 +56,18 @@ pub async fn start_modules(config: &Config, database: &Database) -> Result<Modul
.unwrap(),
);

let txpool = fuel_txpool::Service::new(
Box::new(database.clone()) as Box<dyn TxPoolDb>,
config.txpool.clone(),
)?;
txpool_builder
.config(config.txpool.clone())
.db(Box::new(database.clone()) as Box<dyn TxPoolDb>)
.import_block_event(block_importer.subscribe());

let p2p_mpsc = ();
let p2p_broadcast_consensus = ();
let p2p_broadcast_block = ();

block_importer.start().await;
txpool.start(block_importer.subscribe()).await;
block_producer.start(txpool.sender().clone()).await;

block_producer.start(txpool_builder.sender().clone()).await;
bft.start(
relayer_builder.sender().clone(),
p2p_broadcast_consensus,
Expand All @@ -82,11 +86,13 @@ pub async fn start_modules(config: &Config, database: &Database) -> Result<Modul
)
.await;

// build modules
// build services
let relayer = relayer_builder.build()?;
let txpool = txpool_builder.build()?;

// start modules
// start services
relayer.start().await?;
txpool.start().await?;

Ok(Modules {
txpool: Arc::new(txpool),
Expand Down
190 changes: 0 additions & 190 deletions fuel-txpool/src/interface.rs

This file was deleted.

6 changes: 2 additions & 4 deletions fuel-txpool/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
pub mod config;
mod containers;
pub use fuel_core_interfaces::txpool::Error;

mod interface;
pub mod service;
pub mod txpool;
pub mod types;

pub use config::Config;
pub use service::Service;
pub use fuel_core_interfaces::txpool::Error;
pub use service::{Service, ServiceBuilder};
pub use txpool::TxPool;
Loading