21 lines
571 B
Python
21 lines
571 B
Python
import os
|
|
|
|
from leveldir.numeric import NumDir
|
|
from leveldir.hex import HexDir
|
|
|
|
class FileTxStore:
|
|
|
|
subdivision = 100000
|
|
|
|
def __init__(self, store_base_path):
|
|
tx_base_path = os.path.join(store_base_path, 'tx')
|
|
num_base_path = os.path.join(tx_base_path, 'blocks')
|
|
hash_base_path = os.path.join(tx_base_path, 'hash')
|
|
self.block_index_dir = NumDir(num_base_path)
|
|
self.hash_index_dir = HexDir(hash_base_path, 32)
|
|
|
|
|
|
def put(self, k, v):
|
|
hsh = bytes.fromhex(k)
|
|
self.hash_index_dir.add(hsh, v.encode('utf-8'))
|