From 97a0d00bfdbf32fcb049bd74ee2a3499cc563f93 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Sun, 16 Oct 2022 15:04:46 -0400 Subject: [PATCH] faster active amount as of height --- hub/db/db.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hub/db/db.py b/hub/db/db.py index 7c5143c..5f289b7 100644 --- a/hub/db/db.py +++ b/hub/db/db.py @@ -524,11 +524,16 @@ class SecondaryDB: if not v: return 0 return v.activated_sum - v.activated_support_sum + amount = 0 + v = self.prefix_db.effective_amount.get(claim_hash) + if v: + amount = v.activated_sum - v.activated_support_sum for v in self.prefix_db.active_amount.iterate( - start=(claim_hash, ACTIVATED_CLAIM_TXO_TYPE, 0), stop=(claim_hash, ACTIVATED_CLAIM_TXO_TYPE, height), + start=(claim_hash, ACTIVATED_CLAIM_TXO_TYPE, self.db_height + 1), + stop=(claim_hash, ACTIVATED_CLAIM_TXO_TYPE, height), include_key=False, reverse=True): return v.amount - return 0 + return amount def get_effective_amount(self, claim_hash: bytes) -> int: v = self.prefix_db.effective_amount.get(claim_hash)