parent
8694ab078e
commit
0a2fe2a0b1
|
@ -179,7 +179,8 @@ class OnionrCommunicatorDaemon:
|
||||||
continue
|
continue
|
||||||
self.currentDownloading.append(blockHash)
|
self.currentDownloading.append(blockHash)
|
||||||
logger.info("Attempting to download %s..." % blockHash)
|
logger.info("Attempting to download %s..." % blockHash)
|
||||||
content = self.peerAction(self.pickOnlinePeer(), 'getData', data=blockHash) # block content from random peer (includes metadata)
|
peerUsed = self.pickOnlinePeer()
|
||||||
|
content = self.peerAction(peerUsed, 'getData', data=blockHash) # block content from random peer (includes metadata)
|
||||||
if content != False:
|
if content != False:
|
||||||
try:
|
try:
|
||||||
content = content.encode()
|
content = content.encode()
|
||||||
|
@ -213,6 +214,8 @@ class OnionrCommunicatorDaemon:
|
||||||
tempHash = tempHash.decode()
|
tempHash = tempHash.decode()
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
# Punish peer for sharing invalid block (not always malicious, but is bad regardless)
|
||||||
|
onionrpeers.PeerProfiles(peerUsed, self._core).addScore(-50)
|
||||||
logger.warn('Block hash validation failed for ' + blockHash + ' got ' + tempHash)
|
logger.warn('Block hash validation failed for ' + blockHash + ' got ' + tempHash)
|
||||||
self.blockQueue.remove(blockHash) # remove from block queue both if success or false
|
self.blockQueue.remove(blockHash) # remove from block queue both if success or false
|
||||||
self.currentDownloading.remove(blockHash)
|
self.currentDownloading.remove(blockHash)
|
||||||
|
@ -424,6 +427,7 @@ class OnionrCommunicatorDaemon:
|
||||||
triedPeers.append(peer)
|
triedPeers.append(peer)
|
||||||
url = 'http://' + peer + '/public/upload/'
|
url = 'http://' + peer + '/public/upload/'
|
||||||
data = {'block': block.Block(self.blockToUpload).getRaw()}
|
data = {'block': block.Block(self.blockToUpload).getRaw()}
|
||||||
|
proxyType = ''
|
||||||
if peer.endswith('.onion'):
|
if peer.endswith('.onion'):
|
||||||
proxyType = 'tor'
|
proxyType = 'tor'
|
||||||
elif peer.endswith('.i2p'):
|
elif peer.endswith('.i2p'):
|
||||||
|
|
|
@ -77,6 +77,7 @@ def peerCleanup(coreInst):
|
||||||
raise TypeError('coreInst must be instance of core.Core')
|
raise TypeError('coreInst must be instance of core.Core')
|
||||||
|
|
||||||
logger.info('Cleaning peers...')
|
logger.info('Cleaning peers...')
|
||||||
|
config.reload()
|
||||||
|
|
||||||
minScore = int(config.get('peers.minimumScore'))
|
minScore = int(config.get('peers.minimumScore'))
|
||||||
maxPeers = int(config.get('peers.maxStoredPeers'))
|
maxPeers = int(config.get('peers.maxStoredPeers'))
|
||||||
|
|
Loading…
Reference in New Issue