Persist block announcements (#3826)

* Persist block announcements

* Renamed sync requests to fork targets

* Fixed pruning detection condition
This commit is contained in:
Arkadiy Paronyan
2019-10-18 16:44:40 +02:00
committed by Gavin Wood
parent 3437d64115
commit 3963bb58ff
4 changed files with 105 additions and 128 deletions
+2
View File
@@ -704,7 +704,9 @@ pub trait TestNetFactory: Sized {
fn poll(&mut self) {
self.mut_peers(|peers| {
for peer in peers {
trace!(target: "sync", "-- Polling {}", peer.id());
peer.network.poll().unwrap();
trace!(target: "sync", "-- Polling complete {}", peer.id());
// We poll `imported_blocks_stream`.
while let Ok(Async::Ready(Some(notification))) = peer.imported_blocks_stream.poll() {
+11
View File
@@ -457,6 +457,17 @@ fn can_sync_small_non_best_forks() {
}
Ok(Async::Ready(()))
})).unwrap();
net.block_until_sync(&mut runtime);
let another_fork = net.peer(0).push_blocks_at(BlockId::Number(35), 2, true);
net.peer(0).announce_block(another_fork, Vec::new());
runtime.block_on(futures::future::poll_fn::<(), (), _>(|| -> Result<_, ()> {
net.poll();
if net.peer(1).client().header(&BlockId::Hash(another_fork)).unwrap().is_none() {
return Ok(Async::NotReady)
}
Ok(Async::Ready(()))
})).unwrap();
}
#[test]