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

Unexpected batch behavior #95

Open
evanlinjin opened this issue Feb 14, 2023 · 0 comments
Open

Unexpected batch behavior #95

evanlinjin opened this issue Feb 14, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@evanlinjin
Copy link
Member

evanlinjin commented Feb 14, 2023

The problem

If we do a batch request where the response array contains a response object which is an error, ElectrumClient will return Err(Error::Protocol) and the response objects will be discarded. This is not ideal as in most instances, we still want the response objects.

For example, a single request to method blockchain.transaction.get may return an response object with error if the transaction does not exist. Doing a batch of blockchain.transaction.get requests where we have a single transaction that the electrum server is not aware of (yet), will result in us not seeing any of the other response objects.

This is the current API for a batch request

fn batch_call(&self, batch: &Batch) -> Result<Vec<serde_json::Value>, Error> {

Proposed solution

fn batch_call(&self, batch: &Batch) -> Result<Vec<RawResponse>, Error> { todo!() }

pub enum RawResponse {
    /// Instead of returning `Err(Error::Protocol)`, we have this.
    Error { code: i32, message: String, data: Option<serde::Value> },

    /// The successful result, as usual.
    Result(serde::Value),
}

The RawResponse can be used to transform into a non-raw response depending on the method invoked.

For example, client.transaction_get() can return Result<Option<Transaction>, Error>.

Questions

  • The electrum server API docs does not provide error codes for error responses. Is there a standard for these? For example, if a transaction is not found.

Reference

@evanlinjin evanlinjin added the bug Something isn't working label Feb 14, 2023
@notmandatory notmandatory added this to the Release 0.19.0 milestone Nov 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants