Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
parity
Mirrored projects
polkadot
Commits
16fc4a68
Commit
16fc4a68
authored
Jun 29, 2018
by
Svyatoslav Nikolsky
Committed by
Gav Wood
Jun 29, 2018
Browse files
DB-based light client backend (#250)
* use db in light clients * fixed comment * fixed grumbles
parent
2e2d5a25
Changes
2
Hide whitespace changes
Inline
Side-by-side
service/src/components.rs
View file @
16fc4a68
...
...
@@ -116,15 +116,19 @@ impl Components for FullComponents {
pub
struct
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
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
>
{
let
client_backend
=
client
::
light
::
new_light_backend
();
let
fetch_checker
=
Arc
::
new
(
client
::
light
::
new_fetch_checker
(
client_backend
.clone
(),
executor
));
let
db_storage
=
client_db
::
light
::
LightStorage
::
new
(
db_settings
)
?
;
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
client_backend
=
client
::
light
::
new_light_backend
(
light_blockchain
,
fetcher
.clone
());
let
client
=
client
::
light
::
new_light
(
client_backend
,
fetcher
.clone
(),
genesis_storage
)
?
;
Ok
((
Arc
::
new
(
client
),
Some
(
fetcher
)))
}
...
...
service/src/lib.rs
View file @
16fc4a68
...
...
@@ -136,7 +136,7 @@ impl<Components> Service<Components>
},
network_config
:
config
.network
,
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
,
};
let
network
=
network
::
Service
::
new
(
network_params
)
?
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment