feat: can get actual available roots
Some checks failed
continuous-integration/drone/push Build is failing

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
2024-05-14 20:58:38 +02:00
parent 7bdf8393b1
commit 816869e6f9
4 changed files with 95 additions and 11 deletions

View File

@@ -1,17 +1,32 @@
use hyperlog_core::log::GraphItem;
use crate::state::SharedState;
use crate::{
services::get_available_roots::{self, GetAvailableRoots, GetAvailableRootsExt},
state::SharedState,
};
pub struct Querier {}
pub struct Querier {
get_available_roots: GetAvailableRoots,
}
#[allow(dead_code, unused_variables)]
impl Querier {
pub fn new() -> Self {
Self {}
pub fn new(get_available_roots: GetAvailableRoots) -> Self {
Self {
get_available_roots,
}
}
pub fn get_available_roots(&self) -> Option<Vec<String>> {
todo!()
pub async fn get_available_roots(&self) -> anyhow::Result<Option<Vec<String>>> {
let res = self
.get_available_roots
.execute(get_available_roots::Request {})
.await?;
if res.roots.is_empty() {
return Ok(None);
}
Ok(Some(res.roots))
}
pub fn get(
@@ -29,6 +44,6 @@ pub trait QuerierExt {
impl QuerierExt for SharedState {
fn querier(&self) -> Querier {
Querier::new()
Querier::new(self.get_available_roots_service())
}
}