aboutsummaryrefslogtreecommitdiff
path: root/qa/rpc-tests/test_framework/blockstore.py
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2016-03-19 20:58:06 +0100
committerMarcoFalke <falke.marco@gmail.com>2016-05-05 15:43:37 +0200
commitfa389d4edc367073e2ccc6d1f0790c4b72ba17f2 (patch)
tree3bc22860769bb62b3679dbd185940cf3df9f890e /qa/rpc-tests/test_framework/blockstore.py
parent3b9a0bf41f2336b09e854522ab1ce6dcfc7a3050 (diff)
downloadbitcoin-fa389d4edc367073e2ccc6d1f0790c4b72ba17f2.tar.xz
[qa] Switch to py3
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 = []