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
|
|
|
|
import storagecounter
|
|
|
|
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))
|
|
|
|
storagecounter.StorageCounter().removeBytes(dataSize)
|
2019-06-22 22:54:41 +00:00
|
|
|
else:
|
|
|
|
raise onionrexceptions.InvalidHexHash
|