From 556e47ce94e10c5388308e52922705f127e480fb Mon Sep 17 00:00:00 2001 From: 4tochka Date: Wed, 8 May 2019 13:36:22 +0400 Subject: [PATCH] connector --- .../lib.macosx-10.9-x86_64-3.7/pybtc/connector.py | 10 +++++----- pybtc/connector/utxo.py | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/build/lib.macosx-10.9-x86_64-3.7/pybtc/connector.py b/build/lib.macosx-10.9-x86_64-3.7/pybtc/connector.py index 59109e9..9ff4f36 100644 --- a/build/lib.macosx-10.9-x86_64-3.7/pybtc/connector.py +++ b/build/lib.macosx-10.9-x86_64-3.7/pybtc/connector.py @@ -377,11 +377,11 @@ class Connector: self.block_headers_cache.set(block["hash"], block["height"]) self.last_block_height = block["height"] - # if self.utxo_data: - # if not self.deep_synchronization: - # self.utxo.destroy_utxo(block["height"]) - # elif block["height"] % 500 == 0: - # self.utxo.destroy_utxo(block["height"]) + if self.utxo_data: + if not self.deep_synchronization: + self.utxo.destroy_utxo(block["height"]) + elif block["height"] % 500 == 0: + self.utxo.destroy_utxo(block["height"]) self.blocks_processed_count += 1 diff --git a/pybtc/connector/utxo.py b/pybtc/connector/utxo.py index d43212f..200bd66 100644 --- a/pybtc/connector/utxo.py +++ b/pybtc/connector/utxo.py @@ -43,6 +43,20 @@ class UTXO(): del self.cached[outpoint] def destroy_utxo(self, block_height): + for outpoint in self.destroyed: + try: + del self.cached[outpoint] + self.destroyed_utxo += 1 + except: + try: + del self.loaded[outpoint] + self.destroyed_utxo += 1 + except: + self.destroyed_utxo += 1 + pass + + return + block_height -= self.maturity for key in range(self.destroyed_utxo_block + 1, block_height + 1): if key not in self.destroyed: continue