Basic fetch

This commit is contained in:
2024-08-16 22:55:46 +01:00
parent 70e0d70d8b
commit ac91e30db7
5 changed files with 371 additions and 2 deletions

View File

@ -1,13 +1,17 @@
#[macro_use]
extern crate rocket;
use std::time::Duration;
use anyhow::Error;
use rocket::shield::Shield;
use crate::fetch::FetchQueue;
use crate::store::SledDatabase;
mod events;
mod store;
mod fetch;
#[rocket::main]
async fn main() -> Result<(), Error> {
@ -15,8 +19,20 @@ async fn main() -> Result<(), Error> {
let db = SledDatabase::new("nostr.db");
let mut fetch = FetchQueue::new();
fetch.add_relay("wss://relay.snort.social".parse().unwrap()).await.unwrap();
let fetch2 = fetch.clone();
tokio::spawn(async move {
loop {
fetch2.process_queue().await;
tokio::time::sleep(Duration::from_millis(100)).await;
}
});
let rocket = rocket::Rocket::build()
.manage(db)
.manage(fetch)
.attach(Shield::new()) // disable
.mount("/", events::routes())
.launch()