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

[gh-2589] add signatories as file suffix. #2641

Merged
merged 2 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions crates/rooch-types/src/transaction/rooch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ impl PartiallySignedRoochTransaction {
self.data.sender
}

pub fn signators(&self) -> usize {
self.authenticators.len()
}

pub fn contains_authenticator(&self, authenticator: &BitcoinAuthenticator) -> bool {
self.authenticators
.iter()
Expand Down
15 changes: 14 additions & 1 deletion crates/rooch/src/commands/transaction/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ impl FileOutputData {
}
}

pub fn file_count_suffix(&self) -> usize {
match self {
FileOutputData::RoochTransactionData(_) => 1,
FileOutputData::SignedRoochTransaction(_) => 1,
FileOutputData::PartiallySignedRoochTransaction(data) => data.signators(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only put the count suffix to psrt? The count of rtd and srt means less.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only put the count suffix to psrt? The count of rtd and srt means less.

The description of the issue only mentioned the psrt file.

Okay. I'll also put suffix to others.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've fixed it now.

}
}

pub fn file_suffix(&self) -> &str {
match self {
FileOutputData::RoochTransactionData(_) => "rtd",
Expand All @@ -50,7 +58,12 @@ impl FileOutputData {
pub fn default_output_file_path(&self) -> Result<PathBuf> {
let temp_dir = env::temp_dir();
let tx_hash = self.tx_hash();
let file_name = format!("{}.{}", hex::encode(&tx_hash[..8]), self.file_suffix());
let file_name = format!(
"{}.{}.{}",
hex::encode(&tx_hash[..8]),
self.file_count_suffix(),
self.file_suffix()
);
Ok(temp_dir.join(file_name))
}
}
Expand Down
Loading