-
Notifications
You must be signed in to change notification settings - Fork 74
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
Remove AddChainOptions.jsonRpcCallback in favor of Chain.nextJsonRpcResponse #2778
Conversation
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.
Automatically approving tomaka's pull requests. This auto-approval will be removed once more maintainers are active.
twiggy diff reportDifference in .wasm size before and after this pull request.
|
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.
👍
Close #2456 This PR removes the `Chain.databaseContent` function from the public API. Users are supposed to use the `chainHead_unstable_finalizedDatabase` JSON-RPC function that was added in #2749 instead. This is an API breaking change. Since #2778 has been merged and is a breaking change, let's do other breaking changes at the same time. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Close #2528
This PR is a major change in the public API of the JS library, as such I will bump to 0.7.0 at the next release.
Instead of passing a callback when adding a chain where the JSON-RPC responses are sent, you are now supposed to call
nextJsonRpcResponse
on the chain.This asynchronous function waits (if necessary) for a JSON-RPC response to be available then returns it.
In addition to this,
sendJsonRpc
now returns an error if the request is malformed or if the queue is full.This change in API has several major advantages:
jsonRpcCallback
throws an exception.nextJsonRpcResponse
. This will cause the responses to pile up in the buffer, until a point wheresendJsonRpc
will return an error.nextJsonRpcResponse
will throw an exception in case of a smoldot crash, while before the callback was simply not called and you had to detect crashes throughsendJsonRpc
.Migration
It is always possible to migrate to the new API.
If your code looks like this:
You can rewrite it like this: