From 2a8e5b65aaa299a5da24970420626b0a333e8a01 Mon Sep 17 00:00:00 2001 From: 4tochka Date: Mon, 6 May 2019 11:01:45 +0400 Subject: [PATCH] connector --- pybtc/connector.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/pybtc/connector.py b/pybtc/connector.py index e051a12..99a3c8b 100644 --- a/pybtc/connector.py +++ b/pybtc/connector.py @@ -357,7 +357,7 @@ class Connector: return self.active_block = asyncio.Future() - self.log.debug("Block %s %s" % (block["height"], block["hash"])) + # self.log.debug("Block %s %s" % (block["height"], block["hash"])) self.cache_loading = True if self.last_block_height < self.app_block_height_on_start else False @@ -497,6 +497,7 @@ class Connector: self.log.debug("Transactions received: %s [%s] received tx rate tx/s ->> %s <<" % (tx_count, time.time() - q, rate)) async def verify_block_position(self, block): + return if "previousblockhash" not in block : return if self.block_headers_cache.len() == 0: @@ -783,6 +784,7 @@ class UTXO(): del self.cached[outpoint] def destroy_utxo(self, block_height): + return block_height -= self.maturity for key in range(self.destroyed_utxo_block + 1, block_height + 1): if key not in self.destroyed: continue @@ -873,6 +875,7 @@ class UTXO(): self._requests += 1 try: i = self.cached.pop(key) + self.destroyed_utxo += 1 # try: # self.destroyed[block_height].add(key) # except: @@ -955,8 +958,8 @@ def decode_block_tx(block): b["strippedSize"] = 80 b["version"] = unpack("L", b["version"]).hex() - b["previousBlockHash"] = rh2s(s.read(32)) - b["merkleRoot"] = rh2s(s.read(32)) + b["previousBlockHash"] = s.read(32) + b["merkleRoot"] = s.read(32) b["time"] = unpack("