Remove stale DEFAULT_NODES
This commit is contained in:
parent
e845aa8b00
commit
c70a9b2d82
|
@ -36,18 +36,6 @@ knownNodesActual = False
|
||||||
|
|
||||||
logger = logging.getLogger('default')
|
logger = logging.getLogger('default')
|
||||||
|
|
||||||
DEFAULT_NODES = (
|
|
||||||
Peer('5.45.99.75', 8444),
|
|
||||||
Peer('75.167.159.54', 8444),
|
|
||||||
Peer('95.165.168.168', 8444),
|
|
||||||
Peer('85.180.139.241', 8444),
|
|
||||||
Peer('158.222.217.190', 8080),
|
|
||||||
Peer('178.62.12.187', 8448),
|
|
||||||
Peer('24.188.198.204', 8111),
|
|
||||||
Peer('109.147.204.113', 1195),
|
|
||||||
Peer('178.11.46.221', 8444)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def json_serialize_knownnodes(output):
|
def json_serialize_knownnodes(output):
|
||||||
"""
|
"""
|
||||||
|
@ -73,8 +61,7 @@ def json_deserialize_knownnodes(source):
|
||||||
info = node['info']
|
info = node['info']
|
||||||
peer = Peer(str(peer['host']), peer.get('port', 8444))
|
peer = Peer(str(peer['host']), peer.get('port', 8444))
|
||||||
knownNodes[node['stream']][peer] = info
|
knownNodes[node['stream']][peer] = info
|
||||||
if not (knownNodesActual
|
if not (knownNodesActual or info.get('self')):
|
||||||
or info.get('self')) and peer not in DEFAULT_NODES:
|
|
||||||
knownNodesActual = True
|
knownNodesActual = True
|
||||||
|
|
||||||
|
|
||||||
|
@ -142,14 +129,6 @@ def addKnownNode(stream, peer, lastseen=None, is_self=False):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def createDefaultKnownNodes():
|
|
||||||
"""Creating default Knownnodes"""
|
|
||||||
past = time.time() - 2418600 # 28 days - 10 min
|
|
||||||
for peer in DEFAULT_NODES:
|
|
||||||
addKnownNode(1, peer, past)
|
|
||||||
saveKnownNodes()
|
|
||||||
|
|
||||||
|
|
||||||
def readKnownNodes():
|
def readKnownNodes():
|
||||||
"""Load knownnodes from filesystem"""
|
"""Load knownnodes from filesystem"""
|
||||||
try:
|
try:
|
||||||
|
@ -163,7 +142,6 @@ def readKnownNodes():
|
||||||
except (IOError, OSError, KeyError, EOFError):
|
except (IOError, OSError, KeyError, EOFError):
|
||||||
logger.debug(
|
logger.debug(
|
||||||
'Failed to read nodes from knownnodes.dat', exc_info=True)
|
'Failed to read nodes from knownnodes.dat', exc_info=True)
|
||||||
createDefaultKnownNodes()
|
|
||||||
|
|
||||||
config = BMConfigParser()
|
config = BMConfigParser()
|
||||||
|
|
||||||
|
@ -221,13 +199,6 @@ def trimKnownNodes(recAddrStream=1):
|
||||||
del knownNodes[recAddrStream][oldest]
|
del knownNodes[recAddrStream][oldest]
|
||||||
|
|
||||||
|
|
||||||
def dns():
|
|
||||||
"""Add DNS names to knownnodes"""
|
|
||||||
for port in [8080, 8444]:
|
|
||||||
addKnownNode(
|
|
||||||
1, Peer('bootstrap%s.bitmessage.org' % port, port))
|
|
||||||
|
|
||||||
|
|
||||||
def cleanupKnownNodes():
|
def cleanupKnownNodes():
|
||||||
"""
|
"""
|
||||||
Cleanup knownnodes: remove old nodes and nodes with low rating
|
Cleanup knownnodes: remove old nodes and nodes with low rating
|
||||||
|
|
|
@ -154,14 +154,6 @@ class TestCore(unittest.TestCase):
|
||||||
self_count += 1
|
self_count += 1
|
||||||
self.assertEqual(n - self_count, 2)
|
self.assertEqual(n - self_count, 2)
|
||||||
|
|
||||||
def test_knownnodes_default(self):
|
|
||||||
"""test adding default knownnodes if nothing loaded"""
|
|
||||||
cleanup(files=('knownnodes.dat',))
|
|
||||||
self._wipe_knownnodes()
|
|
||||||
knownnodes.readKnownNodes()
|
|
||||||
self.assertGreaterEqual(
|
|
||||||
len(knownnodes.knownNodes[1]), len(knownnodes.DEFAULT_NODES))
|
|
||||||
|
|
||||||
def test_0_cleaner(self):
|
def test_0_cleaner(self):
|
||||||
"""test knownnodes starvation leading to IndexError in Asyncore"""
|
"""test knownnodes starvation leading to IndexError in Asyncore"""
|
||||||
self._outdate_knownnodes()
|
self._outdate_knownnodes()
|
||||||
|
|
Reference in New Issue
Block a user