Onionr/onionr/onionrstorage/removeblock.py

21 lines
719 B
Python
Raw Permalink Normal View History

2019-06-22 22:54:41 +00:00
import sys, sqlite3
import onionrexceptions, onionrstorage
from onionrutils import stringvalidators
2019-06-22 22:54:41 +00:00
def remove_block(core_inst, block):
'''
remove a block from this node (does not automatically blacklist)
**You may want blacklist.addToDB(blockHash)
'''
if stringvalidators.validate_hash(block):
2019-06-22 22:54:41 +00:00
conn = sqlite3.connect(core_inst.blockDB, timeout=30)
c = conn.cursor()
t = (block,)
c.execute('Delete from hashes where hash=?;', t)
conn.commit()
conn.close()
dataSize = sys.getsizeof(onionrstorage.getData(core_inst, block))
core_inst.storage_counter.removeBytes(dataSize)
2019-06-22 22:54:41 +00:00
else:
raise onionrexceptions.InvalidHexHash