Skip to content

Commit

Permalink
Fix clippy & fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
poplexity committed Oct 15, 2024
1 parent 768693b commit 116a8d9
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 20 deletions.
1 change: 1 addition & 0 deletions client/tests/ship_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ async fn evm_deploy() {
chain_endpoint: format!("http://localhost:{port_8888}"),
batch_size: 5,
prev_hash: B256::ZERO.to_string(),
last_legacy_raw_tx: None,
evm_start_block: 0,
validate_hash: None,
evm_stop_block: Some(60),
Expand Down
33 changes: 23 additions & 10 deletions translator/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,17 +175,30 @@ pub fn decode<T: Packer + Default>(raw: &[u8]) -> T {
result
}

pub struct ProcessingEVMBlockArgs {
pub chain_id: u64,
pub block_num: u32,
pub block_hash: Checksum256,
pub prev_block_hash: Option<Checksum256>,
pub lib_num: u32,
pub lib_hash: Checksum256,
pub result: GetBlocksResultV0,
pub use_legacy_raw_action: bool,
}

impl ProcessingEVMBlock {
pub fn new(
chain_id: u64,
block_num: u32,
block_hash: Checksum256,
prev_block_hash: Option<Checksum256>,
lib_num: u32,
lib_hash: Checksum256,
result: GetBlocksResultV0,
use_legacy_raw_action: bool,
) -> Self {
pub fn new(args: ProcessingEVMBlockArgs) -> Self {
let ProcessingEVMBlockArgs {
chain_id,
block_num,
block_hash,
prev_block_hash,
lib_num,
lib_hash,
result,
use_legacy_raw_action,
} = args;

Self {
block_num,
block_hash,
Expand Down
20 changes: 10 additions & 10 deletions translator/src/tasks/raw_deserializer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::block::ProcessingEVMBlock;
use crate::block::{ProcessingEVMBlock, ProcessingEVMBlockArgs};
use crate::translator::TranslatorConfig;
use crate::types::ship_types::ShipRequest::{GetBlocksAck, GetStatus};
use crate::types::ship_types::{
Expand Down Expand Up @@ -87,16 +87,16 @@ pub async fn raw_deserializer(
.last_legacy_raw_tx
.map(|n| b.block_num <= n)
.unwrap_or(false);
let block = ProcessingEVMBlock::new(
config.chain_id.0,
b.block_num,
b.block_id,
r.prev_block.as_ref().map(|b| b.block_id),
r.last_irreversible.block_num,
r.last_irreversible.block_id,
r.clone(),
let block = ProcessingEVMBlock::new(ProcessingEVMBlockArgs {
chain_id: config.chain_id.0,
block_num: b.block_num,
block_hash: b.block_id,
prev_block_hash: r.prev_block.as_ref().map(|b| b.block_id),
lib_num: r.last_irreversible.block_num,
lib_hash: r.last_irreversible.block_id,
result: r.clone(),
use_legacy_raw_action,
);
});
debug!("Block #{} sending to block deserializer...", b.block_num);
block_deserializer_tx.send(block).await?;
debug!("Block #{} sent to block deserializer", b.block_num);
Expand Down

0 comments on commit 116a8d9

Please sign in to comment.