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
refactor(devimint): add get_block_count to bitcoind #3898
refactor(devimint): add get_block_count to bitcoind #3898
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #3898 +/- ##
==========================================
+ Coverage 56.94% 56.99% +0.05%
==========================================
Files 193 193
Lines 42740 42743 +3
==========================================
+ Hits 24337 24361 +24
+ Misses 18403 18382 -21 ☔ View full report in Codecov by Sentry. |
/// blocks, where bitcoind's rpc returns the height. Since the genesis | ||
/// block has height 0, we need to add 1 to get the total block count. | ||
pub fn get_block_count(&self) -> Result<u64> { | ||
Ok(self.client().get_block_count()? + 1) |
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.
We already account for that afaik:
fedimint/fedimint-bitcoind/src/bitcoincore.rs
Lines 56 to 61 in 747585f
async fn get_block_count(&self) -> anyhow::Result<u64> { | |
// The RPC function is confusingly named and actually returns the block height | |
block_in_place(|| self.0.get_block_count()) | |
.map(|height| height + 1) | |
.map_err(anyhow::Error::from) | |
} |
Maybe something else is wrong?
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 also found this a bit confusing. The client for Bitcoind
in devimint external uses bitcoincore_rpc::Client
instead of IBitcoindRpc
, so we're essentially duplicating impl.
Should we consider changing the devimint external client to IBitcoindRpc
? If so, I can create an issue.
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.
Hmm, on further thought I'm not sure it's a good idea to switch to IBitcoindRpc
in devimint external. We rely on accessing several methods from bitcoind's rpc that would make unifying with IBitcoindRpc
pretty messy.
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, then nevermind.
Followup for #3893 (comment)