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
Rename txid
to compute_txid
#2366
Rename txid
to compute_txid
#2366
Conversation
Pull Request Test Coverage Report for Build 7630482955
💛 - Coveralls |
b81f8fc
to
b62d25e
Compare
bitcoin/src/blockdata/transaction.rs
Outdated
} | ||
|
||
#[deprecated(since = "0.31.0", note = "use compute_txid() instead")] | ||
#[doc(alias = "compute_txid")] |
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.
I thought we should add alias = "txid"
on the compute_txid
, so when someone types tx.txid
the LSP will suggest compute_txid
? But I might be wrong. @Kixunil might know better.
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.
ah oops, yeah that's an easy change. I don't currently use LSP so I don't care either way.
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.
@dpc yes, needs to be the other way around.
bitcoin/src/blockdata/transaction.rs
Outdated
} | ||
|
||
#[deprecated(since = "0.31.0", note = "use compute_txid() instead")] | ||
#[doc(alias = "compute_txid")] | ||
#[doc(hidden)] |
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.
doc(hidden)
seems unnecessary and might just confuse people. Deprecation message seems like enough. A docstring explaining to use new name seem more helpful.
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.
There's a lint that fails without doc(hidden)
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.
Yes, doc(hidden)
is wrong and so is the lint. Which lint is that? Just turn it off and I'll happily complain at the repo of whoever came up with such nonsense..
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.
The lint is defined here: https://github.com/rust-bitcoin/rust-bitcoin/blob/master/bitcoin/src/lib.rs#L36
#![warn(missing_docs)]
I could change the lint level, but I assumed it was put in place for a reason to ensure a good level of documentation. Ideally this lint wouldn't complain if there's a deprecated
attribute..
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.
Oh, I didn't notice you didn't write the documentation. You have to add documentation even when it's deprecated. Or maybe especially because people will read it to understand deprecation better, so write a good explanation there.
bitcoin/src/blockdata/transaction.rs
Outdated
@@ -773,7 +773,7 @@ impl Transaction { | |||
#[inline] |
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.
Why this commit? We have a CI job for this.
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.
Running cargo +nightly fmt
before the CI weekly job runs formats all files yet to be formatted by the CI job.
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.
Then just don't do it or only commit relevant changes.
bitcoin/src/blockdata/transaction.rs
Outdated
} | ||
|
||
#[deprecated(since = "0.31.0", note = "use compute_txid() instead")] | ||
#[doc(alias = "compute_txid")] |
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.
@dpc yes, needs to be the other way around.
bitcoin/src/blockdata/transaction.rs
Outdated
} | ||
|
||
#[deprecated(since = "0.31.0", note = "use compute_txid() instead")] | ||
#[doc(alias = "compute_txid")] | ||
#[doc(hidden)] |
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.
Yes, doc(hidden)
is wrong and so is the lint. Which lint is that? Just turn it off and I'll happily complain at the repo of whoever came up with such nonsense..
Oh, one more thing: the same applies to |
b62d25e
to
3c216ff
Compare
Renamed |
3c216ff
to
8068df2
Compare
8068df2
to
cb339a0
Compare
Computing the txid is computationally expensive, so rename the method accordingly.
Computing the wtxid is computationally expensive, so rename the method accordingly.
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.
One last typo, the rest looks good.
bitcoin/src/blockdata/transaction.rs
Outdated
@@ -679,11 +679,21 @@ impl Transaction { | |||
/// Maximum transaction weight for Bitcoin Core 25.0. | |||
pub const MAX_STANDARD_WEIGHT: Weight = Weight::from_wu(400_000); | |||
|
|||
/// Computes a "normalized TXID" which does not include any signatures. | |||
/// | |||
/// This method is deprecated. Use `ntxid` instead. |
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.
Use compute_ntxid
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.
Thanks, good catch.
cb339a0
to
7af3a58
Compare
Computing the ntxid is computationally expensive, so rename the method accordingly.
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 7af3a58
BTW we could arguably drop On the one hand it's an obscure non-standardized legacy thing. But on the other hand, when you are using pre-segwit transactions, it comes in handy. In any case, out of scope for this PR. |
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 7af3a58
Looks useful enough to me. |
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 7af3a58
Rename txid to compute_txid and mark txid as deprecated.
Closes #2363