in removeblock calculate size of block before removing it

master
Kevin Froman 2020-09-28 08:19:06 +00:00
parent 6370d07f90
commit ab9726a41a
1 changed files with 1 additions and 1 deletions

View File

@ -35,6 +35,7 @@ def remove_block(block):
**You may want blacklist.addToDB(blockHash) **You may want blacklist.addToDB(blockHash)
""" """
if stringvalidators.validate_hash(block): if stringvalidators.validate_hash(block):
dataSize = sys.getsizeof(onionrstorage.getData(block))
conn = sqlite3.connect( conn = sqlite3.connect(
dbfiles.block_meta_db, timeout=DATABASE_LOCK_TIMEOUT) dbfiles.block_meta_db, timeout=DATABASE_LOCK_TIMEOUT)
c = conn.cursor() c = conn.cursor()
@ -42,7 +43,6 @@ def remove_block(block):
c.execute('Delete from hashes where hash=?;', t) c.execute('Delete from hashes where hash=?;', t)
conn.commit() conn.commit()
conn.close() conn.close()
dataSize = sys.getsizeof(onionrstorage.getData(block))
storage_counter.remove_bytes(dataSize) storage_counter.remove_bytes(dataSize)
else: else:
raise onionrexceptions.InvalidHexHash raise onionrexceptions.InvalidHexHash