Skip to content

Commit 8bad333

Browse files
committed
Pass FinalityMode by value in executors
Derive copy on the enum as well.
1 parent febcd52 commit 8bad333

File tree

7 files changed

+16
-16
lines changed

7 files changed

+16
-16
lines changed

networks/monza/monza-full-node/src/partial.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ impl <T : MonzaExecutor + Send + Sync + Clone>MonzaPartialNode<T> {
166166
);
167167
let block_id = executable_block.block_id;
168168
self.executor.execute_block(
169-
&FinalityMode::Opt,
169+
FinalityMode::Opt,
170170
executable_block
171171
).await?;
172172

networks/suzuka/suzuka-full-node/src/partial.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ impl <T : SuzukaExecutor + Send + Sync + Clone>SuzukaPartialNode<T> {
166166
);
167167
let block_id = executable_block.block_id;
168168
self.executor.execute_block(
169-
&FinalityMode::Opt,
169+
FinalityMode::Opt,
170170
executable_block
171171
).await?;
172172

protocol-units/execution/maptos/util/src/finality_mode.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#[derive(Debug, Clone, PartialEq, Eq)]
1+
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
22
pub enum FinalityMode {
33
Dyn,
44
Opt,

protocol-units/execution/monza/executor/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub trait MonzaExecutor {
2424
/// Executes a block dynamically
2525
async fn execute_block(
2626
&self,
27-
mode : &FinalityMode,
27+
mode: FinalityMode,
2828
block: ExecutableBlock,
2929
) -> Result<(), anyhow::Error>;
3030

protocol-units/execution/monza/executor/src/v1.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl MonzaExecutor for MonzaExecutorV1 {
4343
/// Executes a block dynamically
4444
async fn execute_block(
4545
&self,
46-
mode: &FinalityMode,
46+
mode: FinalityMode,
4747
block: ExecutableBlock,
4848
) -> Result<(), anyhow::Error> {
4949
match mode {
@@ -131,15 +131,15 @@ mod tests {
131131

132132
#[tokio::test]
133133
async fn test_execute_opt_block() -> Result<(), anyhow::Error> {
134-
let (tx, rx) = async_channel::unbounded();
135-
let mut executor = MonzaExecutorV1::try_from_env(tx).await?;
134+
let (tx, _rx) = async_channel::unbounded();
135+
let executor = MonzaExecutorV1::try_from_env(tx).await?;
136136
let block_id = HashValue::random();
137137
let tx = SignatureVerifiedTransaction::Valid(Transaction::UserTransaction(
138138
create_signed_transaction(0),
139139
));
140140
let txs = ExecutableTransactions::Unsharded(vec![tx]);
141141
let block = ExecutableBlock::new(block_id.clone(), txs);
142-
executor.execute_block(&FinalityMode::Opt, block).await?;
142+
executor.execute_block(FinalityMode::Opt, block).await?;
143143
Ok(())
144144
}
145145

@@ -212,7 +212,7 @@ mod tests {
212212
SignatureVerifiedTransaction::Valid(Transaction::UserTransaction(received_transaction));
213213
let txs = ExecutableTransactions::Unsharded(vec![tx]);
214214
let block = ExecutableBlock::new(block_id.clone(), txs);
215-
executor.execute_block(&FinalityMode::Opt, block).await?;
215+
executor.execute_block(FinalityMode::Opt, block).await?;
216216

217217
services_handle.abort();
218218
background_handle.abort();
@@ -274,7 +274,7 @@ mod tests {
274274
));
275275
let txs = ExecutableTransactions::Unsharded(vec![tx]);
276276
let block = ExecutableBlock::new(block_id.clone(), txs);
277-
executor.execute_block(&FinalityMode::Opt, block).await?;
277+
executor.execute_block(FinalityMode::Opt, block).await?;
278278

279279
blockheight += 1;
280280
committed_blocks.insert(

protocol-units/execution/suzuka/executor/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub trait SuzukaExecutor {
2424
/// Executes a block dynamically
2525
async fn execute_block(
2626
&self,
27-
mode : &FinalityMode,
27+
mode: FinalityMode,
2828
block: ExecutableBlock,
2929
) -> Result<(), anyhow::Error>;
3030

protocol-units/execution/suzuka/executor/src/v1.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl SuzukaExecutor for SuzukaExecutorV1 {
4848
/// Executes a block dynamically
4949
async fn execute_block(
5050
&self,
51-
mode : &FinalityMode,
51+
mode: FinalityMode,
5252
block: ExecutableBlock,
5353
) -> Result<(), anyhow::Error> {
5454

@@ -137,15 +137,15 @@ mod opt_tests {
137137

138138
#[tokio::test]
139139
async fn test_execute_opt_block() -> Result<(), anyhow::Error> {
140-
let (tx, rx) = async_channel::unbounded();
141-
let mut executor = SuzukaExecutorV1::try_from_env(tx).await?;
140+
let (tx, _rx) = async_channel::unbounded();
141+
let executor = SuzukaExecutorV1::try_from_env(tx).await?;
142142
let block_id = HashValue::random();
143143
let tx = SignatureVerifiedTransaction::Valid(Transaction::UserTransaction(
144144
create_signed_transaction(0),
145145
));
146146
let txs = ExecutableTransactions::Unsharded(vec![tx]);
147147
let block = ExecutableBlock::new(block_id.clone(), txs);
148-
executor.execute_block(&FinalityMode::Opt, block).await?;
148+
executor.execute_block(FinalityMode::Opt, block).await?;
149149
Ok(())
150150
}
151151

@@ -228,7 +228,7 @@ mod opt_tests {
228228
));
229229
let txs = ExecutableTransactions::Unsharded(vec![tx]);
230230
let block = ExecutableBlock::new(block_id.clone(), txs);
231-
executor.execute_block(&FinalityMode::Opt, block).await?;
231+
executor.execute_block(FinalityMode::Opt, block).await?;
232232

233233
services_handle.abort();
234234
background_handle.abort();

0 commit comments

Comments
 (0)