23 lines
756 B
Python
23 lines
756 B
Python
import sys, sqlite3
|
|
import onionrexceptions, onionrstorage
|
|
from onionrutils import stringvalidators
|
|
from coredb import dbfiles
|
|
import storagecounter
|
|
def remove_block(block):
|
|
'''
|
|
remove a block from this node (does not automatically blacklist)
|
|
|
|
**You may want blacklist.addToDB(blockHash)
|
|
'''
|
|
|
|
if stringvalidators.validate_hash(block):
|
|
conn = sqlite3.connect(dbfiles.block_data_db, timeout=30)
|
|
c = conn.cursor()
|
|
t = (block,)
|
|
c.execute('Delete from hashes where hash=?;', t)
|
|
conn.commit()
|
|
conn.close()
|
|
dataSize = sys.getsizeof(onionrstorage.getData(block))
|
|
storagecounter.StorageCounter().removeBytes(dataSize)
|
|
else:
|
|
raise onionrexceptions.InvalidHexHash |