From 85be8f76e507990ce26def27582e50c8b267b03a Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Tue, 28 Jan 2020 02:15:11 -0600 Subject: [PATCH] improve formatting in removeblock and blacklist --- src/onionrblocks/onionrblacklist.py | 31 ++++++++++++++++------------- src/onionrstorage/removeblock.py | 24 ++++++++++++++++++++-- 2 files changed, 39 insertions(+), 16 deletions(-) diff --git a/src/onionrblocks/onionrblacklist.py b/src/onionrblocks/onionrblacklist.py index f40c3e3a..544e7d2d 100755 --- a/src/onionrblocks/onionrblacklist.py +++ b/src/onionrblocks/onionrblacklist.py @@ -1,9 +1,15 @@ -''' - Onionr - Private P2P Communication +"""Onionr - Private P2P Communication. - This file handles maintenence of a blacklist database, for blocks and peers -''' -''' +Handle maintenence of a blacklist database, for blocks and peers +""" +import sqlite3 +import os + +from onionrplugins.onionrevents import event +import onionrcrypto +from onionrutils import epoch, bytesconverter +from coredb import dbfiles +""" 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 @@ -16,11 +22,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . -''' -import sqlite3, os -import logger, onionrcrypto -from onionrutils import epoch, bytesconverter -from coredb import dbfiles +""" + class OnionrBlackList: def __init__(self): @@ -57,7 +60,7 @@ class OnionrBlackList: return def deleteExpired(self, dataType=0): - '''Delete expired entries''' + """Delete expired entries""" deleteList = [] curTime = epoch.get_epoch() @@ -78,7 +81,7 @@ class OnionrBlackList: return def clearDB(self): - self._dbExecute('''DELETE FROM blacklist;''') + self._dbExecute("""DELETE FROM blacklist;""") def getList(self): data = self._dbExecute('SELECT * FROM blacklist') @@ -88,11 +91,11 @@ class OnionrBlackList: return myList def addToDB(self, data, dataType=0, expire=0): - '''Add to the blacklist. Intended to be block hash, block data, peers, or transport addresses + """Add to the blacklist. Intended to be block hash, block data, peers, or transport addresses 0=block 1=peer 2=pubkey - ''' + """ # we hash the data so we can remove data entirely from our node's disk hashed = bytesconverter.bytes_to_str(onionrcrypto.hashers.sha3_hash(data)) diff --git a/src/onionrstorage/removeblock.py b/src/onionrstorage/removeblock.py index afe79bf2..49ec846f 100644 --- a/src/onionrstorage/removeblock.py +++ b/src/onionrstorage/removeblock.py @@ -1,14 +1,34 @@ +"""Onionr - Private P2P Communication. + +remove onionr block from meta db +""" import sys, sqlite3 import onionrexceptions, onionrstorage from onionrutils import stringvalidators from coredb import dbfiles from onionrblocks import storagecounter +""" + 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 . +""" + + 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_meta_db, timeout=30)