mirror of
https://github.com/aljazceru/cdk.git
synced 2025-12-23 23:55:01 +01:00
feat: optimize SQL balance calculation (#1152)
* feat: optimize SQL balance calculation replace proof-fetching approach with SUM aggregation - add get_balance() method to Database trait - implement SQL SUM aggregation in cdk-sql-common - update total_balance() to use get_balance() instead of get_unspent_proofs() - redb impl maintains existing behavior --------- Co-authored-by: thesimplekid <tsk@thesimplekid.com> Co-authored-by: Cesar Rodas <cesar@rodasm.com.py>
This commit is contained in:
@@ -96,6 +96,13 @@ pub trait Database: Debug {
|
||||
state: Option<Vec<State>>,
|
||||
spending_conditions: Option<Vec<SpendingConditions>>,
|
||||
) -> Result<Vec<ProofInfo>, Self::Err>;
|
||||
/// Get balance
|
||||
async fn get_balance(
|
||||
&self,
|
||||
mint_url: Option<MintUrl>,
|
||||
unit: Option<CurrencyUnit>,
|
||||
state: Option<Vec<State>>,
|
||||
) -> Result<u64, Self::Err>;
|
||||
/// Update proofs state in storage
|
||||
async fn update_proofs_state(&self, ys: Vec<PublicKey>, state: State) -> Result<(), Self::Err>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user