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
4e0ac574
Commit
4e0ac574
authored
5 years ago
by
Pierre Krieger
Committed by
Gavin Wood
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Move DummySpecialization to sc-network (#4680)
parent
96cd57a6
Branches
Branches containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
substrate/client/network/src/protocol/specialization.rs
+26
-0
26 additions, 0 deletions
substrate/client/network/src/protocol/specialization.rs
substrate/client/network/test/src/lib.rs
+1
-26
1 addition, 26 deletions
substrate/client/network/test/src/lib.rs
with
27 additions
and
26 deletions
substrate/client/network/src/protocol/specialization.rs
+
26
−
0
View file @
4e0ac574
...
...
@@ -57,6 +57,32 @@ pub trait NetworkSpecialization<B: BlockT>: Send + Sync + 'static {
fn
on_block_imported
(
&
mut
self
,
_ctx
:
&
mut
dyn
Context
<
B
>
,
_hash
:
B
::
Hash
,
_header
:
&
B
::
Header
)
{
}
}
/// A specialization that does nothing.
#[derive(Clone)]
pub
struct
DummySpecialization
;
impl
<
B
:
BlockT
>
NetworkSpecialization
<
B
>
for
DummySpecialization
{
fn
status
(
&
self
)
->
Vec
<
u8
>
{
vec!
[]
}
fn
on_connect
(
&
mut
self
,
_ctx
:
&
mut
dyn
Context
<
B
>
,
_peer_id
:
PeerId
,
_status
:
crate
::
message
::
Status
<
B
>
)
{}
fn
on_disconnect
(
&
mut
self
,
_ctx
:
&
mut
dyn
Context
<
B
>
,
_peer_id
:
PeerId
)
{}
fn
on_message
(
&
mut
self
,
_ctx
:
&
mut
dyn
Context
<
B
>
,
_peer_id
:
PeerId
,
_message
:
Vec
<
u8
>
,
)
{}
}
/// Construct a simple protocol that is composed of several sub protocols.
/// Each "sub protocol" needs to implement `Specialization` and needs to provide a `new()` function.
/// For more fine grained implementations, this macro is not usable.
...
...
This diff is collapsed.
Click to expand it.
substrate/client/network/test/src/lib.rs
+
1
−
26
View file @
4e0ac574
...
...
@@ -62,6 +62,7 @@ use substrate_test_runtime_client::{self, AccountKeyring};
pub
use
substrate_test_runtime_client
::
runtime
::{
Block
,
Extrinsic
,
Hash
,
Transfer
};
pub
use
substrate_test_runtime_client
::{
TestClient
,
TestClientBuilder
,
TestClientBuilderExt
};
pub
use
sc_network
::
specialization
::
DummySpecialization
;
type
AuthorityId
=
sp_consensus_babe
::
AuthorityId
;
...
...
@@ -101,32 +102,6 @@ impl<B: BlockT> Verifier<B> for PassThroughVerifier {
}
}
/// The test specialization.
#[derive(Clone)]
pub
struct
DummySpecialization
;
impl
NetworkSpecialization
<
Block
>
for
DummySpecialization
{
fn
status
(
&
self
)
->
Vec
<
u8
>
{
vec!
[]
}
fn
on_connect
(
&
mut
self
,
_ctx
:
&
mut
dyn
Context
<
Block
>
,
_peer_id
:
PeerId
,
_status
:
sc_network
::
message
::
Status
<
Block
>
)
{}
fn
on_disconnect
(
&
mut
self
,
_ctx
:
&
mut
dyn
Context
<
Block
>
,
_peer_id
:
PeerId
)
{}
fn
on_message
(
&
mut
self
,
_ctx
:
&
mut
dyn
Context
<
Block
>
,
_peer_id
:
PeerId
,
_message
:
Vec
<
u8
>
,
)
{}
}
pub
type
PeersFullClient
=
sc_client
::
Client
<
substrate_test_runtime_client
::
Backend
,
substrate_test_runtime_client
::
Executor
,
Block
,
substrate_test_runtime_client
::
runtime
::
RuntimeApi
>
;
pub
type
PeersLightClient
=
...
...
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