-
Notifications
You must be signed in to change notification settings - Fork 436
lightning-block-sync: switch to bitreq, drop chunked_transfer #4350
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
Open
Apostlex0
wants to merge
6
commits into
lightningdevkit:main
Choose a base branch
from
Apostlex0:feat/blocks-sync-bitreq
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1f77a33
lightning-block-sync: switch to bitreq, drop chunked_transfer
Apostlex0 8f732f2
fix: changes realted to bitreq usage.
Apostlex0 ab30823
ci fix
Apostlex0 1b6b0a1
api updates
Apostlex0 a4afede
fmt
Apostlex0 d274f6f
Remove unnecessary tests from http.rs
Apostlex0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
| use crate::http::{BinaryResponse, JsonResponse}; | ||
| use crate::http::{BinaryResponse, HttpClientError, JsonResponse}; | ||
| #[cfg(feature = "rpc-client")] | ||
| use crate::rpc::RpcClientError; | ||
| use crate::utils::hex_to_work; | ||
| use crate::{BlockHeaderData, BlockSourceError}; | ||
|
|
||
|
|
@@ -35,6 +37,48 @@ impl From<io::Error> for BlockSourceError { | |
| } | ||
| } | ||
|
|
||
| /// Conversion from `HttpClientError` into `BlockSourceError`. | ||
| impl From<HttpClientError> for BlockSourceError { | ||
| fn from(e: HttpClientError) -> BlockSourceError { | ||
| match &e { | ||
| // Transport errors (connection, timeout, etc.) are transient | ||
| HttpClientError::Transport(_) => BlockSourceError::transient(e), | ||
| // HTTP non-2xx errors are transient - e.g. "not found" must not stop polling | ||
| HttpClientError::Http(_) => BlockSourceError::transient(e), | ||
| // I/O errors follow the same logic as std::io::Error | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then just call it? |
||
| HttpClientError::Io(io_error) => match io_error.kind() { | ||
| io::ErrorKind::InvalidData => BlockSourceError::persistent(e), | ||
| io::ErrorKind::InvalidInput => BlockSourceError::persistent(e), | ||
| _ => BlockSourceError::transient(e), | ||
| }, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// Conversion from `RpcClientError` into `BlockSourceError`. | ||
| #[cfg(feature = "rpc-client")] | ||
| impl From<RpcClientError> for BlockSourceError { | ||
| fn from(e: RpcClientError) -> BlockSourceError { | ||
| match &e { | ||
| RpcClientError::Http(http_error) => match http_error { | ||
| HttpClientError::Transport(_) => BlockSourceError::transient(e), | ||
| // HTTP non-2xx errors are transient | ||
| HttpClientError::Http(_) => BlockSourceError::transient(e), | ||
| HttpClientError::Io(io_error) => match io_error.kind() { | ||
| io::ErrorKind::InvalidData => BlockSourceError::persistent(e), | ||
| io::ErrorKind::InvalidInput => BlockSourceError::persistent(e), | ||
| _ => BlockSourceError::transient(e), | ||
| }, | ||
| }, | ||
| // RPC errors are transient | ||
| // e.g. "block not found" should not stop polling | ||
| RpcClientError::Rpc(_) => BlockSourceError::transient(e), | ||
| // Malformed response data is persistent | ||
| RpcClientError::InvalidData(_) => BlockSourceError::persistent(e), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// Parses binary data as a block. | ||
| impl TryInto<Block> for BinaryResponse { | ||
| type Error = io::Error; | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Presumably a 404 or 403, for example, would, in fact, indicate a
persistentissue (though a 503 might not)? Maybe 5XX should be a transient issue and anything else persistent?