-
-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
58 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[package] | ||
name = "nostr-sdk-db" | ||
version = "0.1.0" | ||
edition = "2021" | ||
description = "Nostr SDK Database" | ||
authors = ["Yuki Kishimoto <[email protected]>"] | ||
homepage.workspace = true | ||
repository.workspace = true | ||
license.workspace = true | ||
readme = "README.md" | ||
rust-version.workspace = true | ||
keywords = ["nostr", "sdk", "db"] | ||
|
||
[dependencies] | ||
async-trait = "0.1" | ||
nostr = { version = "0.24", path = "../nostr", default-features = false, features = ["std"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) 2022-2023 Yuki Kishimoto | ||
// Distributed under the MIT software license | ||
|
||
//! Nostr SDK Database | ||
#![warn(missing_docs)] | ||
#![warn(rustdoc::bare_urls)] | ||
|
||
use async_trait::async_trait; | ||
use nostr::{Event, EventId, Filter, Url}; | ||
|
||
/// Nostr SDK Database | ||
#[async_trait] | ||
pub trait NostrDatabase { | ||
/// Error | ||
type Err; | ||
|
||
/// Save [`Event`] into store | ||
async fn save_event(&self, event: &Event) -> Result<(), Self::Err>; | ||
|
||
/// Save [`EventId`] seen by relay | ||
/// | ||
/// Useful for NIP65 (gossip) | ||
async fn save_event_id_seen_by_relay( | ||
&self, | ||
event_id: EventId, | ||
relay_url: Url, | ||
) -> Result<(), Self::Err>; | ||
|
||
/// Get list of relays that have seen the [`EventId`] | ||
async fn event_recently_seen_on_relays(&self, event_id: EventId) | ||
-> Result<Vec<Url>, Self::Err>; | ||
|
||
/// Query store with filters | ||
async fn query(&self, filters: Vec<Filter>) -> Result<Vec<Event>, Self::Err>; | ||
|
||
/// Get event IDs by filters | ||
/// | ||
/// Uuseful for negentropy reconciliation | ||
async fn event_ids_by_filters(&self, filters: Vec<Filter>) -> Result<Vec<EventId>, Self::Err>; | ||
} |