Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
sakia
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor 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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
clients
python
sakia
Commits
40fae940
Commit
40fae940
authored
9 years ago
by
inso
Browse files
Options
Downloads
Patches
Plain Diff
Fix network discovery
parent
6e7763bd
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/cutecoin/core/net/network.py
+2
-2
2 additions, 2 deletions
src/cutecoin/core/net/network.py
src/cutecoin/core/net/node.py
+9
-3
9 additions, 3 deletions
src/cutecoin/core/net/node.py
with
11 additions
and
5 deletions
src/cutecoin/core/net/network.py
+
2
−
2
View file @
40fae940
...
@@ -202,7 +202,7 @@ class Network(QObject):
...
@@ -202,7 +202,7 @@ class Network(QObject):
blocks_occurences
=
Counter
(
blocks
)
blocks_occurences
=
Counter
(
blocks
)
blocks_by_occurences
=
{}
blocks_by_occurences
=
{}
for
key
,
value
in
blocks_occurences
.
items
():
for
key
,
value
in
blocks_occurences
.
items
():
the_block
=
[
n
.
block
for
n
in
self
.
nodes
if
n
.
block
[
'
hash
'
]
==
key
][
0
]
the_block
=
[
n
.
block
for
n
in
self
.
nodes
if
n
.
block
and
n
.
block
[
'
hash
'
]
==
key
][
0
]
if
value
not
in
blocks_by_occurences
:
if
value
not
in
blocks_by_occurences
:
blocks_by_occurences
[
value
]
=
[
the_block
]
blocks_by_occurences
[
value
]
=
[
the_block
]
else
:
else
:
...
@@ -244,7 +244,7 @@ class Network(QObject):
...
@@ -244,7 +244,7 @@ class Network(QObject):
synced_block_hash
=
blocks_by_occurences
[
most_present
][
0
][
'
hash
'
]
synced_block_hash
=
blocks_by_occurences
[
most_present
][
0
][
'
hash
'
]
for
n
in
[
n
for
n
in
self
.
_nodes
if
n
.
state
in
(
Node
.
ONLINE
,
Node
.
DESYNCED
)]:
for
n
in
[
n
for
n
in
self
.
_nodes
if
n
.
state
in
(
Node
.
ONLINE
,
Node
.
DESYNCED
)]:
if
n
.
block
[
'
hash
'
]
==
synced_block_hash
:
if
n
.
block
and
n
.
block
[
'
hash
'
]
==
synced_block_hash
:
n
.
state
=
Node
.
ONLINE
n
.
state
=
Node
.
ONLINE
else
:
else
:
n
.
state
=
Node
.
DESYNCED
n
.
state
=
Node
.
DESYNCED
...
...
This diff is collapsed.
Click to expand it.
src/cutecoin/core/net/node.py
+
9
−
3
View file @
40fae940
...
@@ -99,7 +99,7 @@ class Node(QObject):
...
@@ -99,7 +99,7 @@ class Node(QObject):
raise
InvalidNodeCurrency
(
peer
.
currency
,
currency
)
raise
InvalidNodeCurrency
(
peer
.
currency
,
currency
)
node
=
cls
(
peer
.
currency
,
peer
.
endpoints
,
node
=
cls
(
peer
.
currency
,
peer
.
endpoints
,
""
,
pubkey
,
bma
.
blockchain
.
Block
.
null_valu
e
,
""
,
pubkey
,
Non
e
,
Node
.
ONLINE
,
time
.
time
(),
Node
.
ONLINE
,
time
.
time
(),
{
'
root
'
:
""
,
'
leaves
'
:
[]},
{
'
root
'
:
""
,
'
leaves
'
:
[]},
""
,
""
,
0
)
""
,
""
,
0
)
...
@@ -349,6 +349,8 @@ class Node(QObject):
...
@@ -349,6 +349,8 @@ class Node(QObject):
logging
.
debug
(
"
Timeout error : {0}
"
.
format
(
self
.
pubkey
))
logging
.
debug
(
"
Timeout error : {0}
"
.
format
(
self
.
pubkey
))
self
.
state
=
Node
.
OFFLINE
self
.
state
=
Node
.
OFFLINE
@asyncify
@asyncio.coroutine
def
refresh_summary
(
self
):
def
refresh_summary
(
self
):
conn_handler
=
self
.
endpoint
.
conn_handler
()
conn_handler
=
self
.
endpoint
.
conn_handler
()
...
@@ -371,12 +373,15 @@ class Node(QObject):
...
@@ -371,12 +373,15 @@ class Node(QObject):
logging
.
debug
(
"
Timeout error : {0}
"
.
format
(
self
.
pubkey
))
logging
.
debug
(
"
Timeout error : {0}
"
.
format
(
self
.
pubkey
))
self
.
state
=
Node
.
OFFLINE
self
.
state
=
Node
.
OFFLINE
@asyncify
@asyncio.coroutine
def
refresh_uid
(
self
):
def
refresh_uid
(
self
):
conn_handler
=
self
.
endpoint
.
conn_handler
()
conn_handler
=
self
.
endpoint
.
conn_handler
()
try
:
try
:
data
=
yield
from
bma
.
wot
.
Lookup
(
conn_handler
,
self
.
pubkey
).
get
()
data
=
yield
from
bma
.
wot
.
Lookup
(
conn_handler
,
self
.
pubkey
).
get
()
self
.
state
=
Node
.
ONLINE
self
.
state
=
Node
.
ONLINE
timestamp
=
0
timestamp
=
0
uid
=
None
for
result
in
data
[
'
results
'
]:
for
result
in
data
[
'
results
'
]:
if
result
[
"
pubkey
"
]
==
self
.
pubkey
:
if
result
[
"
pubkey
"
]
==
self
.
pubkey
:
uids
=
result
[
'
uids
'
]
uids
=
result
[
'
uids
'
]
...
@@ -384,8 +389,7 @@ class Node(QObject):
...
@@ -384,8 +389,7 @@ class Node(QObject):
if
uid
[
"
meta
"
][
"
timestamp
"
]
>
timestamp
:
if
uid
[
"
meta
"
][
"
timestamp
"
]
>
timestamp
:
timestamp
=
uid
[
"
meta
"
][
"
timestamp
"
]
timestamp
=
uid
[
"
meta
"
][
"
timestamp
"
]
uid
=
uid
[
"
uid
"
]
uid
=
uid
[
"
uid
"
]
if
uid
and
self
.
_uid
!=
uid
:
if
self
.
_uid
!=
uid
:
self
.
_uid
=
uid
self
.
_uid
=
uid
self
.
changed
.
emit
()
self
.
changed
.
emit
()
except
ValueError
as
e
:
except
ValueError
as
e
:
...
@@ -401,6 +405,8 @@ class Node(QObject):
...
@@ -401,6 +405,8 @@ class Node(QObject):
logging
.
debug
(
"
Timeout error : {0}
"
.
format
(
self
.
pubkey
))
logging
.
debug
(
"
Timeout error : {0}
"
.
format
(
self
.
pubkey
))
self
.
state
=
Node
.
OFFLINE
self
.
state
=
Node
.
OFFLINE
@asyncify
@asyncio.coroutine
def
refresh_peers
(
self
):
def
refresh_peers
(
self
):
conn_handler
=
self
.
endpoint
.
conn_handler
()
conn_handler
=
self
.
endpoint
.
conn_handler
()
...
...
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