Why self.blockIndexes returns an empty list?
in blockchain.py:
def __getBlockIndexes(self, index):
"""There is no method of leveldb to close the db (and release the lock).
This creates problem during concurrent operations.
This function also provides caching of indexes.
"""
if self.indexPath != index:
db = plyvel.DB(index, compression=None)
print("%s" % (str(db))) # added by me and it returns <plyvel.DB with name 'something' at somewhere>
self.blockIndexes = [DBBlockIndex(format_hash(k[1:]), v)
for k, v in db.iterator() if k[0] == ord('b')]
db.close()
self.blockIndexes.sort(key=lambda x: x.height)
self.indexPath = index
return self.blockIndexes
returned self.blockIndexes is an empty list. Wondering why? If you still maintaining this code pls reply!
Are you providing the path to the index part of the datadir of a full node to Blockchain?
Are you providing the path to the index part of the datadir of a full node to
Blockchain?
this is how I use this parser:
import os from blockchain_parser.blockchain import Blockchain
blockchain = Blockchain(os.path.expanduser('/mnt/g/blockchains/blocks')) for block in blockchain.get_ordered_blocks(os.path.expanduser('/mnt/g/blockchains/blocks/index'), end=1000): print("height=%d block=%s" % (block.height, block.hash))
Are you providing the path to the index part of the datadir of a full node to
Blockchain?
Thank you for reply but is that means I uses this parser wrong? If wrong how can I change my code?
I have the same problem.
Sorry, my fault. I missed that a start of ordered blocks was > end. I remember this error before so it could be useful for all to check their ordered blocks interval while there is no error message.
I got the following
Traceback (most recent call last):
File "main.py", line 29, in <module>
for block in blockchain.get_ordered_blocks(os.path.expanduser(base + '/testnet3/blocks/index'), end=END_BLOCK):
File "/mnt/6da521ae-93b2-44d6-bd41-422c135def79/devEnv/ventureum/projects/python-bitcoin-blockchain-parser/blockchain_parser/blockchain.py", line 167, in get_ordered_blocks
blockIndexes = self.__getBlockIndexes(index)
File "/mnt/6da521ae-93b2-44d6-bd41-422c135def79/devEnv/ventureum/projects/python-bitcoin-blockchain-parser/blockchain_parser/blockchain.py", line 102, in __getBlockIndexes
for k, v in db.iterator() if True]
File "/mnt/6da521ae-93b2-44d6-bd41-422c135def79/devEnv/ventureum/projects/python-bitcoin-blockchain-parser/blockchain_parser/index.py", line 31, in __init__
n_version, i = _read_varint(raw_hex[pos:])
File "/mnt/6da521ae-93b2-44d6-bd41-422c135def79/devEnv/ventureum/projects/python-bitcoin-blockchain-parser/blockchain_parser/index.py", line 21, in _read_varint
n = (n << 7) | (data & 0x7f)
TypeError: unsupported operand type(s) for &: 'str' and 'int'
weird