Skip to content

Commit

Permalink
Drop nostr_last_checked table, remove references (#647)
Browse files Browse the repository at this point in the history
* cdk-sqlite: Drop unused table nostr_last_checked

* cdk-rexie: Drop unused object store nostr_last_checked

* cdk-redb: Remove unused table ref nostr_last_checked
  • Loading branch information
ok300 authored Mar 10, 2025
1 parent 1d42455 commit 1131711
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 55 deletions.
2 changes: 0 additions & 2 deletions crates/cdk-redb/src/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ const MINT_KEYS_TABLE: TableDefinition<&str, &str> = TableDefinition::new("mint_
const PROOFS_TABLE: TableDefinition<&[u8], &str> = TableDefinition::new("proofs");
const CONFIG_TABLE: TableDefinition<&str, &str> = TableDefinition::new("config");
const KEYSET_COUNTER: TableDefinition<&str, u32> = TableDefinition::new("keyset_counter");
const NOSTR_LAST_CHECKED: TableDefinition<&str, u32> = TableDefinition::new("keyset_counter");

const DATABASE_VERSION: u32 = 2;

Expand Down Expand Up @@ -133,7 +132,6 @@ impl WalletRedbDatabase {
let _ = write_txn.open_table(MINT_KEYS_TABLE)?;
let _ = write_txn.open_table(PROOFS_TABLE)?;
let _ = write_txn.open_table(KEYSET_COUNTER)?;
let _ = write_txn.open_table(NOSTR_LAST_CHECKED)?;
table.insert("db_version", DATABASE_VERSION.to_string().as_str())?;
}

Expand Down
54 changes: 1 addition & 53 deletions crates/cdk-rexie/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ const MELT_QUOTES: &str = "melt_quotes";
const PROOFS: &str = "proofs";
const CONFIG: &str = "config";
const KEYSET_COUNTER: &str = "keyset_counter";
const NOSTR_LAST_CHECKED: &str = "nostr_last_check";

const DATABASE_VERSION: u32 = 3;
const DATABASE_VERSION: u32 = 4;

/// Rexie Database Error
#[derive(Debug, Error)]
Expand Down Expand Up @@ -98,7 +97,6 @@ impl WalletRexieDatabase {
.add_object_store(ObjectStore::new(MELT_QUOTES))
.add_object_store(ObjectStore::new(CONFIG))
.add_object_store(ObjectStore::new(KEYSET_COUNTER))
.add_object_store(ObjectStore::new(NOSTR_LAST_CHECKED))
// Build the database
.build()
.await
Expand Down Expand Up @@ -747,54 +745,4 @@ impl WalletDatabase for WalletRexieDatabase {

Ok(current_count)
}

async fn add_nostr_last_checked(
&self,
verifying_key: PublicKey,
last_checked: u32,
) -> Result<(), Self::Err> {
let rexie = self.db.lock().await;

let transaction = rexie
.transaction(&[NOSTR_LAST_CHECKED], TransactionMode::ReadWrite)
.map_err(Error::from)?;

let counter_store = transaction.store(NOSTR_LAST_CHECKED).map_err(Error::from)?;

let verifying_key = serde_wasm_bindgen::to_value(&verifying_key).map_err(Error::from)?;

let last_checked = serde_wasm_bindgen::to_value(&last_checked).map_err(Error::from)?;

counter_store
.put(&last_checked, Some(&verifying_key))
.await
.map_err(Error::from)?;

transaction.done().await.map_err(Error::from)?;

Ok(())
}

async fn get_nostr_last_checked(
&self,
verifying_key: &PublicKey,
) -> Result<Option<u32>, Self::Err> {
let rexie = self.db.lock().await;

let transaction = rexie
.transaction(&[NOSTR_LAST_CHECKED], TransactionMode::ReadOnly)
.map_err(Error::from)?;

let nostr_last_check_store = transaction.store(NOSTR_LAST_CHECKED).map_err(Error::from)?;

let verifying_key = serde_wasm_bindgen::to_value(verifying_key).map_err(Error::from)?;

let last_checked = nostr_last_check_store
.get(verifying_key)
.await
.map_err(Error::from)?
.and_then(|l| serde_wasm_bindgen::from_value(l).ok());

Ok(last_checked)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP TABLE IF EXISTS nostr_last_checked;

0 comments on commit 1131711

Please sign in to comment.