From 91c1e223244439e6d130eabd232182d7d7f749e2 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Thu, 16 Aug 2018 22:30:36 -0500 Subject: [PATCH] do not duplicate blacklist entries --- onionr/communicator2.py | 7 +++++-- onionr/onionrblacklist.py | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/onionr/communicator2.py b/onionr/communicator2.py index 5a6aeee6..1f2166ac 100755 --- a/onionr/communicator2.py +++ b/onionr/communicator2.py @@ -215,8 +215,11 @@ class OnionrCommunicatorDaemon: else: logger.warn('POW failed for block ' + blockHash) else: - logger.warn('Metadata for ' + blockHash + ' is invalid.') - self._core._blacklist.addToDB(blockHash) + if self._core._blacklist.inBlacklist(realHash): + logger.warn('%s is blacklisted' % (realHash,)) + else: + logger.warn('Metadata for ' + blockHash + ' is invalid.') + self._core._blacklist.addToDB(blockHash) else: # if block didn't meet expected hash tempHash = self._core._crypto.sha3Hash(content) # lazy hack, TODO use var diff --git a/onionr/onionrblacklist.py b/onionr/onionrblacklist.py index bb990cce..86823283 100644 --- a/onionr/onionrblacklist.py +++ b/onionr/onionrblacklist.py @@ -95,6 +95,10 @@ class OnionrBlackList: ''' # we hash the data so we can remove data entirely from our node's disk hashed = self._core._utils.bytesToStr(self._core._crypto.sha3Hash(data)) + + if self.inBlacklist(hashed): + return + if not hashed.isalnum(): raise Exception("Hashed data is not alpha numeric") try: