2019-06-01 16:54:36 +00:00
|
|
|
'''
|
2019-06-12 20:12:56 +00:00
|
|
|
Onionr - Private P2P Communication
|
2019-06-01 16:54:36 +00:00
|
|
|
|
|
|
|
This file contains the command for banning blocks from the node
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
'''
|
|
|
|
import sys
|
|
|
|
import logger
|
|
|
|
def ban_block(o_inst):
|
|
|
|
try:
|
|
|
|
ban = sys.argv[2]
|
|
|
|
except IndexError:
|
|
|
|
ban = logger.readline('Enter a block hash:')
|
|
|
|
if o_inst.onionrUtils.validateHash(ban):
|
|
|
|
if not o_inst.onionrCore._blacklist.inBlacklist(ban):
|
|
|
|
try:
|
|
|
|
o_inst.onionrCore._blacklist.addToDB(ban)
|
|
|
|
o_inst.onionrCore.removeBlock(ban)
|
|
|
|
except Exception as error:
|
2019-06-19 20:29:27 +00:00
|
|
|
logger.error('Could not blacklist block', error=error, terminal=True)
|
2019-06-01 16:54:36 +00:00
|
|
|
else:
|
2019-06-19 20:29:27 +00:00
|
|
|
logger.info('Block blacklisted', terminal=True)
|
2019-06-01 16:54:36 +00:00
|
|
|
else:
|
2019-06-19 20:29:27 +00:00
|
|
|
logger.warn('That block is already blacklisted', terminal=True)
|
2019-06-01 16:54:36 +00:00
|
|
|
else:
|
2019-06-19 20:29:27 +00:00
|
|
|
logger.error('Invalid block hash', terminal=True)
|