upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/client.rs22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/lib/client.rs b/src/lib/client.rs
index 5f9e996..8a381ab 100644
--- a/src/lib/client.rs
+++ b/src/lib/client.rs
@@ -30,11 +30,11 @@ use indicatif::{MultiProgress, ProgressBar, ProgressDrawTarget, ProgressState, P
30use mockall::*; 30use mockall::*;
31use nostr::{nips::nip01::Coordinate, Event}; 31use nostr::{nips::nip01::Coordinate, Event};
32use nostr_database::NostrDatabase; 32use nostr_database::NostrDatabase;
33use nostr_lmdb::NostrLMDB;
33use nostr_sdk::{ 34use nostr_sdk::{
34 prelude::RelayLimits, EventBuilder, EventId, Kind, NostrSigner, Options, PublicKey, 35 prelude::RelayLimits, EventBuilder, EventId, Kind, NostrSigner, Options, PublicKey,
35 SingleLetterTag, Timestamp, Url, 36 SingleLetterTag, Timestamp, Url,
36}; 37};
37use nostr_sqlite::SQLiteDatabase;
38 38
39use crate::{ 39use crate::{
40 get_dirs, 40 get_dirs,
@@ -157,7 +157,7 @@ impl Connect for Client {
157 .opts(Options::new().relay_limits(RelayLimits::disable())) 157 .opts(Options::new().relay_limits(RelayLimits::disable()))
158 .signer(opts.keys.unwrap_or(nostr::Keys::generate())) 158 .signer(opts.keys.unwrap_or(nostr::Keys::generate()))
159 // .database( 159 // .database(
160 // SQLiteDatabase::open(get_dirs()?.cache_dir().join("nostr-cache.sqlite")). 160 // SQLiteDatabase::open(get_dirs()?.cache_dir().join("nostr-cache.lmdb")).
161 // await?, ) 161 // await?, )
162 .build(), 162 .build(),
163 fallback_relays: opts.fallback_relays, 163 fallback_relays: opts.fallback_relays,
@@ -732,23 +732,21 @@ fn pb_after_style(succeed: bool) -> indicatif::ProgressStyle {
732 .unwrap() 732 .unwrap()
733} 733}
734 734
735async fn get_local_cache_database(git_repo_path: &Path) -> Result<SQLiteDatabase> { 735async fn get_local_cache_database(git_repo_path: &Path) -> Result<NostrLMDB> {
736 SQLiteDatabase::open(git_repo_path.join(".git/nostr-cache.sqlite")) 736 NostrLMDB::open(git_repo_path.join(".git/nostr-cache.lmdb"))
737 .await 737 .context("cannot open or create nostr cache database at .git/nostr-cache.lmdb")
738 .context("cannot open or create nostr cache database at .git/nostr-cache.sqlite")
739} 738}
740 739
741async fn get_global_cache_database(git_repo_path: &Path) -> Result<SQLiteDatabase> { 740async fn get_global_cache_database(git_repo_path: &Path) -> Result<NostrLMDB> {
742 SQLiteDatabase::open(if std::env::var("NGITTEST").is_err() { 741 NostrLMDB::open(if std::env::var("NGITTEST").is_err() {
743 create_dir_all(get_dirs()?.cache_dir()).context(format!( 742 create_dir_all(get_dirs()?.cache_dir()).context(format!(
744 "cannot create cache directory in: {:?}", 743 "cannot create cache directory in: {:?}",
745 get_dirs()?.cache_dir() 744 get_dirs()?.cache_dir()
746 ))?; 745 ))?;
747 get_dirs()?.cache_dir().join("nostr-cache.sqlite") 746 get_dirs()?.cache_dir().join("nostr-cache.lmdb")
748 } else { 747 } else {
749 git_repo_path.join(".git/test-global-cache.sqlite") 748 git_repo_path.join(".git/test-global-cache.lmdb")
750 }) 749 })
751 .await
752 .context("cannot open ngit global nostr cache database") 750 .context("cannot open ngit global nostr cache database")
753} 751}
754 752
@@ -761,7 +759,7 @@ pub async fn get_events_from_cache(
761 .query(filters.clone()) 759 .query(filters.clone())
762 .await 760 .await
763 .context( 761 .context(
764 "cannot execute query on opened git repo nostr cache database .git/nostr-cache.sqlite", 762 "cannot execute query on opened git repo nostr cache database .git/nostr-cache.lmdb",
765 ) 763 )
766} 764}
767 765