Get block hash by its height#634
Conversation
danielabrozzoni
left a comment
There was a problem hiding this comment.
Concept ACK, a couple of comments
6f3528b to
0822cc0
Compare
|
@danielabrozzoni I have amended the code based on your recommendation. @evanlinjin I have also fixed the import issue. The test is passing for all blockchains but while testing against |
|
That looks like a spurious error... In CI, compact filters compilation is failing. You can reproduce with |
62b00fb to
d0efd4d
Compare
danielabrozzoni
left a comment
There was a problem hiding this comment.
utACK d0efd4d
just a small nit
| let block_hash = self.headers.get_block_hash(height as usize)?; | ||
| match block_hash { | ||
| Some(block_hash) => Ok(block_hash), | ||
| None => Err(Error::CompactFilters( | ||
| CompactFiltersError::BlockHashNotFound, | ||
| )), | ||
| } |
There was a problem hiding this comment.
nit: you can re-write this as
self.headers.get_block_hash(height as usize)?.ok_or(Error::CompactFilters(
CompactFiltersError::BlockHashNotFound,
))
ok_or makes it way more compact :)
d0efd4d to
2b6801b
Compare
|
Also, you have conflicts with the changelog :( |
2b6801b to
b985b12
Compare
|
@danielabrozzoni, thanks for pointing that out. Fixed! |
Create blockchain::GetBlockHash trait with a method to get block hash given a block height. Then, implement this trait for all backends (Electrum, RPC , Esplora, CBF). Referenced in issue 603.
b985b12 to
2af678a
Compare
notmandatory
left a comment
There was a problem hiding this comment.
ACK 2af678a
Looks good !
758dba1 Get block hash by its height (Vladimir Fomene) Pull request description: ### Description This PR create a new trait `blockchain::GetBlockHash` with a `get_block_hash` method which returns a block hash given the block height. This has been implemented for all blockchain backends. Fixes #603 ### Notes to the reviewers I haven't updated the `CHANGELOG.md` and docs. Am I suppose to update it for this change? ### Checklists #### All Submissions: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) * [x] I ran `cargo fmt` and `cargo clippy` before committing #### New Features: * [x] I've added tests for the new feature * [ ] I've added docs for the new feature * [ ] I've updated `CHANGELOG.md` ACKs for top commit: notmandatory: ACK 758dba1 Tree-SHA512: 9c084a6665ecbf27ee8170fdb06e0dc8373d6a901ce29e5f5a1bec111d1507cb3bee6b03a653a55fd20e0fabe7a5eada3353e24a1e21f3a11f01bb9881ae99e5
758dba18fd4c5f6d8db8ba51e34646fbb2302042 Get block hash by its height (Vladimir Fomene) Pull request description: ### Description This PR create a new trait `blockchain::GetBlockHash` with a `get_block_hash` method which returns a block hash given the block height. This has been implemented for all blockchain backends. Fixes #603 ### Notes to the reviewers I haven't updated the `CHANGELOG.md` and docs. Am I suppose to update it for this change? ### Checklists #### All Submissions: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) * [x] I ran `cargo fmt` and `cargo clippy` before committing #### New Features: * [x] I've added tests for the new feature * [ ] I've added docs for the new feature * [ ] I've updated `CHANGELOG.md` ACKs for top commit: notmandatory: ACK 758dba18fd4c5f6d8db8ba51e34646fbb2302042 Tree-SHA512: 9c084a6665ecbf27ee8170fdb06e0dc8373d6a901ce29e5f5a1bec111d1507cb3bee6b03a653a55fd20e0fabe7a5eada3353e24a1e21f3a11f01bb9881ae99e5

Description
This PR create a new trait
blockchain::GetBlockHashwith aget_block_hashmethod which returns a block hash given the block height. This has been implemented for all blockchain backends.Fixes #603
Notes to the reviewers
I haven't updated the
CHANGELOG.mdand docs. Am I suppose to update it for this change?Checklists
All Submissions:
cargo fmtandcargo clippybefore committingNew Features:
CHANGELOG.md