-
Notifications
You must be signed in to change notification settings - Fork 2.7k
client/network-gossip: Move sink IO outside of state_machine #5669
client/network-gossip: Move sink IO outside of state_machine #5669
Conversation
`ConsensusGossip` is supposed to be a deterministic state machine. `GossipEngine` wrapping `ConsensusGossip` should handle IO operations. This commit moves the `message_sink` IO operations to `GossipEngine`. More specifically on incoming messages a `GossipEngine` calls `ConsensusGossip::on_incoming` to validate and register the messages. `ConsensusGossip` returns the valid messages which are then forwarded by `GossipEngine` to the upper layer via the `message_sinks`.
@@ -544,22 +526,6 @@ mod tests { | |||
assert_eq!(consensus.messages.len(), 2); | |||
} | |||
|
|||
#[test] | |||
fn can_keep_multiple_subscribers_per_topic() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been moved to bridge.rs
and renamed to keeps_multiple_subscribers_per_topic_updated_with_both_old_and_new_messages
.
"Pushing consensus message to sinks for {}.", topic, | ||
); | ||
entry.get_mut().retain(move |sink| { | ||
if let Err(e) = sink.unbounded_send(notification.clone()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this pull request sending on the event channel is happening in an asynchronous context. Thus we could replace the unbounded channel with a bounded channel in a follow up pull request.
Thanks for the review @tomaka and thanks for the help @gnunicorn! I am guessing that the polkadot-companion failure is not related.
|
@mxinden still tests failing... |
); | ||
|
||
for (topic, notification) in to_forward.into_iter() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the follow-up (I won't introduce another CI cycle for this issue), the into_iter()
call is redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Fixed in f277e6c.
ConsensusGossip
is supposed to be a deterministic state machine.GossipEngine
wrappingConsensusGossip
should handle IO operations.This commit moves the
message_sink
IO operations toGossipEngine
.More specifically on incoming messages a
GossipEngine
callsConsensusGossip::on_incoming
to validate and register the messages.ConsensusGossip
returns the valid messages which are then forwarded byGossipEngine
to the upper layer via themessage_sinks
.