use bsv_rs::overlay::{
LookupAnswer, LookupQuestion, LookupResolver, LookupResolverConfig, TopicBroadcaster,
TopicBroadcasterConfig,
};
use bsv_rs::transaction::Transaction;
#[tokio::main(flavor = "current_thread")]
async fn main() {
let resolver = LookupResolver::new(LookupResolverConfig::default());
let question = LookupQuestion::new("ls_kvstore", serde_json::json!({ "key": "hello" }));
match resolver.query(&question, Some(5_000)).await {
Ok(LookupAnswer::OutputList { outputs }) => {
println!("lookup answered {} output(s)", outputs.len())
}
Ok(other) => println!("lookup answered a {:?} shape", other.answer_type()),
Err(e) => println!("lookup failed: {e}"),
}
let broadcaster = TopicBroadcaster::new(
vec!["tm_kvstore".to_string()],
TopicBroadcasterConfig::default(),
)
.unwrap();
let tx = Transaction::new();
match broadcaster.broadcast_tx(&tx).await {
Ok(steak) => println!("broadcast acknowledged: {steak:?}"),
Err(e) => println!("broadcast refused: {e:?}"),
}
}