Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
polkadot-sdk
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
parity
Mirrored projects
polkadot-sdk
Commits
4fa4dfb7
Commit
4fa4dfb7
authored
5 years ago
by
André Silva
Committed by
Gavin Wood
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
client: helper to create standalone client without service (#4536)
parent
b462009f
Branches
Branches containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
substrate/client/service/src/builder.rs
+77
-46
77 additions, 46 deletions
substrate/client/service/src/builder.rs
substrate/client/service/src/lib.rs
+1
-0
1 addition, 0 deletions
substrate/client/service/src/lib.rs
with
78 additions
and
46 deletions
substrate/client/service/src/builder.rs
+
77
−
46
View file @
4fa4dfb7
...
...
@@ -139,6 +139,82 @@ pub type TLightCallExecutor<TBl, TExecDisp> = sc_client::light::call_executor::G
>
,
>
;
type
TFullParts
<
TBl
,
TRtApi
,
TExecDisp
>
=
(
TFullClient
<
TBl
,
TRtApi
,
TExecDisp
>
,
Arc
<
TFullBackend
<
TBl
>>
,
Arc
<
RwLock
<
sc_keystore
::
Store
>>
,
);
/// Creates a new full client for the given config.
pub
fn
new_full_client
<
TBl
,
TRtApi
,
TExecDisp
,
TCfg
,
TGen
,
TCSExt
>
(
config
:
&
Configuration
<
TCfg
,
TGen
,
TCSExt
>
,
)
->
Result
<
TFullClient
<
TBl
,
TRtApi
,
TExecDisp
>
,
Error
>
where
TBl
:
BlockT
<
Hash
=
H256
>
,
TExecDisp
:
NativeExecutionDispatch
,
TGen
:
sp_runtime
::
BuildStorage
+
serde
::
Serialize
+
for
<
'de
>
serde
::
Deserialize
<
'de
>
,
TCSExt
:
Extension
,
{
new_full_parts
(
config
)
.map
(|
parts
|
parts
.0
)
}
fn
new_full_parts
<
TBl
,
TRtApi
,
TExecDisp
,
TCfg
,
TGen
,
TCSExt
>
(
config
:
&
Configuration
<
TCfg
,
TGen
,
TCSExt
>
,
)
->
Result
<
TFullParts
<
TBl
,
TRtApi
,
TExecDisp
>
,
Error
>
where
TBl
:
BlockT
<
Hash
=
H256
>
,
TExecDisp
:
NativeExecutionDispatch
,
TGen
:
sp_runtime
::
BuildStorage
+
serde
::
Serialize
+
for
<
'de
>
serde
::
Deserialize
<
'de
>
,
TCSExt
:
Extension
,
{
let
keystore
=
Keystore
::
open
(
config
.keystore_path
.clone
()
.ok_or
(
"No basepath configured"
)
?
,
config
.keystore_password
.clone
()
)
?
;
let
executor
=
NativeExecutor
::
<
TExecDisp
>
::
new
(
config
.wasm_method
,
config
.default_heap_pages
,
);
let
fork_blocks
=
config
.chain_spec
.extensions
()
.get
::
<
sc_client
::
ForkBlocks
<
TBl
>>
()
.cloned
()
.unwrap_or_default
();
let
(
client
,
backend
)
=
{
let
db_config
=
sc_client_db
::
DatabaseSettings
{
state_cache_size
:
config
.state_cache_size
,
state_cache_child_ratio
:
config
.state_cache_child_ratio
.map
(|
v
|
(
v
,
100
)),
pruning
:
config
.pruning
.clone
(),
source
:
match
&
config
.database
{
DatabaseConfig
::
Path
{
path
,
cache_size
}
=>
sc_client_db
::
DatabaseSettingsSrc
::
Path
{
path
:
path
.clone
(),
cache_size
:
cache_size
.clone
()
.map
(|
u
|
u
as
usize
),
},
DatabaseConfig
::
Custom
(
db
)
=>
sc_client_db
::
DatabaseSettingsSrc
::
Custom
(
db
.clone
()),
},
};
let
extensions
=
sc_client_api
::
execution_extensions
::
ExecutionExtensions
::
new
(
config
.execution_strategies
.clone
(),
Some
(
keystore
.clone
()),
);
sc_client_db
::
new_client
(
db_config
,
executor
,
&
config
.chain_spec
,
fork_blocks
,
extensions
,
)
?
};
Ok
((
client
,
backend
,
keystore
))
}
impl
<
TCfg
,
TGen
,
TCSExt
>
ServiceBuilder
<
(),
(),
TCfg
,
TGen
,
TCSExt
,
(),
(),
(),
(),
(),
(),
(),
(),
(),
()
>
where
TGen
:
RuntimeGenesis
,
TCSExt
:
Extension
{
/// Start the service builder with a configuration.
...
...
@@ -161,52 +237,7 @@ where TGen: RuntimeGenesis, TCSExt: Extension {
(),
TFullBackend
<
TBl
>
,
>
,
Error
>
{
let
keystore
=
Keystore
::
open
(
config
.keystore_path
.clone
()
.ok_or
(
"No basepath configured"
)
?
,
config
.keystore_password
.clone
()
)
?
;
let
executor
=
NativeExecutor
::
<
TExecDisp
>
::
new
(
config
.wasm_method
,
config
.default_heap_pages
,
);
let
fork_blocks
=
config
.chain_spec
.extensions
()
.get
::
<
sc_client
::
ForkBlocks
<
TBl
>>
()
.cloned
()
.unwrap_or_default
();
let
(
client
,
backend
)
=
{
let
db_config
=
sc_client_db
::
DatabaseSettings
{
state_cache_size
:
config
.state_cache_size
,
state_cache_child_ratio
:
config
.state_cache_child_ratio
.map
(|
v
|
(
v
,
100
)),
pruning
:
config
.pruning
.clone
(),
source
:
match
&
config
.database
{
DatabaseConfig
::
Path
{
path
,
cache_size
}
=>
sc_client_db
::
DatabaseSettingsSrc
::
Path
{
path
:
path
.clone
(),
cache_size
:
cache_size
.clone
()
.map
(|
u
|
u
as
usize
),
},
DatabaseConfig
::
Custom
(
db
)
=>
sc_client_db
::
DatabaseSettingsSrc
::
Custom
(
db
.clone
()),
},
};
let
extensions
=
sc_client_api
::
execution_extensions
::
ExecutionExtensions
::
new
(
config
.execution_strategies
.clone
(),
Some
(
keystore
.clone
()),
);
sc_client_db
::
new_client
(
db_config
,
executor
,
&
config
.chain_spec
,
fork_blocks
,
extensions
,
)
?
};
let
(
client
,
backend
,
keystore
)
=
new_full_parts
(
&
config
)
?
;
let
client
=
Arc
::
new
(
client
);
...
...
This diff is collapsed.
Click to expand it.
substrate/client/service/src/lib.rs
+
1
−
0
View file @
4fa4dfb7
...
...
@@ -54,6 +54,7 @@ use sp_runtime::traits::{NumberFor, Block as BlockT};
pub
use
self
::
error
::
Error
;
pub
use
self
::
builder
::{
new_full_client
,
ServiceBuilder
,
ServiceBuilderCommand
,
TFullClient
,
TLightClient
,
TFullBackend
,
TLightBackend
,
TFullCallExecutor
,
TLightCallExecutor
,
};
...
...
This diff is collapsed.
Click to expand it.
Preview
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!
Save comment
Cancel
Please
register
or
sign in
to comment