Introduce RPC Worker (#1462)

* Extract json-rpc-client and introduce worker

* Initial rpc worker

* Add error handling

* Use bounded channels for listeners

* Improve naming and clean up

* Use tracing channels

* Improve code readability

* Decrease channel size limit

* Remove unused dependency

* Fix docs

* RPC -> Rpc

* Start worker in initialization method

* Print error in case a distribution channel is full

* Fix docs

* Make `RpcStreamWorker` private

Co-authored-by: Davide Galassi <davxy@datawok.net>

* Use tokio channels and add TODO item

* Remove `Option` from `to_worker_channel`

Co-authored-by: Davide Galassi <davxy@datawok.net>
This commit is contained in:
Sebastian Kunert
2022-08-01 12:08:57 +02:00
committed by GitHub
parent f0a8dc6a9d
commit 36e580a56a
8 changed files with 503 additions and 302 deletions
+5 -3
View File
@@ -30,7 +30,7 @@ use cumulus_primitives_core::{
};
use cumulus_relay_chain_inprocess_interface::build_inprocess_relay_chain;
use cumulus_relay_chain_interface::{RelayChainError, RelayChainInterface, RelayChainResult};
use cumulus_relay_chain_rpc_interface::RelayChainRPCInterface;
use cumulus_relay_chain_rpc_interface::{create_client_and_start_worker, RelayChainRpcInterface};
use polkadot_service::CollatorPair;
use sp_core::Pair;
@@ -296,8 +296,10 @@ async fn build_relay_chain_interface(
hwbench: Option<sc_sysinfo::HwBench>,
) -> RelayChainResult<(Arc<(dyn RelayChainInterface + 'static)>, Option<CollatorPair>)> {
match collator_options.relay_chain_rpc_url {
Some(relay_chain_url) =>
Ok((Arc::new(RelayChainRPCInterface::new(relay_chain_url).await?) as Arc<_>, None)),
Some(relay_chain_url) => {
let client = create_client_and_start_worker(relay_chain_url, task_manager).await?;
Ok((Arc::new(RelayChainRpcInterface::new(client)) as Arc<_>, None))
},
None => build_inprocess_relay_chain(
polkadot_config,
parachain_config,