-
Notifications
You must be signed in to change notification settings - Fork 417
fix: no Debug on Display implementations
#2083
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
Open
Dmenec
wants to merge
5
commits into
bitcoindevkit:master
Choose a base branch
from
Dmenec:fix/no-debug-on-display-impls
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
52c20ba
fix: remove Debug usage and implement Display for InsertDescriptorError
Dmenec 566a592
docs: add detailed SyncRequest output example
Dmenec 2d4510a
fix: remove Debug usage and implement Display for CalculateFeeError
Dmenec 875b5e9
fix: remove Debug usage and implement Display for StoreError.
Dmenec b73016e
fix(no_std): replace std::string with alloc::string for compatibility
Dmenec File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -10,7 +10,7 @@ use crate::{ | |||||
| spk_txout::SpkTxOutIndex, | ||||||
| DescriptorExt, DescriptorId, Indexed, Indexer, KeychainIndexed, SpkIterator, | ||||||
| }; | ||||||
| use alloc::{borrow::ToOwned, vec::Vec}; | ||||||
| use alloc::{borrow::ToOwned, string::String, string::ToString, vec::Vec}; | ||||||
| use bitcoin::{ | ||||||
| key::Secp256k1, Amount, OutPoint, Script, ScriptBuf, SignedAmount, Transaction, TxOut, Txid, | ||||||
| }; | ||||||
|
|
@@ -973,33 +973,47 @@ pub enum InsertDescriptorError<K> { | |||||
| }, | ||||||
| } | ||||||
|
|
||||||
| impl<K: core::fmt::Debug> core::fmt::Display for InsertDescriptorError<K> { | ||||||
| /// Returns a shortened string representation of a descriptor. | ||||||
| /// Shows the first and last `edge_len` characters, separated by `...`. | ||||||
| fn short_descriptor(desc: &Descriptor<DescriptorPublicKey>, edge_len: usize) -> String { | ||||||
| let s = ToString::to_string(desc); | ||||||
| if s.len() <= edge_len * 2 { | ||||||
| return s; | ||||||
| } | ||||||
| format!("{}...{}", &s[..edge_len], &s[s.len() - edge_len..]) | ||||||
| } | ||||||
|
|
||||||
| impl<K: core::fmt::Display> core::fmt::Display for InsertDescriptorError<K> { | ||||||
| fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||||||
| match self { | ||||||
| InsertDescriptorError::DescriptorAlreadyAssigned { | ||||||
| existing_assignment: existing, | ||||||
| existing_assignment, | ||||||
| descriptor, | ||||||
| } => { | ||||||
| let short_desc = short_descriptor(descriptor, 4); | ||||||
| write!( | ||||||
| f, | ||||||
| "attempt to re-assign descriptor {descriptor:?} already assigned to {existing:?}" | ||||||
| "Descriptor '{}' is already in use by keychain '{}'. Please use a different descriptor.", | ||||||
| short_desc, existing_assignment | ||||||
| ) | ||||||
| } | ||||||
| InsertDescriptorError::KeychainAlreadyAssigned { | ||||||
| existing_assignment: existing, | ||||||
| existing_assignment, | ||||||
| keychain, | ||||||
| } => { | ||||||
| let short_desc = short_descriptor(existing_assignment, 4); | ||||||
| write!( | ||||||
| f, | ||||||
| "attempt to re-assign keychain {keychain:?} already assigned to {existing:?}" | ||||||
| "Keychain '{}' is already associated with descriptor '{}'. Please choose a different keychain.", | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit
Suggested change
|
||||||
| keychain, short_desc | ||||||
| ) | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| #[cfg(feature = "std")] | ||||||
| impl<K: core::fmt::Debug> std::error::Error for InsertDescriptorError<K> {} | ||||||
| impl<K: core::fmt::Display + core::fmt::Debug> std::error::Error for InsertDescriptorError<K> {} | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Technically this is a breaking change, so it should be reflected in the commit message ( |
||||||
|
|
||||||
| /// `ChangeSet` represents persistent updates to a [`KeychainTxOutIndex`]. | ||||||
| /// | ||||||
|
|
||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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