message: Inspect unspent allowance in separate thread
diff: use std::{
  collections::{HashMap, HashSet},
  sync::{Arc, RwLock},
  + thread,
  time::{Duration, Instant},
  };
  use prometheus::Counter;
  -use tokio::sync::Mutex;
  +use tokio::{runtime::Handle, sync::Mutex};
  use tracing::{error, trace};
  use casper_types::{EraId, PublicKey};
  @@ -112,15 +113,27 @@ impl Limiter {
  }
  pub(super) fn debug_inspect_unspent_allowance(&self) -> Option<i64> {
  - // Disabled temporarily, as it results in a panic:
  -
  - // node panicked: Cannot start a runtime from within a runtime. This happens because a
  - // function (like `block_on`) attempted to block the current thread while the thread is
  - // being used to drive asynchronous tasks.
  + let resources = Arc::clone(&self.data.resources);
  + thread::spawn(|| {
  + if let Ok(runtime) = tokio::runtime::Runtime::new() {
  + Some(runtime.block_on(async {
  + if let Ok(unspent_allowance) = Handle::current()
  + .spawn(async move { resources.lock().await.available })
  + .await
  + {
  + Some(unspent_allowance)
  + } else {
  None
  -
  - //Some(self.data.resources.blocking_lock().available)
  + }
  + }))
  + } else {
  + None
  + }
  + })
  + .join()
  + .unwrap_or(None)
  + .flatten()
  }
  pub(super) fn debug_inspect_validators(
  @@ -150,7 +163,7 @@ struct LimiterData {
  /// connection.
  connected_validators: RwLock<HashMap<NodeId, PublicKey>>,
  /// Information about available resources.
  - resources: Mutex<ResourceData>,
  + resources: Arc<Mutex<ResourceData>>,
  /// Total time spent waiting.
  wait_time_sec: Counter,
  }
  @@ -174,10 +187,10 @@ impl LimiterData {
  LimiterData {
  resources_per_second,
  connected_validators: Default::default(),
  - resources: Mutex::new(ResourceData {
  + resources: Arc::new(Mutex::new(ResourceData {
  available: 0,
  last_refill: Instant::now(),
  - }),
  + })),
  wait_time_sec,
  }
  }
  