From eb9c6f39a42fd0d26f3b3eca5b4ee4ee3a1afbdc Mon Sep 17 00:00:00 2001 From: EggPool Date: Sun, 18 Oct 2020 15:28:51 +0200 Subject: [PATCH] Fix regnet digesting tx twice --- .travis.yml | 2 +- dbhandler.py | 20 +++++++++++++------- digest.py | 1 + node.py | 2 +- tests/test_ledger.py | 2 +- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index d1e051c..05d5c71 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,4 +28,4 @@ after_failure: script: - cd tests - - pytest + - pytest -v diff --git a/dbhandler.py b/dbhandler.py index 4dbd22c..59ff47e 100644 --- a/dbhandler.py +++ b/dbhandler.py @@ -309,14 +309,19 @@ def misc_to_h2(data): self.execute_param(self.h2, self.SQL_TO_MISC, (x[0], x[1])) self.commit(self.hdd2) - try: - + if node.is_regnet: + node.hdd_block = node.last_block + node.hdd_hash = node.last_block_hash + self.logger.app_log.warning(f"Chain: Regnet simulated move to HDD") + return node.logger.app_log.warning(f"Chain: Moving new data to HDD, {node.hdd_block + 1} to {node.last_block} ") - self.execute_param(self.c, "SELECT * FROM transactions WHERE block_height > ? " - "OR block_height < ? ORDER BY block_height ASC", - (node.hdd_block, -node.hdd_block)) + self.execute_param(self.c, + "SELECT * FROM transactions " + "WHERE block_height > ? OR block_height < ? " + "ORDER BY block_height ASC", + (node.hdd_block, -node.hdd_block)) result1 = self.c.fetchall() @@ -324,8 +329,9 @@ def misc_to_h2(data): if node.ram: # we want to save to hyper.db from RAM/hyper.db depending on ram conf transactions_to_h2(result1) - self.execute_param(self.c, "SELECT * FROM misc WHERE block_height > ? ORDER BY block_height ASC", - (node.hdd_block,)) + self.execute_param(self.c, + "SELECT * FROM misc WHERE block_height > ? ORDER BY block_height ASC", + (node.hdd_block, )) result2 = self.c.fetchall() misc_to_h(result2) diff --git a/digest.py b/digest.py index 20665fd..d9c673c 100644 --- a/digest.py +++ b/digest.py @@ -14,6 +14,7 @@ fork = Fork() + def digest_block(node, data, sdef, peer_ip, db_handler): """node param for imports""" diff --git a/node.py b/node.py index ce7ead8..025f330 100644 --- a/node.py +++ b/node.py @@ -11,7 +11,7 @@ # issues with db? perhaps you missed a commit() or two -VERSION = "4.4.0.12" +VERSION = "4.4.0.13" import functools import glob diff --git a/tests/test_ledger.py b/tests/test_ledger.py index 5dabdc2..8379df0 100644 --- a/tests/test_ledger.py +++ b/tests/test_ledger.py @@ -112,7 +112,7 @@ def test_db_blockhash(myserver, verbose=False): sleep(1) data = client.command(command="blocklastjson") if verbose: - print(f"blocklastjson returns {data1}") + print(f"blocklastjson returns {data}") since = data['block_height'] - 2 r = client.command(command="api_getblocksince", options=[since]) if verbose: