Yuki Kishimoto on Nostr: mikedilger, I'm trying with this example: ```toml [dependencies] nostr-sdk = { ...
mikedilger (npub1acg…p35c), I'm trying with this example:
```toml
[dependencies]
nostr-sdk = { version = "0.38", features = ["lmdb"] }
tokio = { version = "1.42", features = ["full"] }
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
```
```rust
use nostr_sdk::prelude::*;
#[tokio::main]
async fn main() -> Result<()> {
tracing_subscriber::fmt::init();
let keys = Keys::parse("nsec1ufnus6pju578ste3v90xd5m2decpuzpql2295m3sknqcjzyys9ls0qlc85")?;
let database = NostrLMDB::open("./db/nostr-lmdb")?;
let client: Client = ClientBuilder::default()
.signer(keys.clone())
.database(database)
.build();
client.add_relay("wss://chorus.mikedilger.com:444").await?;
client.connect().await;
let since = Timestamp::from_secs(1736726400);
let until = Timestamp::from_secs(1737331200);
let filter = Filter::new().kind(Kind::TextNote).since(since).until(until); // Sync the text notes of the last week
// Negentropy options
let (tx, mut rx) = SyncProgress::channel();
let opts = SyncOptions::default().progress(tx);
// Keep track of the progress
tokio::spawn(async move {
while rx.changed().await.is_ok() {
let progress = *rx.borrow_and_update();
if progress.total > 0 {
println!("{:.2}%", progress.percentage() * 100.0);
}
}
});
// Sync
let output = client.sync(filter, &opts).await?;
// Sync output
println!("Local: {}", output.local.len());
println!("Remote: {}", output.remote.len());
println!("Sent: {}", output.sent.len());
println!("Received: {}", output.received.len());
println!("Failures:");
for (url, map) in output.send_failures.iter() {
println!("* '{url}':");
for (id, e) in map.iter() {
println!(" - {id}: {e}");
}
}
Ok(())
}
```
```toml
[dependencies]
nostr-sdk = { version = "0.38", features = ["lmdb"] }
tokio = { version = "1.42", features = ["full"] }
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
```
```rust
use nostr_sdk::prelude::*;
#[tokio::main]
async fn main() -> Result<()> {
tracing_subscriber::fmt::init();
let keys = Keys::parse("nsec1ufnus6pju578ste3v90xd5m2decpuzpql2295m3sknqcjzyys9ls0qlc85")?;
let database = NostrLMDB::open("./db/nostr-lmdb")?;
let client: Client = ClientBuilder::default()
.signer(keys.clone())
.database(database)
.build();
client.add_relay("wss://chorus.mikedilger.com:444").await?;
client.connect().await;
let since = Timestamp::from_secs(1736726400);
let until = Timestamp::from_secs(1737331200);
let filter = Filter::new().kind(Kind::TextNote).since(since).until(until); // Sync the text notes of the last week
// Negentropy options
let (tx, mut rx) = SyncProgress::channel();
let opts = SyncOptions::default().progress(tx);
// Keep track of the progress
tokio::spawn(async move {
while rx.changed().await.is_ok() {
let progress = *rx.borrow_and_update();
if progress.total > 0 {
println!("{:.2}%", progress.percentage() * 100.0);
}
}
});
// Sync
let output = client.sync(filter, &opts).await?;
// Sync output
println!("Local: {}", output.local.len());
println!("Remote: {}", output.remote.len());
println!("Sent: {}", output.sent.len());
println!("Received: {}", output.received.len());
println!("Failures:");
for (url, map) in output.send_failures.iter() {
println!("* '{url}':");
for (id, e) in map.iter() {
println!(" - {id}: {e}");
}
}
Ok(())
}
```