Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ĞMixer-py
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pascal Engélibert
ĞMixer-py
Commits
696c75db
Commit
696c75db
authored
5 years ago
by
Pascal Engélibert
Browse files
Options
Downloads
Patches
Plain Diff
Remove old peers
parent
a0ae9040
No related branches found
No related tags found
No related merge requests found
Pipeline
#5750
passed
5 years ago
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
server.py
+15
-0
15 additions, 0 deletions
server.py
with
15 additions
and
0 deletions
server.py
+
15
−
0
View file @
696c75db
...
@@ -604,6 +604,7 @@ class ClientThread(Thread):
...
@@ -604,6 +604,7 @@ class ClientThread(Thread):
utils
.
logprint
(
"
Peer detection: Network error:
"
+
peer
.
to_human_str
(),
utils
.
LOG_WARN
)
utils
.
logprint
(
"
Peer detection: Network error:
"
+
peer
.
to_human_str
(),
utils
.
LOG_WARN
)
# Choose the more recent peer infos
# Choose the more recent peer infos
added_peers
=
False
for
peer
in
new_peers
:
for
peer
in
new_peers
:
new_peer
=
max
(
new_peers
[
peer
],
key
=
lambda
p
:
p
.
sigtime
)
# select the more recent
new_peer
=
max
(
new_peers
[
peer
],
key
=
lambda
p
:
p
.
sigtime
)
# select the more recent
...
@@ -612,9 +613,22 @@ class ClientThread(Thread):
...
@@ -612,9 +613,22 @@ class ClientThread(Thread):
utils
.
logprint
(
"
Peer detection: too old sig
"
,
utils
.
LOG_TRACE
)
utils
.
logprint
(
"
Peer detection: too old sig
"
,
utils
.
LOG_TRACE
)
continue
continue
self
.
peers
[
peer
]
=
new_peer
self
.
peers
[
peer
]
=
new_peer
added_peers
=
True
utils
.
logprint
(
"
Peer:
"
+
new_peer
.
to_human_str
(),
utils
.
LOG_TRACE
)
utils
.
logprint
(
"
Peer:
"
+
new_peer
.
to_human_str
(),
utils
.
LOG_TRACE
)
utils
.
logprint
(
"
Finished peers detection
"
,
utils
.
LOG_TRACE
)
utils
.
logprint
(
"
Finished peers detection
"
,
utils
.
LOG_TRACE
)
# Remove old peers
if
added_peers
:
t
=
time
.
time
()
-
self
.
conf
[
"
server
"
][
"
peer_sig_age_max
"
]
to_remove
=
[]
for
peer
in
self
.
peers
:
if
self
.
peers
[
peer
].
sigtime
<
t
:
to_remove
.
append
(
peer
)
for
peer
in
to_remove
:
utils
.
logprint
(
"
Remove old peer:
"
+
self
.
peers
[
peer
].
to_human_str
(),
utils
.
LOG_TRACE
)
self
.
peers
.
pop
(
peer
)
def
spread_peer_info
(
self
):
def
spread_peer_info
(
self
):
utils
.
logprint
(
"
Start spreading peer info
"
,
utils
.
LOG_TRACE
)
utils
.
logprint
(
"
Start spreading peer info
"
,
utils
.
LOG_TRACE
)
...
@@ -832,6 +846,7 @@ def main():
...
@@ -832,6 +846,7 @@ def main():
peers
=
{}
peers
=
{}
db_peers
=
plyvel
.
DB
(
DIR
+
"
/db_peers
"
,
create_if_missing
=
True
)
db_peers
=
plyvel
.
DB
(
DIR
+
"
/db_peers
"
,
create_if_missing
=
True
)
utils
.
load_peers
(
conf
,
db_peers
,
peers
)
utils
.
load_peers
(
conf
,
db_peers
,
peers
)
utils
.
logprint
(
"
Loaded
"
+
str
(
len
(
peers
))
+
"
peers
"
,
utils
.
LOG_TRACE
)
# Load txs
# Load txs
pool
=
[]
pool
=
[]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment