3 releases (breaking)
|0.3.0||Dec 1, 2022|
|0.2.0||Sep 7, 2022|
|0.1.0||Aug 23, 2022|
#2336 in Magic Beans
40 downloads per month
Smoldot light client library.
This library provides an easy way to create a light client.
This light client is opinionated towards certain aspects: what it downloads, how much memory and CPU it is willing to consume, etc.
In order to use the light client, call [
Client::new], passing a [
ClientConfig]. See the
documentation of [
ClientConfig] for information about what to provide.
Client] contains two generic parameters:
- An implementation of the [
platform::Platform] trait. This is how the client will communicate with the outside, such as getting the current time.
- An opaque user data. If you do not use this, you can simply use
Adding a chain
After the client has been initialized, use [
Client::add_chain] to ask the client to connect
to said chain. See the documentation of [
AddChainConfig] for information about what to
Client::add_chain] returns a [
ChainId], which identifies the chain within the [
Client] can be thought of as a collection of chain connections, each identified by their
ChainId], akin to a
A chain can be removed at any time using [
Client::remove_chain]. This will cause the client
to stop all connections and clean up its internal services. The [
ChainId] is instantly
considered as invalid as soon as the method is called.
JSON-RPC requests and responses
Once a chain has been added, one can send JSON-RPC requests using [
The request parameter of this function must be a JSON-RPC request in its text form. For
Client::json_rpc_request] queues the request in the internals of the client. Later,
the client will process it.
Responses can be pulled by calling the [
AddChainSuccess::json_rpc_responses] that is returned
after a chain has been added.