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
96cdf519
Commit
96cdf519
authored
Aug 13, 2020
by
Cecile Tonglet
Browse files
CLEANUP
Forked at:
e9164236
Parent branch: origin/rococo-branch
parent
b66861cb
Pipeline
#103767
canceled with stages
in 5 minutes and 50 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
collator/src/lib.rs
View file @
96cdf519
...
...
@@ -67,7 +67,7 @@ pub use sc_network::PeerId;
pub
use
service
::{
RuntimeApiCollection
,
Client
};
pub
use
sc_cli
::
SubstrateCli
;
#[cfg(not(feature
=
"service-rewr"
))]
use
polkadot_service
::{
FullNodeHandles
,
AbstractClient
,
YaExecuteWith
Client
};
use
polkadot_service
::{
FullNodeHandles
,
AbstractClient
,
Client
Handle
};
#[cfg(feature
=
"service-rewr"
)]
use
polkadot_service_new
::{
self
as
polkadot_service
,
...
...
@@ -200,12 +200,12 @@ pub async fn collate<P>(
Some
(
collation
)
}
/// Build a collator service based on the `
YaExecuteWith
Client`.
/// Build a collator service based on the `Client
Handle
`.
#[cfg(feature
=
"service-rewr"
)]
pub
fn
build_collator_service
<
P
>
(
spawner
:
SpawnTaskHandle
,
handles
:
FullNodeHandles
,
client
:
impl
YaExecuteWith
Client
,
client
:
impl
Client
Handle
,
para_id
:
ParaId
,
key
:
Arc
<
CollatorPair
>
,
build_parachain_context
:
P
,
...
...
@@ -352,12 +352,12 @@ impl<P> polkadot_service::ExecuteWithClient for BuildCollationWork<P>
}
}
/// Build a collator service based on the `
YaExecuteWith
Client`.
/// Build a collator service based on the `Client
Handle
`.
#[cfg(not(feature
=
"service-rewr"
))]
pub
fn
build_collator_service
<
P
>
(
spawner
:
SpawnTaskHandle
,
handles
:
FullNodeHandles
,
client
:
impl
YaExecuteWith
Client
,
client
:
impl
Client
Handle
,
para_id
:
ParaId
,
key
:
Arc
<
CollatorPair
>
,
build_parachain_context
:
P
,
...
...
node/test-service/src/lib.rs
View file @
96cdf519
...
...
@@ -26,7 +26,7 @@ use polkadot_primitives::v0::{
Block
,
Hash
,
CollatorId
,
Id
as
ParaId
,
};
use
polkadot_runtime_common
::{
parachains
,
registrar
,
BlockHashCount
};
use
polkadot_service
::{
new_full
,
FullNodeHandles
,
AbstractClient
,
YaExecuteWith
Client
,
ExecuteWithClient
};
use
polkadot_service
::{
new_full
,
FullNodeHandles
,
AbstractClient
,
Client
Handle
,
ExecuteWithClient
};
use
polkadot_test_runtime
::{
RestrictFunctionality
,
Runtime
,
SignedExtra
,
SignedPayload
,
VERSION
};
use
sc_chain_spec
::
ChainSpec
;
use
sc_client_api
::{
execution_extensions
::
ExecutionStrategies
,
BlockchainEvents
};
...
...
@@ -88,10 +88,10 @@ pub fn polkadot_test_new_full(
Ok
((
task_manager
,
client
,
handles
,
network
,
rpc_handlers
))
}
/// A wrapper for the test client that implements `
YaExecuteWith
Client`.
/// A wrapper for the test client that implements `Client
Handle
`.
pub
struct
TestClient
(
pub
Arc
<
polkadot_service
::
FullClient
<
polkadot_test_runtime
::
RuntimeApi
,
PolkadotTestExecutor
>>
);
impl
YaExecuteWith
Client
for
TestClient
{
impl
Client
Handle
for
TestClient
{
fn
execute_with
<
T
:
ExecuteWithClient
>
(
&
self
,
t
:
T
)
->
T
::
Output
{
T
::
execute_with_client
::
<
_
,
_
,
polkadot_service
::
FullBackend
>
(
t
,
self
.0
.clone
())
}
...
...
service/src/client.rs
View file @
96cdf519
...
...
@@ -118,8 +118,15 @@ pub trait ExecuteWithClient {
Client
:
AbstractClient
<
Block
,
Backend
,
Api
=
Api
>
+
'static
;
}
/// Yet Another ExecuteWithClient
pub
trait
YaExecuteWithClient
{
/// A handle to a Polkadot client instance.
///
/// The Polkadot service supports multiple different runtimes (Westend, Polkadot itself, etc). As each runtime has a
/// specialized client, we need to hide them behind a trait. This is this trait.
///
/// When wanting to work with the inner client, you need to use `ClientHandle::execute_with`.
///
/// See `ExecuteWithClient` for more information.
pub
trait
ClientHandle
{
/// Execute the given something with the client.
fn
execute_with
<
T
:
ExecuteWithClient
>
(
&
self
,
t
:
T
)
->
T
::
Output
;
}
...
...
@@ -135,7 +142,7 @@ pub enum Client {
Rococo
(
Arc
<
crate
::
FullClient
<
rococo_runtime
::
RuntimeApi
,
crate
::
RococoExecutor
>>
),
}
impl
YaExecuteWith
Client
for
Client
{
impl
Client
Handle
for
Client
{
fn
execute_with
<
T
:
ExecuteWithClient
>
(
&
self
,
t
:
T
)
->
T
::
Output
{
match
self
{
Self
::
Polkadot
(
client
)
=>
{
...
...
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