-
Notifications
You must be signed in to change notification settings - Fork 22
fix: no Debug
on Display
implementations
#12
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
base: master
Are you sure you want to change the base?
fix: no Debug
on Display
implementations
#12
Conversation
Pull Request Test Coverage Report for Build 14539669521Details
💛 - Coveralls |
nit: should we consider changing |
ACK 6e521c9 (compiled the code and ran the tests) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cACK 6e521c9
No, because we're using the |
6e521c9
to
0ae48b1
Compare
0ae48b1
to
0d8d0ec
Compare
Rebased with suggestions from @ValuedMammal on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 0d8d0ec
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 0d8d0ec
Just a small nit.
/// Helper function to display basic information about a [`ChangeSet`]. | ||
fn changeset_info(changeset: &ChangeSet) -> String { | ||
let network = match &changeset.network { | ||
Some(network) => network.to_string(), | ||
None => "None".to_string(), | ||
}; | ||
|
||
let mut checksum = String::new(); | ||
if let Some(desc) = &changeset.descriptor { | ||
if let Ok(ck) = calc_checksum(&desc.to_string()) { | ||
checksum += ck.as_str(); | ||
} | ||
} | ||
if let Some(desc) = &changeset.change_descriptor { | ||
if let Ok(ck) = calc_checksum(&desc.to_string()) { | ||
checksum += ck.as_str(); | ||
} | ||
} | ||
// Don't return an empty checksum | ||
if checksum.is_empty() { | ||
checksum = "None".to_string(); | ||
} | ||
|
||
format!("Network: {}, Descriptor Checksum: {}", network, checksum) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: change signature of this to take in f: &mut fmt::Formatter
instead.
Also:
- Separate out the descriptor checksums. `descriptor_checksum={}, change_descriptor_checksum={}.
- All more info:
tx_count
,anchor_count
,block_count
, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think @evanlinjin? cc @ValuedMammal
/// Helper function to display basic information about a [`ChangeSet`].
fn changeset_info(f: &mut fmt::Formatter<'_>, changeset: &ChangeSet) -> fmt::Result {
let network = changeset.network
.as_ref()
.map_or("None".to_string(), |n| n.to_string());
let descriptor_checksum = changeset.descriptor
.as_ref()
.and_then(|d| calc_checksum(&d.to_string()).ok())
.unwrap_or_else(|| "None".to_string());
let change_descriptor_checksum = changeset.change_descriptor
.as_ref()
.and_then(|d| calc_checksum(&d.to_string()).ok())
.unwrap_or_else(|| "None".to_string());
let tx_count = changeset.tx_graph.txs.len();
let anchor_count = changeset.tx_graph.anchors.len();
let block_count = if let Some(&count) = changeset.local_chain.blocks.keys().last() {
count
} else {
0
};
writeln!(f, "")?;
writeln!(f, "Network: {}", network)?;
writeln!(f, "Descriptor Checksum: {}", descriptor_checksum)?;
writeln!(f, "Change Descriptor Checksum: {}", change_descriptor_checksum)?;
writeln!(f, "Transaction Count: {}", tx_count)?;
writeln!(f, "Anchor Count: {}", anchor_count)?;
writeln!(f, "Block Count: {}", block_count)?;
Ok(())
}
Then it gets called by CreateWithPersistError
like this:
impl<E: fmt::Display> fmt::Display for CreateWithPersistError<E> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Persist(err) => write!(f, "{}", err),
Self::DataAlreadyExists(changeset) => {
write!(f, "Cannot create wallet in a persister which already contains data: ")?;
changeset_info(f, changeset)
}
Self::Descriptor(err) => {
write!(f, "{err}")
}
}
}
}
Description
This PR removes the use of debugs on
Display
implemetations.Changelog notice
CreateTxError::LockTime
arm hadrequested
andrequired
inverted, now fixed.Checklists
All Submissions:
cargo fmt
andcargo clippy
before committing