+ blocks can now be blacklisted
* Peers sync a little better
This commit is contained in:
parent
12d39393b4
commit
5f21d15cdd
@ -173,7 +173,7 @@ class OnionrCommunicatorDaemon:
|
||||
# if newline seperated string is valid hash
|
||||
if not i in existingBlocks:
|
||||
# if block does not exist on disk and is not already in block queue
|
||||
if i not in self.blockQueue:
|
||||
if i not in self.blockQueue and not self._core._blacklist.inBlacklist(i):
|
||||
self.blockQueue.append(i)
|
||||
self.decrementThreadCount('lookupBlocks')
|
||||
return
|
||||
@ -289,6 +289,7 @@ class OnionrCommunicatorDaemon:
|
||||
for i in self._core.bootstrapList:
|
||||
if i not in peerList and i not in self.offlinePeers and i != self._core.hsAddress:
|
||||
peerList.append(i)
|
||||
self._core.addAddress(i)
|
||||
|
||||
def connectNewPeer(self, peer='', useBootstrap=False):
|
||||
'''Adds a new random online peer to self.onlinePeers'''
|
||||
|
@ -172,7 +172,7 @@ class Core:
|
||||
|
||||
def removeBlock(self, block):
|
||||
'''
|
||||
remove a block from this node
|
||||
remove a block from this node (does not automatically blacklist)
|
||||
'''
|
||||
if self._utils.validateHash(block):
|
||||
conn = sqlite3.connect(self.blockDB)
|
||||
|
@ -232,6 +232,7 @@ class Onionr:
|
||||
'listconn': 'list connected peers',
|
||||
'kex': 'exchange keys with peers (done automatically)',
|
||||
'pex': 'exchange addresses with peers (done automatically)',
|
||||
'blacklist-block': 'deletes a block by hash and permanently removes it from your node',
|
||||
'introduce': 'Introduce your node to the public Onionr network',
|
||||
}
|
||||
|
||||
@ -264,15 +265,22 @@ class Onionr:
|
||||
try:
|
||||
ban = sys.argv[2]
|
||||
except IndexError:
|
||||
while True:
|
||||
ban = logger.readline('Enter a block hash:')
|
||||
if self.onionrUtils.validateHash(ban):
|
||||
if not self.onionrCore._blacklist.inBlacklist(ban):
|
||||
self.onionrCore._blacklist.addToDB(ban)
|
||||
|
||||
ban = logger.readline('Enter a block hash:')
|
||||
if self.onionrUtils.validateHash(ban):
|
||||
if not self.onionrCore._blacklist.inBlacklist(ban):
|
||||
try:
|
||||
self.onionrCore._blacklist.addToDB(ban)
|
||||
self.onionrCore.removeBlock(ban)
|
||||
except Exception as error:
|
||||
logger.error('Could not blacklist block', error=error)
|
||||
else:
|
||||
logger.info('Block blacklisted')
|
||||
else:
|
||||
logger.warn('That block is already blacklisted')
|
||||
else:
|
||||
logger.error('Invalid block hash')
|
||||
return
|
||||
|
||||
|
||||
def listConn(self):
|
||||
self.onionrCore.daemonQueueAdd('connectedPeers')
|
||||
|
||||
|
@ -25,7 +25,6 @@ class OnionrBlackList:
|
||||
|
||||
if not os.path.exists(self.blacklistDB):
|
||||
self.generateDB()
|
||||
|
||||
return
|
||||
|
||||
def inBlacklist(self, data):
|
||||
|
Loading…
Reference in New Issue
Block a user