X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=backends%2Fbitcoind%2Fstorage.py;h=098d12e61484e5ba90e9516d5c4916df2ab020c3;hb=d0439647dfc60efce32e0a13b0ec02428ba412cf;hp=7658b4988feaf75a1093bbbd1cd1f5834fa2f74c;hpb=f758aa692b0f6eb5826afe30b013f98aa77ad5ba;p=electrum-server.git diff --git a/backends/bitcoind/storage.py b/backends/bitcoind/storage.py index 7658b49..098d12e 100644 --- a/backends/bitcoind/storage.py +++ b/backends/bitcoind/storage.py @@ -33,7 +33,7 @@ class Storage(object): traceback.print_exc(file=sys.stdout) self.shared.stop() - self.db_version = 2 # increase this when database needs to be updated + self.db_version = 3 # increase this when database needs to be updated try: self.last_hash, self.height, db_version = ast.literal_eval(self.db_undo.get('height')) print_log("Database version", self.db_version) @@ -42,7 +42,7 @@ class Storage(object): #traceback.print_exc(file=sys.stdout) print_log('initializing database') self.height = 0 - self.last_hash = '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f' + self.last_hash = '00000a060336cbb72fe969666d337b87198b1add2abaa59cca226820b32933a4' db_version = self.db_version # write root self.put_node('', {}) @@ -144,8 +144,7 @@ class Storage(object): def get_address(self, txi): - addr = self.db_addr.get(txi) - return self.key_to_address(addr) if addr else None + return self.db_addr.get(txi) def get_undo_info(self, height): @@ -492,7 +491,7 @@ class Storage(object): self.add_address(key + txo, value, tx_height) # backlink - self.db_addr.put(txo, key) + self.db_addr.put(txo, addr) @@ -507,6 +506,13 @@ class Storage(object): self.db_addr.delete(txo) + def get_utxo_value(self, addr, txi): + key = self.address_to_key(addr) + leaf = key + txi + s = self.db_utxo.get(leaf) + value = hex_to_int(s[0:8]) + return value + def set_spent(self, addr, txi, txid, index, height, undo): key = self.address_to_key(addr) @@ -535,7 +541,7 @@ class Storage(object): leaf = key + txi # restore backlink - self.db_addr.put(txi, key) + self.db_addr.put(txi, addr) v, height = undo.pop(leaf) self.add_address(leaf, v, height)