client: Do not set fork sync request via network-gossip (#4439)

The finality-grandpa module needs two sets of functionalities from the
network:

1. Everything gossip related, e.g. event_stream, write_notification, ...

2. The ability to set a fork sync request for a specific block hash.

Instead of embedding (2) inside of (1) this patch extracts (2) from (1)
having finality-grandpa depend on a `Network` that fulfills the
`network_gossip::Network` trait and that can set block sync requests.

On the one hand this improves the overall structure splitting things
that don't logically belong together. On the other hand it does
reintroduce a lot of trait bounds within finality-grandpa.
This commit is contained in:
Robert Habermeier
2019-12-18 14:17:13 +01:00
committed by GitHub
parent da87c3c1e3
commit 8f1b5b840d
7 changed files with 82 additions and 74 deletions
@@ -67,7 +67,9 @@ impl sc_network_gossip::Network<Block> for TestNetwork {
fn announce(&self, block: Hash, _associated_data: Vec<u8>) {
let _ = self.sender.unbounded_send(Event::Announce(block));
}
}
impl super::Network<Block> for TestNetwork {
fn set_sync_fork_request(
&self,
_peers: Vec<sc_network::PeerId>,
@@ -94,7 +96,7 @@ impl sc_network_gossip::ValidatorContext<Block> for TestNetwork {
}
struct Tester {
net_handle: super::NetworkBridge<Block>,
net_handle: super::NetworkBridge<Block, TestNetwork>,
gossip_validator: Arc<GossipValidator<Block>>,
events: mpsc::UnboundedReceiver<Event>,
}