Skip to content

Commit

Permalink
Fix regnet digesting tx twice
Browse files Browse the repository at this point in the history
  • Loading branch information
EggPool committed Oct 18, 2020
1 parent e9d6fc5 commit eb9c6f3
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ after_failure:

script:
- cd tests
- pytest
- pytest -v
20 changes: 13 additions & 7 deletions dbhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,23 +309,29 @@ 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()

transactions_to_h(result1)
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)
Expand Down
1 change: 1 addition & 0 deletions digest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

fork = Fork()


def digest_block(node, data, sdef, peer_ip, db_handler):
"""node param for imports"""

Expand Down
2 changes: 1 addition & 1 deletion node.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/test_ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit eb9c6f3

Please sign in to comment.