Skip to content

Commit

Permalink
refactor: remove dead code
Browse files Browse the repository at this point in the history
The dispatcher doesn't use the history foldable because this code was
reimplemented in the authority-claimer service.
  • Loading branch information
gligneul committed Jan 24, 2024
1 parent 419a1ea commit 6499576
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 212 deletions.
6 changes: 0 additions & 6 deletions offchain/dispatcher/src/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,6 @@ pub async fn start(
);

let initial_state = RollupsInitialState {
history_address: config
.blockchain_config
.history_address
.clone()
.into_inner()
.into(),
input_box_address: config
.blockchain_config
.input_box_address
Expand Down
45 changes: 6 additions & 39 deletions offchain/types/src/foldables/authority/rollups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
// SPDX-License-Identifier: Apache-2.0 (see LICENSE)

use crate::{
foldables::{
claims::{History, HistoryInitialState},
input_box::{InputBox, InputBoxInitialState},
},
foldables::input_box::{InputBox, InputBoxInitialState},
FoldableError, UserData,
};

Expand All @@ -23,17 +20,13 @@ use std::sync::{Arc, Mutex};

#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
pub struct RollupsInitialState {
pub history_address: Address,
pub input_box_address: Address,
}

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct RollupsState {
pub input_box_initial_state: Arc<InputBoxInitialState>,
pub input_box: Arc<InputBox>,

pub history_initial_state: Arc<HistoryInitialState>,
pub history: Arc<History>,
}

#[async_trait]
Expand All @@ -48,34 +41,17 @@ impl Foldable for RollupsState {
env: &StateFoldEnvironment<M, Self::UserData>,
_access: Arc<SyncMiddleware<M>>,
) -> Result<Self, Self::Error> {
let (input_box_initial_state, history_initial_state) = {
let input_box_initial_state = {
let mut user_data = env
.user_data()
.lock()
.expect("Mutex should never be poisoned");

let i = {
let input_box_address =
user_data.get(initial_state.input_box_address);
Arc::new(InputBoxInitialState { input_box_address })
};

let h = {
let history_address =
user_data.get(initial_state.history_address);
Arc::new(HistoryInitialState { history_address })
};

(i, h)
let input_box_address =
user_data.get(initial_state.input_box_address);
Arc::new(InputBoxInitialState { input_box_address })
};

fetch_sub_foldables(
env,
block,
input_box_initial_state,
history_initial_state,
)
.await
fetch_sub_foldables(env, block, input_box_initial_state).await
}

async fn fold<M: Middleware + 'static>(
Expand All @@ -89,7 +65,6 @@ impl Foldable for RollupsState {
env,
block,
previous_state.input_box_initial_state.clone(),
previous_state.history_initial_state.clone(),
)
.await
}
Expand All @@ -99,7 +74,6 @@ async fn fetch_sub_foldables<M: Middleware + 'static>(
env: &StateFoldEnvironment<M, <RollupsState as Foldable>::UserData>,
block: &Block,
input_box_initial_state: Arc<InputBoxInitialState>,
history_initial_state: Arc<HistoryInitialState>,
) -> Result<RollupsState, <RollupsState as Foldable>::Error> {
// TODO: Change state-fold sync/fold to receive Arc<Block>
let block = QueryBlock::Block(Arc::new(block.clone()));
Expand All @@ -112,15 +86,8 @@ async fn fetch_sub_foldables<M: Middleware + 'static>(
.await?
.state;

let history = env
.get_state_for_block::<History>(&history_initial_state, block)
.await?
.state;

Ok(RollupsState {
input_box,
input_box_initial_state,
history,
history_initial_state,
})
}
166 changes: 0 additions & 166 deletions offchain/types/src/foldables/claims.rs

This file was deleted.

1 change: 0 additions & 1 deletion offchain/types/src/foldables/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@

pub mod authority;

pub mod claims;
pub mod input_box;

0 comments on commit 6499576

Please sign in to comment.