There's no point defining connection parameters for a peer unless
something's going to act on them, and that something is watch(8). On
startup (the `--startup' switch), we're meant to notice existing peers
(probably established by connect(8)) and ensure that they're set up
properly. This initial pass over the peer list is done by
Pinger.rescan, which /usually/ is interested only in watched peers that
need pinging. It therefore ignores unwatched peers, with the result
that pre-existing unwatched peers are left unconfigured. Subsequent
peers are detected through the notification mechanism and processed by
the addpeers function which works correctly.
Now, if startup is set, Pinger.rescan tracks all peers and invokes
addpeer on them.
The code relies on the fact that a startup scan is done only once, when
the peer list is empty. Otherwise it'll reconfigure existing peers,
which is probably a mistake.
"""
if T._debug: print '# rescan peers'
correct = {}
"""
if T._debug: print '# rescan peers'
correct = {}
for peer in S.list():
try:
info = peerinfo(peer)
for peer in S.list():
try:
info = peerinfo(peer)
continue
if boolean(info, 'watch', False):
if T._debug: print '# interesting peer %s' % peer
continue
if boolean(info, 'watch', False):
if T._debug: print '# interesting peer %s' % peer
+ correct[peer] = start[peer] = info
+ elif startup:
+ if T._debug: print '# peer %s ready for adoption' % peer
+ start[peer] = info
for peer, obj in me._peers.items():
if peer in correct:
obj.update(correct[peer])
else:
if T._debug: print '# peer %s vanished' % peer
del me._peers[peer]
for peer, obj in me._peers.items():
if peer in correct:
obj.update(correct[peer])
else:
if T._debug: print '# peer %s vanished' % peer
del me._peers[peer]
- for peer, info in correct.iteritems():
+ for peer, info in start.iteritems():
if peer not in me._peers:
if startup:
if T._debug: print '# setting up peer %s' % peer
if peer not in me._peers:
if startup:
if T._debug: print '# setting up peer %s' % peer