Skip to content
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

feature: add block_headers and blocks streams full APIs (w/ checkpoint and reorg handling) #10

Merged
merged 18 commits into from
Aug 11, 2022

Conversation

oleonardolima
Copy link
Owner

@oleonardolima oleonardolima commented Jun 27, 2022

Description

This PR focus on solving the issues:

This PR refactors the project on top of the other two PRs:

It adds two main features (critical for the project):

  • adds the option to use a checkpoint (height: u32, hash: bitcoin::BlockHash), it fetches and emits all the blocks starting from the checkpoint (inclusive) up to the current tip and listens to all new blocks events from the WebSocket client.
  • it emits both BlockEvent::Connected() and BlockEvent::Disconnected() as it now handles block reorganization, it currently emits a disconnected event for all found stale blocks during reorganization, and a new connected event for the now active branch up to the tip.

This PR also adds documentation for the functions, structures, and enums and updates README examples and doc.rs examples.

Notes to the reviewers

If you would like to check out the other implementations before current updates and reactors, please check out PRs #3 and #8. I'm planning to close and squash them into this one to ease the reviews.

Checklists

All Submissions:

  • I've signed all my commits
  • I followed the contribution guidelines
  • I ran cargo fmt and cargo clippy before committing

New Features:

  • I've added tests for the new feature
  • I've added docs for the new feature
  • I've updated CHANGELOG.md

@oleonardolima oleonardolima force-pushed the feature/add-block-height-checkpoint-feature branch from 0ef1850 to c6492e0 Compare July 1, 2022 02:25
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Show resolved Hide resolved
@oleonardolima oleonardolima changed the title feature: add block height checkpoint feature feature: add block height checkpoint feature, and add reorganization handling Jul 6, 2022
@oleonardolima oleonardolima requested a review from LLFourn July 6, 2022 22:50
@oleonardolima oleonardolima self-assigned this Jul 6, 2022
@oleonardolima oleonardolima added the enhancement New feature or request label Jul 6, 2022
@oleonardolima oleonardolima added this to the milestone #1 milestone Jul 6, 2022
@oleonardolima oleonardolima marked this pull request as ready for review July 6, 2022 22:50
@oleonardolima oleonardolima changed the base branch from feature/add-unit-and-integration-tests-to-block-events to main July 7, 2022 00:06
- use TryStream instead of stream, returning result instead
- use `?` operator instead of unwraping and panicking
- add new mempool.space endpoints for http client
- add features for wss:// and https:// usage
- add features for api versioning based on mempool.space backend
@oleonardolima oleonardolima force-pushed the feature/add-block-height-checkpoint-feature branch from 4b05122 to 2b9e908 Compare July 26, 2022 13:15
…e error handling

- refactor and update http client, url usage and methods
- refactor and add creation methods for cache struct, use specific method to build
  initial one
- add `get_block_header` method in http client, and refactor lib to use `bitcoin::BlockHeader`
  instead of custom mempool.space `BlockExtended` struct
- refactor lib and websocket to improve error handling, update some `unwrap()` usage and
  match errors for messages in `WebSocketStream`
- remove duplicated/unused deps, and use only necessary features
@oleonardolima oleonardolima force-pushed the feature/add-block-height-checkpoint-feature branch from af3a572 to fa4775f Compare August 9, 2022 19:54
@oleonardolima oleonardolima changed the title feature: add block height checkpoint feature, and add reorganization handling feature: add block_headers and blocks streams APIs, block_height and checkpoint feature, and add reorganization handling Aug 9, 2022
@oleonardolima oleonardolima changed the title feature: add block_headers and blocks streams APIs, block_height and checkpoint feature, and add reorganization handling feature: add block_headers and blocks streams APIs, checkpoint feature, and add reorganization handling Aug 9, 2022
- bump mempool/backend docker container version to v2.4.1
- update api+websocket client to handle genesis blocks without prev_blockhash
- update and fix integration tests to new fns and structure
@oleonardolima oleonardolima force-pushed the feature/add-block-height-checkpoint-feature branch from 7bd795f to c52c1b4 Compare August 11, 2022 16:33
@oleonardolima oleonardolima changed the title feature: add block_headers and blocks streams APIs, checkpoint feature, and add reorganization handling feature: add block_headers and blocks streams full APIs (w/ checkpoint and reorg handling) Aug 11, 2022
@oleonardolima oleonardolima merged commit ee81d6a into main Aug 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

2 participants