2019-06-22 22:54:41 +00:00
|
|
|
import sys, sqlite3
|
|
|
|
import onionrexceptions, onionrstorage
|
2019-06-25 23:07:35 +00:00
|
|
|
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)
|
|
|
|
'''
|
|
|
|
|
2019-06-25 23:07:35 +00:00
|
|
|
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))
|
2019-06-25 23:07:35 +00:00
|
|
|
core_inst.storage_counter.removeBytes(dataSize)
|
2019-06-22 22:54:41 +00:00
|
|
|
else:
|
|
|
|
raise onionrexceptions.InvalidHexHash
|