server: multiple frontends + auto download from github when needed

This commit is contained in:
nym21
2025-03-05 12:22:11 +01:00
parent 0d0edd7917
commit b27297cdc6
29 changed files with 892 additions and 99 deletions

View File

@@ -7,6 +7,7 @@ use brk_parser::{
Parser,
rpc::{self, RpcApi},
};
use brk_server::Frontend;
use log::info;
pub fn main() -> color_eyre::Result<()> {
@@ -14,6 +15,8 @@ pub fn main() -> color_eyre::Result<()> {
brk_logger::init(Some(Path::new(".log")));
let process = false;
let bitcoin_dir = Path::new("../../../bitcoin");
let rpc = Box::leak(Box::new(rpc::Client::new(
"http://localhost:8332",
@@ -40,29 +43,33 @@ pub fn main() -> color_eyre::Result<()> {
let served_indexer = indexer.clone();
let served_computer = computer.clone();
tokio::spawn(async move {
brk_server::main(served_indexer, served_computer)
let server = tokio::spawn(async move {
brk_server::main(served_indexer, served_computer, Frontend::KiboMoney)
.await
.unwrap();
});
loop {
let block_count = rpc.get_block_count()?;
if process {
loop {
let block_count = rpc.get_block_count()?;
info!("{block_count} blocks found.");
info!("{block_count} blocks found.");
let starting_indexes = indexer.index(&parser, rpc, &exit)?;
let starting_indexes = indexer.index(&parser, rpc, &exit)?;
computer.compute(&mut indexer, starting_indexes, &exit)?;
computer.compute(&mut indexer, starting_indexes, &exit)?;
info!("Waiting for new blocks...");
info!("Waiting for new blocks...");
while block_count == rpc.get_block_count()? {
sleep(Duration::from_secs(1))
while block_count == rpc.get_block_count()? {
sleep(Duration::from_secs(1))
}
}
}
#[allow(unreachable_code)]
server.await.unwrap();
Ok(())
}) as color_eyre::Result<()>
}