Network sync refactoring (part 6) (#11940)

* Extract `NetworkKVProvider` trait in `sc-authority-discovery` and remove unnecessary dependency

* Extract `NetworkSyncForkRequest` trait in `sc-finality-grandpa`

* Relax requirements on `SyncOracle` trait, remove extra native methods from `NetworkService` that are already provided by trait impls

* Move `NetworkSigner` trait from `sc-authority-discovery` into `sc-network-common` and de-duplicate methods on `NetworkService`

* Move `NetworkKVProvider` trait from `sc-authority-discovery` into `sc-network-common` and de-duplicate methods on `NetworkService`

* Minimize `sc-authority-discovery` dependency on `sc-network`

* Move `NetworkSyncForkRequest` trait from `sc-finality-grandpa` to `sc-network-common` and de-duplicate methods in `NetworkService`

* Extract `NetworkStatusProvider` trait and de-duplicate methods on `NetworkService`

* Extract `NetworkPeers` trait and de-duplicate methods on `NetworkService`

* Extract `NetworkEventStream` trait and de-duplicate methods on `NetworkService`

* Move more methods from `NetworkService` into `NetworkPeers` trait

* Move `NetworkStateInfo` trait into `sc-network-common`

* Extract `NetworkNotification` trait and de-duplicate methods on `NetworkService`

* Extract `NetworkRequest` trait and de-duplicate methods on `NetworkService`

* Remove `NetworkService::local_peer_id()`, it is already provided by `NetworkStateInfo` impl

* Extract `NetworkTransaction` trait and de-duplicate methods on `NetworkService`

* Extract `NetworkBlock` trait and de-duplicate methods on `NetworkService`

* Remove dependencies on `NetworkService` from most of the methods of `sc-service`

* Address simple review comments
This commit is contained in:
Nazar Mokrynskyi
2022-08-09 21:28:32 +03:00
committed by GitHub
parent 9c56e79c43
commit a685582bfd
49 changed files with 1889 additions and 1029 deletions
@@ -236,10 +236,10 @@ pub trait Proposer<B: BlockT> {
pub trait SyncOracle {
/// Whether the synchronization service is undergoing major sync.
/// Returns true if so.
fn is_major_syncing(&mut self) -> bool;
fn is_major_syncing(&self) -> bool;
/// Whether the synchronization service is offline.
/// Returns true if so.
fn is_offline(&mut self) -> bool;
fn is_offline(&self) -> bool;
}
/// A synchronization oracle for when there is no network.
@@ -247,10 +247,10 @@ pub trait SyncOracle {
pub struct NoNetwork;
impl SyncOracle for NoNetwork {
fn is_major_syncing(&mut self) -> bool {
fn is_major_syncing(&self) -> bool {
false
}
fn is_offline(&mut self) -> bool {
fn is_offline(&self) -> bool {
false
}
}
@@ -258,14 +258,14 @@ impl SyncOracle for NoNetwork {
impl<T> SyncOracle for Arc<T>
where
T: ?Sized,
for<'r> &'r T: SyncOracle,
T: SyncOracle,
{
fn is_major_syncing(&mut self) -> bool {
<&T>::is_major_syncing(&mut &**self)
fn is_major_syncing(&self) -> bool {
T::is_major_syncing(self)
}
fn is_offline(&mut self) -> bool {
<&T>::is_offline(&mut &**self)
fn is_offline(&self) -> bool {
T::is_offline(self)
}
}