pull changes in peer sort order, fixes #228
This commit is contained in:
parent
4549a4be4e
commit
c82efdaff1
4 changed files with 22 additions and 12 deletions
21
oml/nodes.py
21
oml/nodes.py
|
|
@ -22,6 +22,7 @@ from changelog import Changelog
|
|||
from websocket import trigger_event
|
||||
from localnodes import LocalNodes
|
||||
from tor_request import get_opener
|
||||
from utils import user_sort_key
|
||||
import state
|
||||
import db
|
||||
|
||||
|
|
@ -474,11 +475,21 @@ class Nodes(Thread):
|
|||
if state.activity and state.activity.get('activity') == 'import':
|
||||
return
|
||||
self._pulling = True
|
||||
for node in list(self._nodes.values()):
|
||||
if not state.shutdown:
|
||||
node.online = node.can_connect()
|
||||
if not state.shutdown and node.online:
|
||||
node.pullChanges()
|
||||
users = []
|
||||
with db.session():
|
||||
from user.models import User
|
||||
for u in User.query.filter(User.id!=settings.USER_ID).filter_by(peered=True).all():
|
||||
users.append(u.json())
|
||||
users.sort(key=user_sort_key)
|
||||
for u in users:
|
||||
if state.shutdown:
|
||||
break
|
||||
node = self._nodes.get(u['id'])
|
||||
if node:
|
||||
if not state.shutdown:
|
||||
node.online = node.can_connect()
|
||||
if not state.shutdown and node.online:
|
||||
node.pullChanges()
|
||||
self._pulling = False
|
||||
|
||||
def run(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue