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-07-19 19:49:56 +00:00
|
|
|
from coredb import dbfiles
|
2019-09-21 23:49:24 +00:00
|
|
|
from onionrblocks import storagecounter
|
2019-07-19 19:49:56 +00:00
|
|
|
def remove_block(block):
|
2019-06-22 22:54:41 +00:00
|
|
|
'''
|
|
|
|
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-07-28 05:33:26 +00:00
|
|
|
conn = sqlite3.connect(dbfiles.block_meta_db, timeout=30)
|
2019-06-22 22:54:41 +00:00
|
|
|
c = conn.cursor()
|
|
|
|
t = (block,)
|
|
|
|
c.execute('Delete from hashes where hash=?;', t)
|
|
|
|
conn.commit()
|
|
|
|
conn.close()
|
2019-07-19 19:49:56 +00:00
|
|
|
dataSize = sys.getsizeof(onionrstorage.getData(block))
|
2019-09-08 09:48:16 +00:00
|
|
|
storagecounter.StorageCounter().remove_bytes(dataSize)
|
2019-06-22 22:54:41 +00:00
|
|
|
else:
|
|
|
|
raise onionrexceptions.InvalidHexHash
|