Skip to content

Allow to retrieve a block header by hash #17

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

Merged

Conversation

tnull
Copy link
Contributor

@tnull tnull commented Oct 6, 2022

Based on #13 since it probably land soon.

This PR adds a method allowing to retrieve a BlockHeader via a given BlockHash and reuses it in get_height.

@tnull tnull force-pushed the 2022-10-add-get-header-by-hash branch from f49cc93 to c13d0a6 Compare October 6, 2022 08:27
@coveralls
Copy link

coveralls commented Oct 6, 2022

Pull Request Test Coverage Report for Build 3228020364

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 7 of 11 (63.64%) changed or added relevant lines in 3 files are covered.
  • 63 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.5%) to 77.858%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/async.rs 1 3 33.33%
src/blocking.rs 1 3 33.33%
Files with Coverage Reduction New Missed Lines %
src/async.rs 21 81.4%
src/blocking.rs 42 59.13%
Totals Coverage Status
Change from base Build 3128702855: -0.5%
Covered Lines: 647
Relevant Lines: 831

💛 - Coveralls

@@ -128,23 +128,15 @@ impl BlockingClient {

/// Get a [`BlockHeader`] given a particular block height.
pub fn get_header(&self, block_height: u32) -> Result<BlockHeader, Error> {
Copy link
Contributor Author

@tnull tnull Oct 6, 2022

Choose a reason for hiding this comment

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

Not sure if we should rename it to get_header_by_height. Also, it's rather unfortunate that this is reliant on two consecutive calls, which might be race-y and take longer than the user expects. Maybe we could just scrap this and rather align the interface more with the actual Esplora API, i.e., letting the user implement this on its own?

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 on removing it. If anything, an API for getting a header by block_height should be implemented by Esplora, the library should just reflect what the Esplora API offers.

Copy link
Member

Choose a reason for hiding this comment

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

I agree get_header should be removed since it doesn't reflect an existing Esplora API. But since we have at least one user (bdk) can you just deprecate it for now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Deprecated with 68b9d2b.

@notmandatory
Copy link
Member

Overall looks good to me, but for the new functions would be good to have at least some simple tests added in lib.rs.

@tnull tnull force-pushed the 2022-10-add-get-header-by-hash branch from c13d0a6 to e010611 Compare October 11, 2022 15:09
@tnull
Copy link
Contributor Author

tnull commented Oct 11, 2022

Overall looks good to me, but for the new functions would be good to have at least some simple tests added in lib.rs.

Added a simple test case for get_block_by_height and removed the test for the now-deprecated get_height with e010611.

@tnull tnull force-pushed the 2022-10-add-get-header-by-hash branch from e010611 to 995aa79 Compare October 11, 2022 15:39
@tnull tnull force-pushed the 2022-10-add-get-header-by-hash branch from 995aa79 to 92606cc Compare October 12, 2022 17:50
@tnull
Copy link
Contributor Author

tnull commented Oct 12, 2022

Rebased on master after #13 landed.

@vladimirfomene vladimirfomene merged commit 98137c9 into bitcoindevkit:master Oct 13, 2022
@notmandatory notmandatory added this to the Release 0.2.0 milestone Oct 22, 2022
notmandatory added a commit that referenced this pull request Oct 31, 2022
3a93ee5 Fix deprecation version of `get_header` (Elias Rohrer)

Pull request description:

  In #17, we deprecated `get_header` and assumed the next version would be 0.1.2, but it turned out to be 0.2.

Top commit has no ACKs.

Tree-SHA512: 2b552730054def1dde12358527ef4c84fc225fe3359b41315318952162c8a28065620259212000bcd28364204f26b21f0e3586d5d231b11bf175db4954b813f7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants