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

chore(da): improve struct documentation & naming #3187

Merged
merged 4 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions crates/rooch-types/src/da/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use moveos_types::h256;
use moveos_types::h256::{sha2_256_of, H256};
use serde::{Deserialize, Serialize};

#[derive(Eq, PartialEq, Hash, Deserialize, Serialize, Clone, Debug)]
/// The tx order range of the block.
#[derive(Eq, PartialEq, Hash, Deserialize, Serialize, Clone, Debug)]
pub struct BlockRange {
/// The Rooch block number for DA, each batch maps to a block
pub block_number: u128,
Expand All @@ -25,8 +25,8 @@ impl BlockRange {
}
}

#[derive(Eq, PartialEq, Hash, Deserialize, Serialize, Clone, Debug)]
/// The state of the block submission.
#[derive(Eq, PartialEq, Hash, Deserialize, Serialize, Clone, Debug)]
pub struct BlockSubmitState {
/// tx order range of the block
pub block_range: BlockRange,
Expand Down Expand Up @@ -67,8 +67,8 @@ impl BlockSubmitState {
}
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
/// Meta of DA batch
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
pub struct DABatchMeta {
/// tx order range of the block
pub block_range: BlockRange,
Expand Down Expand Up @@ -100,8 +100,8 @@ pub struct SignedDABatchMeta {
pub signature: Vec<u8>,
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
/// A batch is a collection of transactions. It is the unit of data flow in DA Stream
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
pub struct DABatch {
/// The metadata of the batch
pub meta: DABatchMeta,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ use std::path::PathBuf;

/// Index tx_order:tx_hash:block_number to a file from segments
#[derive(Debug, clap::Parser)]
pub struct IndexTxCommand {
#[clap(long = "segment-dir")]
pub struct IndexCommand {
#[clap(long = "segment-dir", short = 's')]
pub segment_dir: PathBuf,
#[clap(long = "output")]
pub output: PathBuf,
#[clap(long = "index", short = 'i')]
pub index_path: PathBuf,
}

impl IndexTxCommand {
impl IndexCommand {
pub fn execute(self) -> RoochResult<()> {
let ledger_tx_loader = LedgerTxGetter::new(self.segment_dir)?;
let mut block_number = ledger_tx_loader.get_min_chunk_id();
let mut expected_tx_order = 0;
let file = File::create(self.output.clone())?;
let file = File::create(self.index_path.clone())?;
let mut writer = BufWriter::with_capacity(8 * 1024 * 1024, file.try_clone().unwrap());

loop {
Expand Down
2 changes: 1 addition & 1 deletion crates/rooch/src/commands/da/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use std::sync::atomic::AtomicU64;
use tracing::info;

pub mod exec;
pub mod index_tx;
pub mod index;
pub mod namespace;
pub mod unpack;

Expand Down
6 changes: 3 additions & 3 deletions crates/rooch/src/commands/da/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub mod commands;

use crate::cli_types::CommandAction;
use crate::commands::da::commands::exec::ExecCommand;
use crate::commands::da::commands::index_tx::IndexTxCommand;
use crate::commands::da::commands::index::IndexCommand;
use crate::commands::da::commands::namespace::NamespaceCommand;
use crate::commands::da::commands::unpack::UnpackCommand;
use async_trait::async_trait;
Expand All @@ -26,7 +26,7 @@ impl CommandAction<String> for DA {
DACommand::Unpack(unpack) => unpack.execute().map(|_| "".to_owned()),
DACommand::Namespace(namespace) => namespace.execute().map(|_| "".to_owned()),
DACommand::Exec(exec) => exec.execute().await.map(|_| "".to_owned()),
DACommand::IndexTx(index_tx) => index_tx.execute().map(|_| "".to_owned()),
DACommand::Index(index) => index.execute().map(|_| "".to_owned()),
}
}
}
Expand All @@ -37,5 +37,5 @@ pub enum DACommand {
Unpack(UnpackCommand),
Namespace(NamespaceCommand),
Exec(Box<ExecCommand>),
IndexTx(IndexTxCommand),
Index(IndexCommand),
}
Loading