Skip to content

Commit

Permalink
node: change LongLivedService trait
Browse files Browse the repository at this point in the history
- Add default `initialize` implementation
  • Loading branch information
herr-seppia committed Aug 2, 2024
1 parent 36b8ba6 commit bff23f9
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 28 deletions.
9 changes: 0 additions & 9 deletions node/src/databroker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,6 @@ impl DataBrokerSrv {
impl<N: Network, DB: database::DB, VM: vm::VMExecution>
LongLivedService<N, DB, VM> for DataBrokerSrv
{
async fn initialize(
&mut self,
_network: Arc<RwLock<N>>,
_db: Arc<RwLock<DB>>,
_vm: Arc<RwLock<VM>>,
) -> anyhow::Result<()> {
Ok(())
}

async fn execute(
&mut self,
network: Arc<RwLock<N>>,
Expand Down
5 changes: 4 additions & 1 deletion node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,15 @@ pub trait Network: Send + Sync + 'static {
pub trait LongLivedService<N: Network, DB: database::DB, VM: vm::VMExecution>:
Send + Sync
{
#[allow(unused_variables)]
async fn initialize(
&mut self,
network: Arc<RwLock<N>>,
database: Arc<RwLock<DB>>,
vm: Arc<RwLock<VM>>,
) -> anyhow::Result<()>;
) -> anyhow::Result<()> {
Ok(())
}

async fn execute(
&mut self,
Expand Down
9 changes: 0 additions & 9 deletions node/src/mempool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,6 @@ impl Default for MempoolSrv {
impl<N: Network, DB: database::DB, VM: vm::VMExecution>
LongLivedService<N, DB, VM> for MempoolSrv
{
async fn initialize(
&mut self,
_network: Arc<RwLock<N>>,
_db: Arc<RwLock<DB>>,
_vm: Arc<RwLock<VM>>,
) -> anyhow::Result<()> {
Ok(())
}

async fn execute(
&mut self,
network: Arc<RwLock<N>>,
Expand Down
9 changes: 0 additions & 9 deletions node/src/telemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,6 @@ impl<N: Network, DB: database::DB, VM: vm::VMExecution>
"telemetry"
}

async fn initialize(
&mut self,
_network: Arc<RwLock<N>>,
_db: Arc<RwLock<DB>>,
_vm: Arc<RwLock<VM>>,
) -> anyhow::Result<()> {
Ok(())
}

/// Initialize and spawn Prometheus Exporter and Recorder
async fn execute(
&mut self,
Expand Down

0 comments on commit bff23f9

Please sign in to comment.