Skip to content

Commit

Permalink
separate mempool for testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
hclivess committed Aug 25, 2019
1 parent 30acfe6 commit 69fd3aa
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions mempool.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,14 @@ def __init__(self, app_log, config=None, db_lock=None, testnet=False, trace_db_c
self.trace_db_calls = trace_db_calls

self.testnet = testnet
if not self.testnet:
self.mempool_ram_file = "file:mempool?mode=memory&cache=shared"
else:

if self.testnet:
app_log.warning("Starting mempool in testnet mode")
self.mempool_path = "mempool_testnet.db"
self.mempool_ram_file = "file:mempool_testnet?mode=memory&cache=shared"
else:
self.mempool_ram_file = "file:mempool?mode=memory&cache=shared"
self.mempool_path = self.config.mempool_path #default

self.check()

Expand Down Expand Up @@ -153,7 +156,7 @@ def check(self):
self.db.commit()
self.app_log.warning("Status: In memory mempool file created")
else:
self.db = sqlite3.connect(self.config.mempool_path, timeout=1,
self.db = sqlite3.connect(self.mempool_path, timeout=1,
check_same_thread=False)
if self.trace_db_calls:
self.db.set_trace_callback(functools.partial(sql_trace_callback,self.app_log,"MEMPOOL"))
Expand All @@ -166,8 +169,8 @@ def check(self):
# print(res)
if len(res) != 9:
self.db.close()
os.remove(self.config.mempool_path)
self.db = sqlite3.connect(self.config.mempool_path, timeout=1,
os.remove(self.mempool_path)
self.db = sqlite3.connect(self.mempool_path, timeout=1,
check_same_thread=False)
if self.trace_db_calls:
self.db.set_trace_callback(functools.partial(sql_trace_callback,self.app_log,"MEMPOOL"))
Expand Down

0 comments on commit 69fd3aa

Please sign in to comment.