Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Duniter v2S
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
nodes
rust
Duniter v2S
Commits
a6efc7b6
Unverified
Commit
a6efc7b6
authored
1 year ago
by
bgallois
Browse files
Options
Downloads
Patches
Plain Diff
refactor client
parent
e269e954
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
node/src/service.rs
+17
-60
17 additions, 60 deletions
node/src/service.rs
node/src/service/client.rs
+25
-55
25 additions, 55 deletions
node/src/service/client.rs
runtime/g1/src/lib.rs
+1
-0
1 addition, 0 deletions
runtime/g1/src/lib.rs
with
43 additions
and
115 deletions
node/src/service.rs
+
17
−
60
View file @
a6efc7b6
...
@@ -62,6 +62,7 @@ pub mod runtime_executor {
...
@@ -62,6 +62,7 @@ pub mod runtime_executor {
pub
use
gdev_runtime
as
runtime
;
pub
use
gdev_runtime
as
runtime
;
#[cfg(feature
=
"gtest"
)]
#[cfg(feature
=
"gtest"
)]
pub
use
gtest_runtime
as
runtime
;
pub
use
gtest_runtime
as
runtime
;
use
sc_executor
::
sp_wasm_interface
::{
Function
,
HostFunctionRegistry
};
use
sc_executor
::
sp_wasm_interface
::{
Function
,
HostFunctionRegistry
};
pub
struct
Executor
;
pub
struct
Executor
;
...
@@ -136,66 +137,22 @@ pub fn new_chain_ops(
...
@@ -136,66 +137,22 @@ pub fn new_chain_ops(
),
),
ServiceError
,
ServiceError
,
>
{
>
{
match
config
.chain_spec
.runtime_type
()
{
let
PartialComponents
{
#[cfg(feature
=
"g1"
)]
client
,
RuntimeType
::
G1
::
G1
=>
{
backend
,
let
PartialComponents
{
import_queue
,
client
,
task_manager
,
backend
,
..
import_queue
,
}
=
new_partial
::
<
runtime_executor
::
runtime
::
RuntimeApi
,
runtime_executor
::
Executor
>
(
task_manager
,
config
,
..
manual_consensus
,
}
=
new_partial
::
<
g1_runtime
::
RuntimeApi
,
runtime_executor
::
G1Executor
>
(
)
?
;
config
,
Ok
((
manual_consensus
,
Arc
::
new
(
Client
::
Client
(
client
)),
)
?
;
backend
,
Ok
((
import_queue
,
Arc
::
new
(
Client
::
G1
(
client
)),
task_manager
,
backend
,
))
import_queue
,
task_manager
,
))
}
#[cfg(feature
=
"gtest"
)]
RuntimeType
::
GTest
=>
{
let
PartialComponents
{
client
,
backend
,
import_queue
,
task_manager
,
..
}
=
new_partial
::
<
gtest_runtime
::
RuntimeApi
,
runtime_executor
::
GTestExecutor
>
(
config
,
manual_consensus
,
)
?
;
Ok
((
Arc
::
new
(
Client
::
GTest
(
client
)),
backend
,
import_queue
,
task_manager
,
))
}
#[cfg(feature
=
"gdev"
)]
RuntimeType
::
GDev
=>
{
let
PartialComponents
{
client
,
backend
,
import_queue
,
task_manager
,
..
}
=
new_partial
::
<
gdev_runtime
::
RuntimeApi
,
runtime_executor
::
Executor
>
(
config
,
manual_consensus
,
)
?
;
Ok
((
Arc
::
new
(
Client
::
GDev
(
client
)),
backend
,
import_queue
,
task_manager
,
))
}
_
=>
panic!
(
"unknown runtime"
),
}
}
}
type
FullGrandpaBlockImport
<
RuntimeApi
,
Executor
>
=
sc_consensus_grandpa
::
GrandpaBlockImport
<
type
FullGrandpaBlockImport
<
RuntimeApi
,
Executor
>
=
sc_consensus_grandpa
::
GrandpaBlockImport
<
...
...
This diff is collapsed.
Click to expand it.
node/src/service/client.rs
+
25
−
55
View file @
a6efc7b6
...
@@ -145,12 +145,14 @@ impl<Api> RuntimeApiCollection for Api where
...
@@ -145,12 +145,14 @@ impl<Api> RuntimeApiCollection for Api where
/// A client instance.
/// A client instance.
#[derive(Clone)]
#[derive(Clone)]
pub
enum
Client
{
pub
enum
Client
{
#[cfg(feature
=
"g1"
)]
Client
(
G1
(
Arc
<
super
::
FullClient
<
g1_runtime
::
RuntimeApi
,
super
::
runtime_executor
::
Executor
>>
),
Arc
<
#[cfg(feature
=
"gtest"
)]
super
::
FullClient
<
GTest
(
Arc
<
super
::
FullClient
<
gtest_runtime
::
RuntimeApi
,
super
::
runtime_executor
::
Executor
>>
),
super
::
runtime_executor
::
runtime
::
RuntimeApi
,
#[cfg(feature
=
"gdev"
)]
super
::
runtime_executor
::
Executor
,
GDev
(
Arc
<
super
::
FullClient
<
gdev_runtime
::
RuntimeApi
,
super
::
runtime_executor
::
Executor
>>
),
>
,
>
,
),
}
}
macro_rules!
with_client
{
macro_rules!
with_client
{
...
@@ -162,22 +164,8 @@ macro_rules! with_client {
...
@@ -162,22 +164,8 @@ macro_rules! with_client {
}
}
}
=>
{
}
=>
{
match
$self
{
match
$self
{
#[cfg(feature
=
"g1"
)]
Self
::
Client
(
$client
)
=>
{
Self
::
G1
(
$client
)
=>
{
#[allow(unused_imports)]
use
g1_runtime
as
runtime
;
$
(
$code
)
*
}
#[cfg(feature
=
"gtest"
)]
Self
::
GTest
(
$client
)
=>
{
#[allow(unused_imports)]
use
gtest_runtime
as
runtime
;
$
(
$code
)
*
}
#[cfg(feature
=
"gdev"
)]
Self
::
GDev
(
$client
)
=>
{
#[allow(unused_imports)]
#[allow(unused_imports)]
use
gdev_runtime
as
runtime
;
$
(
$code
)
*
$
(
$code
)
*
}
}
}
}
...
@@ -196,50 +184,32 @@ impl ClientHandle for Client {
...
@@ -196,50 +184,32 @@ impl ClientHandle for Client {
}
}
}
}
#[cfg(feature
=
"g1"
)]
impl
impl
From
<
Arc
<
super
::
FullClient
<
g1_runtime
::
RuntimeApi
,
super
::
runtime_executor
::
Executor
>>>
From
<
for
Client
Arc
<
{
super
::
FullClient
<
fn
from
(
super
::
runtime_executor
::
runtime
::
RuntimeApi
,
client
:
Arc
<
super
::
FullClient
<
g1_runtime
::
RuntimeApi
,
super
::
runtime_executor
::
Executor
>>
,
super
::
runtime_executor
::
Executor
,
)
->
Self
{
>
,
Self
::
G1
(
client
)
>
,
}
>
for
Client
}
#[cfg(feature
=
"gtest"
)]
impl
From
<
Arc
<
super
::
FullClient
<
gtest_runtime
::
RuntimeApi
,
super
::
runtime_executor
::
Executor
>>>
for
Client
{
{
fn
from
(
fn
from
(
client
:
Arc
<
client
:
Arc
<
super
::
FullClient
<
gtest_runtime
::
RuntimeApi
,
super
::
runtime_executor
::
Executor
>
,
super
::
FullClient
<
super
::
runtime_executor
::
runtime
::
RuntimeApi
,
super
::
runtime_executor
::
Executor
,
>
,
>
,
>
,
)
->
Self
{
)
->
Self
{
Self
::
GTest
(
client
)
Self
::
Client
(
client
)
}
}
#[cfg(feature
=
"gdev"
)]
impl
From
<
Arc
<
super
::
FullClient
<
gdev_runtime
::
RuntimeApi
,
super
::
runtime_executor
::
Executor
>>>
for
Client
{
fn
from
(
client
:
Arc
<
super
::
FullClient
<
gdev_runtime
::
RuntimeApi
,
super
::
runtime_executor
::
Executor
>>
,
)
->
Self
{
Self
::
GDev
(
client
)
}
}
}
}
macro_rules!
match_client
{
macro_rules!
match_client
{
(
$self:ident
,
$method:ident
(
$
(
$param:ident
),
*
))
=>
{
(
$self:ident
,
$method:ident
(
$
(
$param:ident
),
*
))
=>
{
match
$self
{
match
$self
{
#[cfg(feature
=
"g1"
)]
Self
::
Client
(
client
)
=>
client
.
$method
(
$
(
$param
),
*
),
Self
::
G1
(
client
)
=>
client
.
$method
(
$
(
$param
),
*
),
#[cfg(feature
=
"gtest"
)]
Self
::
GTest
(
client
)
=>
client
.
$method
(
$
(
$param
),
*
),
#[cfg(feature
=
"gdev"
)]
Self
::
GDev
(
client
)
=>
client
.
$method
(
$
(
$param
),
*
),
}
}
};
};
}
}
...
@@ -336,7 +306,7 @@ use gtest_runtime as runtime;
...
@@ -336,7 +306,7 @@ use gtest_runtime as runtime;
#[cfg(feature
=
"gtest"
)]
#[cfg(feature
=
"gtest"
)]
type
FullClient
=
super
::
FullClient
<
runtime
::
RuntimeApi
,
super
::
runtime_executor
::
Executor
>
;
type
FullClient
=
super
::
FullClient
<
runtime
::
RuntimeApi
,
super
::
runtime_executor
::
Executor
>
;
#[cfg(any(feature
=
"gdev"
,
feature
=
"gtest"
))]
#[cfg(any(feature
=
"gdev"
,
feature
=
"gtest"
,
feature
=
"g1"
))]
impl
BenchmarkCallSigner
<
runtime
::
RuntimeCall
,
sp_core
::
sr25519
::
Pair
>
for
FullClient
{
impl
BenchmarkCallSigner
<
runtime
::
RuntimeCall
,
sp_core
::
sr25519
::
Pair
>
for
FullClient
{
fn
sign_call
(
fn
sign_call
(
&
self
,
&
self
,
...
...
This diff is collapsed.
Click to expand it.
runtime/g1/src/lib.rs
+
1
−
0
View file @
a6efc7b6
...
@@ -33,6 +33,7 @@ pub use common_runtime::{
...
@@ -33,6 +33,7 @@ pub use common_runtime::{
constants
::
*
,
entities
::
*
,
handlers
::
*
,
AccountId
,
Address
,
Balance
,
BlockNumber
,
constants
::
*
,
entities
::
*
,
handlers
::
*
,
AccountId
,
Address
,
Balance
,
BlockNumber
,
FullIdentificationOfImpl
,
GetCurrentEpochIndex
,
Hash
,
Header
,
IdtyIndex
,
Index
,
Signature
,
FullIdentificationOfImpl
,
GetCurrentEpochIndex
,
Hash
,
Header
,
IdtyIndex
,
Index
,
Signature
,
};
};
pub
use
frame_system
::
Call
as
SystemCall
;
pub
use
pallet_balances
::
Call
as
BalancesCall
;
pub
use
pallet_balances
::
Call
as
BalancesCall
;
pub
use
pallet_identity
::{
IdtyStatus
,
IdtyValue
};
pub
use
pallet_identity
::{
IdtyStatus
,
IdtyValue
};
pub
use
pallet_im_online
::
sr25519
::
AuthorityId
as
ImOnlineId
;
pub
use
pallet_im_online
::
sr25519
::
AuthorityId
as
ImOnlineId
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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