Commit 16fc4a68 authored by Svyatoslav Nikolsky's avatar Svyatoslav Nikolsky Committed by Gav Wood
Browse files

DB-based light client backend (#250)

* use db in light clients

* fixed comment

* fixed grumbles
parent 2e2d5a25
...@@ -116,15 +116,19 @@ impl Components for FullComponents { ...@@ -116,15 +116,19 @@ impl Components for FullComponents {
pub struct LightComponents; pub struct LightComponents;
impl Components for LightComponents { impl Components for LightComponents {
type Backend = client::light::Backend<Block>; type Backend = client::light::backend::Backend<client_db::light::LightStorage<Block>, network::OnDemand<Block, network::Service<Block>>>;
type Api = polkadot_api::light::RemotePolkadotApiWrapper<Self::Backend, Self::Executor>; type Api = polkadot_api::light::RemotePolkadotApiWrapper<Self::Backend, Self::Executor>;
type Executor = client::RemoteCallExecutor<client::light::Backend<Block>, network::OnDemand<Block, network::Service<Block>>>; type Executor = client::light::call_executor::RemoteCallExecutor<
client::light::blockchain::Blockchain<client_db::light::LightStorage<Block>, network::OnDemand<Block, network::Service<Block>>>,
network::OnDemand<Block, network::Service<Block>>>;
fn build_client(&self, _settings: client_db::DatabaseSettings, executor: CodeExecutor, genesis_storage: MakeStorage) fn build_client(&self, db_settings: client_db::DatabaseSettings, executor: CodeExecutor, genesis_storage: MakeStorage)
-> Result<(Arc<client::Client<Self::Backend, Self::Executor, Block>>, Option<Arc<network::OnDemand<Block, network::Service<Block>>>>), error::Error> { -> Result<(Arc<client::Client<Self::Backend, Self::Executor, Block>>, Option<Arc<network::OnDemand<Block, network::Service<Block>>>>), error::Error> {
let client_backend = client::light::new_light_backend(); let db_storage = client_db::light::LightStorage::new(db_settings)?;
let fetch_checker = Arc::new(client::light::new_fetch_checker(client_backend.clone(), executor)); let light_blockchain = client::light::new_light_blockchain(db_storage);
let fetch_checker = Arc::new(client::light::new_fetch_checker(light_blockchain.clone(), executor));
let fetcher = Arc::new(network::OnDemand::new(fetch_checker)); let fetcher = Arc::new(network::OnDemand::new(fetch_checker));
let client_backend = client::light::new_light_backend(light_blockchain, fetcher.clone());
let client = client::light::new_light(client_backend, fetcher.clone(), genesis_storage)?; let client = client::light::new_light(client_backend, fetcher.clone(), genesis_storage)?;
Ok((Arc::new(client), Some(fetcher))) Ok((Arc::new(client), Some(fetcher)))
} }
......
...@@ -136,7 +136,7 @@ impl<Components> Service<Components> ...@@ -136,7 +136,7 @@ impl<Components> Service<Components>
}, },
network_config: config.network, network_config: config.network,
chain: client.clone(), chain: client.clone(),
on_demand: on_demand.clone().map(|d| d as Arc<network::OnDemandService>), on_demand: on_demand.clone().map(|d| d as Arc<network::OnDemandService<Block>>),
transaction_pool: transaction_pool_adapter, transaction_pool: transaction_pool_adapter,
}; };
let network = network::Service::new(network_params)?; let network = network::Service::new(network_params)?;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment