Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ddorgan
polkadot
Commits
f98966ac
Unverified
Commit
f98966ac
authored
Dec 09, 2019
by
Ashley
Browse files
Add async blocks back in
parent
7fa88af0
Changes
4
Show whitespace changes
Inline
Side-by-side
collator/src/lib.rs
View file @
f98966ac
...
...
@@ -79,7 +79,7 @@ const COLLATION_TIMEOUT: Duration = Duration::from_secs(30);
pub
trait
Network
:
Send
+
Sync
{
/// Convert the given `CollatorId` to a `PeerId`.
fn
collator_id_to_peer_id
(
&
self
,
collator_id
:
CollatorId
)
->
Box
<
dyn
Future
<
Output
=
Option
<
PeerId
>>
+
Unpin
+
Send
>
;
Box
<
dyn
Future
<
Output
=
Option
<
PeerId
>>
+
Send
>
;
/// Create a `Stream` of checked statements for the given `relay_parent`.
///
...
...
@@ -95,7 +95,7 @@ impl<P, E, SP> Network for ValidationNetwork<P, E, PolkadotNetworkService, SP> w
SP
:
'static
+
Spawn
+
Clone
+
Send
+
Sync
,
{
fn
collator_id_to_peer_id
(
&
self
,
collator_id
:
CollatorId
)
->
Box
<
dyn
Future
<
Output
=
Option
<
PeerId
>>
+
Unpin
+
Send
>
Box
<
dyn
Future
<
Output
=
Option
<
PeerId
>>
+
Send
>
{
Box
::
new
(
Self
::
collator_id_to_peer_id
(
self
,
collator_id
))
}
...
...
network/src/router.rs
View file @
f98966ac
...
...
@@ -175,7 +175,7 @@ impl<P: ProvideRuntimeApi + Send + Sync + 'static, E, N, T> Router<P, E, N, T> w
if
let
Some
(
work
)
=
producer
.map
(|
p
|
self
.create_work
(
c_hash
,
p
))
{
trace!
(
target
:
"validation"
,
"driving statement work to completion"
);
let
work
=
select
(
work
,
self
.fetcher
.exit
()
.clone
())
let
work
=
select
(
work
.boxed
()
,
self
.fetcher
.exit
()
.clone
())
.map
(
drop
);
let
_
=
self
.fetcher
.executor
()
.spawn
(
work
);
}
...
...
@@ -193,11 +193,11 @@ impl<P: ProvideRuntimeApi + Send + Sync + 'static, E, N, T> Router<P, E, N, T> w
let
knowledge
=
self
.fetcher
.knowledge
()
.clone
();
let
attestation_topic
=
self
.attestation_topic
;
let
parent_hash
=
self
.parent_hash
();
let
api
=
self
.fetcher
.api
()
.clone
();
producer
.prime
(
self
.fetcher
.api
()
.clone
())
.validate
()
.boxed
()
.map_ok
(
move
|
validated
|
{
async
move
{
match
producer
.prime
(
api
)
.validate
()
.await
{
Ok
(
validated
)
=>
{
// store the data before broadcasting statements, so other peers can fetch.
knowledge
.lock
()
.note_candidate
(
candidate_hash
,
...
...
@@ -216,12 +216,12 @@ impl<P: ProvideRuntimeApi + Send + Sync + 'static, E, N, T> Router<P, E, N, T> w
);
network
.gossip_message
(
attestation_topic
,
statement
.into
());
})
.map
(|
res
|
{
if
let
Err
(
e
)
=
res
{
debug!
(
target
:
"p_net"
,
"Failed to produce statements: {:?}"
,
e
);
},
Err
(
err
)
=>
{
debug!
(
target
:
"p_net"
,
"Failed to produce statements: {:?}"
,
err
);
}
}
}
})
}
}
...
...
network/src/tests/validation.rs
View file @
f98966ac
...
...
@@ -150,7 +150,7 @@ impl NetworkService for TestNetwork {
fn
gossip_messages_for
(
&
self
,
topic
:
Hash
)
->
GossipMessageStream
{
let
(
tx
,
rx
)
=
mpsc
::
unbounded
();
let
_
=
self
.gossip.send_listener
.unbounded_send
((
topic
,
tx
));
GossipMessageStream
::
new
(
Box
::
new
(
rx
))
GossipMessageStream
::
new
(
rx
.boxed
(
))
}
fn
gossip_message
(
&
self
,
topic
:
Hash
,
message
:
GossipMessage
)
{
...
...
@@ -419,8 +419,8 @@ impl av_store::ProvideGossipMessages for DummyGossipMessages {
fn
gossip_messages_for
(
&
self
,
_topic
:
Hash
)
->
Box
<
dyn
futures
::
Stream
<
Item
=
(
Hash
,
Hash
,
ErasureChunk
)
>
+
Send
+
Unpin
>
{
Box
::
new
(
stream
::
empty
())
)
->
Pin
<
Box
<
dyn
futures
::
Stream
<
Item
=
(
Hash
,
Hash
,
ErasureChunk
)
>
+
Send
>
>
{
stream
::
empty
()
.boxed
(
)
}
fn
gossip_erasure_chunk
(
...
...
network/src/validation.rs
View file @
f98966ac
...
...
@@ -161,11 +161,15 @@ impl<P, E, N, T> ValidationNetwork<P, E, N, T> where N: NetworkService {
pub
fn
collator_id_to_peer_id
(
&
self
,
collator_id
:
CollatorId
)
->
impl
Future
<
Output
=
Option
<
PeerId
>>
+
Send
{
let
network
=
self
.network
.clone
();
async
move
{
let
(
send
,
recv
)
=
oneshot
::
channel
();
self
.
network
.with_spec
(
move
|
spec
,
_
|
{
network
.with_spec
(
move
|
spec
,
_
|
{
let
_
=
send
.send
(
spec
.collator_id_to_peer_id
(
&
collator_id
)
.cloned
());
});
recv
.map
(|
res
|
res
.unwrap_or
(
None
))
recv
.await
.ok
()
.and_then
(|
opt
|
opt
)
}
}
/// Create a `Stream` of checked statements for the given `relay_parent`.
...
...
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