aboutsummaryrefslogtreecommitdiff
path: root/qa/rpc-tests/test_framework/blockstore.py
diff options
context:
space:
mode:
Diffstat (limited to 'qa/rpc-tests/test_framework/blockstore.py')
-rw-r--r--qa/rpc-tests/test_framework/blockstore.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/qa/rpc-tests/test_framework/blockstore.py b/qa/rpc-tests/test_framework/blockstore.py
index 73d9ffbb2f..4bc279032b 100644
--- a/qa/rpc-tests/test_framework/blockstore.py
+++ b/qa/rpc-tests/test_framework/blockstore.py
@@ -1,16 +1,17 @@
+#!/usr/bin/env python3
# BlockStore: a helper class that keeps a map of blocks and implements
# helper functions for responding to getheaders and getdata,
# and for constructing a getheaders message
#
from .mininode import *
-import dbm
from io import BytesIO
+import dbm.ndbm
class BlockStore(object):
def __init__(self, datadir):
- self.blockDB = dbm.open(datadir + "/blocks", 'c')
- self.currentBlock = 0L
+ self.blockDB = dbm.ndbm.open(datadir + "/blocks", 'c')
+ self.currentBlock = 0
self.headers_map = dict()
def close(self):
@@ -67,7 +68,7 @@ class BlockStore(object):
try:
self.blockDB[repr(block.sha256)] = bytes(block.serialize())
except TypeError as e:
- print "Unexpected error: ", sys.exc_info()[0], e.args
+ print("Unexpected error: ", sys.exc_info()[0], e.args)
self.currentBlock = block.sha256
self.headers_map[block.sha256] = CBlockHeader(block)
@@ -105,7 +106,7 @@ class BlockStore(object):
class TxStore(object):
def __init__(self, datadir):
- self.txDB = dbm.open(datadir + "/transactions", 'c')
+ self.txDB = dbm.ndbm.open(datadir + "/transactions", 'c')
def close(self):
self.txDB.close()
@@ -127,7 +128,7 @@ class TxStore(object):
try:
self.txDB[repr(tx.sha256)] = bytes(tx.serialize())
except TypeError as e:
- print "Unexpected error: ", sys.exc_info()[0], e.args
+ print("Unexpected error: ", sys.exc_info()[0], e.args)
def get_transactions(self, inv):
responses = []