computer: rollback part 1

This commit is contained in:
nym21
2025-08-12 22:37:16 +02:00
parent ee5dc8fc41
commit 5f8de8e756
29 changed files with 487 additions and 504 deletions
+1 -41
View File
@@ -42,7 +42,7 @@ pub struct Config {
#[arg(long, value_name = "BOOL")]
exchanges: Option<bool>,
/// Website served by the server (if active), default: default, saved
/// Website served by the server, default: default, saved
#[serde(default, deserialize_with = "default_on_error")]
#[arg(short, long)]
website: Option<Website>,
@@ -72,24 +72,8 @@ pub struct Config {
#[arg(long, value_name = "PASSWORD")]
rpcpassword: Option<String>,
/// Delay between runs, default: 0, saved
#[serde(default, deserialize_with = "default_on_error")]
#[arg(long, value_name = "SECONDS")]
delay: Option<u64>,
/// Activate the Model Context Protocol (MCP) endpoint to give LLMs access to BRK (experimental), default: true, saved
#[serde(default, deserialize_with = "default_on_error")]
#[arg(long, value_name = "BOOL")]
mcp: Option<bool>,
/// DEV: Activate watching the selected website's folder for changes, default: false, saved
#[serde(default, deserialize_with = "default_on_error")]
#[arg(long, value_name = "BOOL")]
watch: Option<bool>,
/// DEV: Activate checking address hashes for collisions when indexing, default: false, saved
#[serde(default, deserialize_with = "default_on_error")]
#[arg(long, value_name = "BOOL")]
check_collisions: Option<bool>,
}
@@ -150,22 +134,10 @@ impl Config {
config_saved.rpcpassword = Some(rpcpassword);
}
if let Some(delay) = config_args.delay.take() {
config_saved.delay = Some(delay);
}
if let Some(check_collisions) = config_args.check_collisions.take() {
config_saved.check_collisions = Some(check_collisions);
}
if let Some(mcp) = config_args.mcp.take() {
config_saved.mcp = Some(mcp);
}
if let Some(watch) = config_args.watch.take() {
config_saved.watch = Some(watch);
}
if config_args != Config::default() {
dbg!(config_args);
panic!("Didn't consume the full config")
@@ -258,10 +230,6 @@ Finally, you can run the program with '-h' for help."
self.rpcport
}
pub fn delay(&self) -> Option<u64> {
self.delay
}
pub fn bitcoindir(&self) -> PathBuf {
self.bitcoindir
.as_ref()
@@ -334,14 +302,6 @@ Finally, you can run the program with '-h' for help."
pub fn check_collisions(&self) -> bool {
self.check_collisions.is_some_and(|b| b)
}
pub fn mcp(&self) -> bool {
self.mcp.is_none_or(|b| b)
}
pub fn watch(&self) -> bool {
self.watch.is_some_and(|b| b)
}
}
fn default_on_error<'de, D, T>(deserializer: D) -> Result<T, D::Error>
+3 -11
View File
@@ -29,7 +29,7 @@ pub fn main() -> color_eyre::Result<()> {
fs::create_dir_all(dot_brk_path())?;
brk_logger::init(Some(&dot_brk_log_path()));
brk_logger::init(Some(&dot_brk_log_path()))?;
thread::Builder::new()
.stack_size(256 * 1024 * 1024)
@@ -108,9 +108,7 @@ pub fn run() -> color_eyre::Result<()> {
interface.generate_bridge_file(website, websites_path.as_path())?;
let watch = config.watch();
Some(bundle(&websites_path, website.to_folder_name(), watch).await?)
Some(bundle(&websites_path, website.to_folder_name(), true).await?)
} else {
None
};
@@ -120,10 +118,8 @@ pub fn run() -> color_eyre::Result<()> {
bundle_path,
);
let mcp = config.mcp();
tokio::spawn(async move {
server.serve(mcp).await.unwrap();
server.serve(true).await.unwrap();
});
sleep(Duration::from_secs(1));
@@ -140,10 +136,6 @@ pub fn run() -> color_eyre::Result<()> {
computer.compute(&indexer, starting_indexes, &exit).unwrap();
if let Some(delay) = config.delay() {
sleep(Duration::from_secs(delay))
}
info!("Waiting for new blocks...");
while block_count == rpc.get_block_count()? {