You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
enumRealClient{FullNode(CkbRpcClient),LightClient(LightClientRpcClient),}implRealClient{fnnew(url:Url,user_provided_full_node:bool) -> RealClient{if user_provided_full_node {RealClient::FullNode(CkbRpcClient::new(url))}else{RealClient::LightClient(LightClientRpcClient::new(url))}}/* Wrap similar RPC methods to unify into one, one by one. */}
In fact, if we only use a sub-set of RPC methods, we don't have to know that such clearly.
We could split:
CKB full node RPC methods into two parts:
Core CKB RPC methods
CKB full node only RPC methods
CKB light client RPC methods into two parts:
Core CKB RPC methods
CKB light client only RPC methods
Then there appears an abstraction layer: a series of core CKB RPC methods.
When an app just uses these core CKB RPC methods, it could connect to either a full node or a light client, it doesn't have to know it clearly, but all of them works well.
Examples:
traitCkbCoreEndpoint{}traitCkbFullNodeEndpoint{}traitCkbLightClientEndpoint{}implCkbCoreEndpointforCkbRpcClient{}implCkbFullNodeEndpointforCkbRpcClient{}implCkbCoreEndpointforLightClientRpcClient{}implCkbLightClientEndpointforLightClientRpcClient{}// Then, a core CKB client could be:implCkbCoreEndpointforCkbCoreClient{}// Or:pubstructCkbCoreClient(Box<dynCkbCoreEndpoint>);
The text was updated successfully, but these errors were encountered:
Description
Now, when an app wants to connect an RPC endpoint, it has to know which kind of endpoint it connects to, a full node or a light client.
ckb-sdk-rust/src/rpc/ckb.rs
Line 22 in 3da7ffa
ckb-sdk-rust/src/rpc/ckb_light_client.rs
Line 103 in 3da7ffa
It makes things complicated.
An example:
In fact, if we only use a sub-set of RPC methods, we don't have to know that such clearly.
We could split:
Then there appears an abstraction layer: a series of core CKB RPC methods.
When an app just uses these core CKB RPC methods, it could connect to either a full node or a light client, it doesn't have to know it clearly, but all of them works well.
Examples:
The text was updated successfully, but these errors were encountered: