Skip to content

Commit

Permalink
feature: add block_headers and blocks streams full APIs (w/ check…
Browse files Browse the repository at this point in the history
…point and reorg handling) (#10)

* feature: implement an initial mempool.space websocket client, and library for block-events from #3

* feature: add unit and integration tests to block events from #8

* feat+test: add initial http client and tests

* wip(feat): add initial approach for subscribing to blocks from a starting height

* wip(feat): fix fn and use a tuple as return type for prev and new block streams

* wip(refactor): initial updates for fns refactor and architecture change

* wip(feat+refactor): add fn to process candidate BlockHeaders, handle reorg and yield BlockEvent

* wip(refactor+docs): extract fns to cache struct, and add documentation for fns, enums and structs

* wip(fixes+tests): fixes, improve error handling and add new integration tests

* wip(fix+test): fix common ancestor and fork branch bug, add new reorg tests

* fix: disconnected and connected block events emitting order for reorg events

* chore: simplify cli usage and output

* chore: update docs and readme examples, use u32 instead of u64

* fix: remaining cargo.toml conflicts from other branches

* feat: add full block stream api, better error handling
- 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

* refactor: do not use features expect two base_url instead, and improve 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

* chore: add and update CHANGELOG.md file

* fix(test): docs and integration tests

- 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
  • Loading branch information
oleonardolima authored Aug 11, 2022
1 parent a53082c commit ee81d6a
Show file tree
Hide file tree
Showing 12 changed files with 2,751 additions and 210 deletions.
30 changes: 30 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!-- You can erase any parts of this template not applicable to your Pull Request. -->

### Description

<!-- Describe the purpose of this PR, what's being adding and/or fixed -->

### Notes to the reviewers

<!-- In this section you can include notes directed to the reviewers, like explaining why some parts
of the PR were done in a specific way -->

### Checklists

#### All Submissions:

* [ ] I've signed all my commits
* [ ] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
* [ ] 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`

#### Bugfixes:

* [ ] This pull request breaks the existing API
* [ ] I've added tests to reproduce the issue which are now passing
* [ ] I'm linking the issue being fixed by this PR
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
- Add `block_events::websocket` client, and a `websocket::listen_new_block_headers` fn to get a stream of websocket messages.
- Add `block_events::http` client, and multiple fns to consume data from mempool.space and/or esplora REST APIs.
- Add `block_events::api` with multiple structs and definition for responses, such as: `BlockExtended` and events as `BlockEvent`
- Add `block_events::subscribe_to_block_headers` fn in order to return a `Stream` of `block_events::api::BlockEvent(bitcoin::BlockHeader)`.
- Add `block_events::process_blocks` to handle block reorganization, manage in-memory cache struct `BlockHeadersCache`, and propagate errors to caller.
- Add `block_events::subscribe_to_blocks` fn in order to return a `Stream` of `block_events::api::BlockEvent(bitcoin::Block)`.
Loading

0 comments on commit ee81d6a

Please sign in to comment.