fix: implement atomic keyset counter

- remove get_keyset_counter
- update increment_keyset_counter to atomically increment and return counter value
- replace get+increment pattern with atomic increment everywhere
This commit is contained in:
vnprc
2025-08-08 18:59:16 -04:00
committed by thesimplekid
parent 51b26eae62
commit 5b30ca546d
7 changed files with 152 additions and 114 deletions

View File

@@ -99,10 +99,8 @@ pub trait Database: Debug {
/// Update proofs state in storage
async fn update_proofs_state(&self, ys: Vec<PublicKey>, state: State) -> Result<(), Self::Err>;
/// Increment Keyset counter
async fn increment_keyset_counter(&self, keyset_id: &Id, count: u32) -> Result<(), Self::Err>;
/// Get current Keyset counter
async fn get_keyset_counter(&self, keyset_id: &Id) -> Result<u32, Self::Err>;
/// Atomically increment Keyset counter and return new value
async fn increment_keyset_counter(&self, keyset_id: &Id, count: u32) -> Result<u32, Self::Err>;
/// Add transaction to storage
async fn add_transaction(&self, transaction: Transaction) -> Result<(), Self::Err>;