Unify ChainSync actions under one enum (follow-up) (#2317)

Get rid of public `ChainSync::..._requests()` functions and return all
requests as actions.

---------

Co-authored-by: Sebastian Kunert <skunert49@gmail.com>
This commit is contained in:
Dmitry Markin
2023-11-15 10:33:58 +02:00
committed by GitHub
parent f53604362c
commit 18165ebba8
7 changed files with 74 additions and 47 deletions
@@ -16,8 +16,8 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//! `ChainSync`-related service code
//! `SyncingEngine`-related service code
pub mod chain_sync;
pub mod mock;
pub mod network;
pub mod syncing_service;
@@ -34,7 +34,7 @@ use std::{
},
};
/// Commands send to `ChainSync`
/// Commands send to `SyncingEngine`
pub enum ToServiceCommand<B: BlockT> {
SetSyncForkRequest(Vec<PeerId>, B::Hash, NumberFor<B>),
RequestJustification(B::Hash, NumberFor<B>),
@@ -63,7 +63,7 @@ pub enum ToServiceCommand<B: BlockT> {
// },
}
/// Handle for communicating with `ChainSync` asynchronously
/// Handle for communicating with `SyncingEngine` asynchronously
#[derive(Clone)]
pub struct SyncingService<B: BlockT> {
tx: TracingUnboundedSender<ToServiceCommand<B>>,
@@ -148,7 +148,7 @@ impl<B: BlockT> SyncingService<B> {
/// Get sync status
///
/// Returns an error if `ChainSync` has terminated.
/// Returns an error if `SyncingEngine` has terminated.
pub async fn status(&self) -> Result<SyncStatus<B>, ()> {
let (tx, rx) = oneshot::channel();
let _ = self.tx.unbounded_send(ToServiceCommand::Status(tx));