From 1bc75986ac5c304e073a952f4b9d47f122e2c13a Mon Sep 17 00:00:00 2001 From: pawan Date: Tue, 21 Apr 2020 20:06:27 +0530 Subject: [PATCH] Add TODOS --- beacon_node/client/src/notifier.rs | 3 ++- beacon_node/timer/src/lib.rs | 5 ++++- beacon_node/websocket_server/src/lib.rs | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/beacon_node/client/src/notifier.rs b/beacon_node/client/src/notifier.rs index 0bd3ae87f3..825c76c7e8 100644 --- a/beacon_node/client/src/notifier.rs +++ b/beacon_node/client/src/notifier.rs @@ -52,6 +52,7 @@ pub fn spawn_notifier( // TODO: `Return type of closure passed to `for_each` is restricted to `Future` // Hence, shifting the .then() error logs into the `for_each` closure. // Can be solved with `TryStreamExt::try_for_each` if `Interval` implemented `TryStream`. + // Check if this can be refactored better. let interval_future = interval_at(start_instant, interval_duration).for_each(|_| { let connected_peer_count = network.connected_peers(); @@ -168,7 +169,7 @@ pub fn spawn_notifier( let future = futures::future::select(interval_future, exit.map_err(|_| ()).map(|_| ())); - // TODO: the runtime handle should spawn this future. + // TODO: check if the runtime handle should spawn this future. tokio::task::spawn(future); Ok(exit_signal) diff --git a/beacon_node/timer/src/lib.rs b/beacon_node/timer/src/lib.rs index 0c22e9ade5..eccf06c4dd 100644 --- a/beacon_node/timer/src/lib.rs +++ b/beacon_node/timer/src/lib.rs @@ -12,7 +12,10 @@ use tokio::runtime::Handle; use tokio::time::{interval_at, Instant}; /// Spawns a timer service which periodically executes tasks for the beacon chain -pub async fn spawn( +/// TODO: We might not need a `Handle` to the runtime since this function should be +/// called from the context of a runtime and we can simply spawn using task::spawn. +/// Check for issues without the Handle. +pub fn spawn( handle: &Handle, beacon_chain: Arc>, milliseconds_per_slot: u64, diff --git a/beacon_node/websocket_server/src/lib.rs b/beacon_node/websocket_server/src/lib.rs index c6f1b537cc..d1f1d27ebc 100644 --- a/beacon_node/websocket_server/src/lib.rs +++ b/beacon_node/websocket_server/src/lib.rs @@ -92,6 +92,7 @@ pub fn start_server( // Place a future on the handle that will shutdown the websocket server when the // application exits. + // TODO: check if we should spawn using a `Handle` or using `task::spawn` handle.spawn(exit_future); exit_channel @@ -99,7 +100,7 @@ pub fn start_server( let log_inner = log.clone(); // TODO: using tokio `spawn_blocking` instead of `thread::spawn` - // Check which is more apt + // Check which is more apt. let _handle = tokio::task::spawn_blocking(move || match server.run() { Ok(_) => { debug!(