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
9cbe9c81
Commit
9cbe9c81
authored
9 years ago
by
inso
Browse files
Options
Downloads
Patches
Plain Diff
Fix identity lookup going in infinite loop
parent
42acb595
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/cutecoin/core/registry/identities.py
+33
-30
33 additions, 30 deletions
src/cutecoin/core/registry/identities.py
with
33 additions
and
30 deletions
src/cutecoin/core/registry/identities.py
+
33
−
30
View file @
9cbe9c81
...
@@ -45,36 +45,39 @@ class IdentitiesRegistry:
...
@@ -45,36 +45,39 @@ class IdentitiesRegistry:
return
{
'
registry
'
:
identities_json
}
return
{
'
registry
'
:
identities_json
}
@asyncio.coroutine
@asyncio.coroutine
def
future_find
(
self
,
pubkey
,
community
):
def
_find_by_lookup
(
self
,
pubkey
,
community
):
def
lookup
():
identity
=
self
.
_instances
[
pubkey
]
nonlocal
identity
lookup_tries
=
0
lookup_tries
=
0
while
lookup_tries
<
3
:
while
lookup_tries
<
3
and
identity
.
local_state
==
LocalState
.
NOT_FOUND
:
try
:
try
:
data
=
yield
from
community
.
bma_access
.
simple_request
(
bma
.
wot
.
Lookup
,
data
=
yield
from
community
.
bma_access
.
simple_request
(
bma
.
wot
.
Lookup
,
req_args
=
{
'
search
'
:
pubkey
})
req_args
=
{
'
search
'
:
pubkey
})
timestamp
=
0
timestamp
=
0
for
result
in
data
[
'
results
'
]:
for
result
in
data
[
'
results
'
]:
if
result
[
"
pubkey
"
]
==
identity
.
pubkey
:
if
result
[
"
pubkey
"
]
==
identity
.
pubkey
:
uids
=
result
[
'
uids
'
]
uids
=
result
[
'
uids
'
]
identity_uid
=
""
identity_uid
=
""
for
uid_data
in
uids
:
for
uid_data
in
uids
:
if
uid_data
[
"
meta
"
][
"
timestamp
"
]
>
timestamp
:
if
uid_data
[
"
meta
"
][
"
timestamp
"
]
>
timestamp
:
timestamp
=
uid_data
[
"
meta
"
][
"
timestamp
"
]
timestamp
=
uid_data
[
"
meta
"
][
"
timestamp
"
]
identity_uid
=
uid_data
[
"
uid
"
]
identity_uid
=
uid_data
[
"
uid
"
]
identity
.
uid
=
identity_uid
identity
.
uid
=
identity_uid
identity
.
blockchain_state
=
BlockchainState
.
BUFFERED
identity
.
blockchain_state
=
BlockchainState
.
BUFFERED
identity
.
local_state
=
LocalState
.
PARTIAL
identity
.
local_state
=
LocalState
.
PARTIAL
return
identity
logging
.
debug
(
"
Lookup : found {0}
"
.
format
(
identity
))
logging
.
debug
(
"
Lookup : found {0}
"
.
format
(
identity
))
except
ValueError
as
e
:
except
ValueError
as
e
:
lookup_tries
+=
1
lookup_tries
+=
1
except
asyncio
.
TimeoutError
:
except
asyncio
.
TimeoutError
:
lookup_tries
+=
1
lookup_tries
+=
1
except
ClientError
:
except
ClientError
:
lookup_tries
+=
1
lookup_tries
+=
1
except
NoPeerAvailable
:
except
NoPeerAvailable
:
return
identity
return
identity
return
identity
@asyncio.coroutine
def
future_find
(
self
,
pubkey
,
community
):
if
pubkey
in
self
.
_instances
:
if
pubkey
in
self
.
_instances
:
identity
=
self
.
_instances
[
pubkey
]
identity
=
self
.
_instances
[
pubkey
]
else
:
else
:
...
@@ -89,7 +92,7 @@ class IdentitiesRegistry:
...
@@ -89,7 +92,7 @@ class IdentitiesRegistry:
identity
.
blockchain_state
=
BlockchainState
.
VALIDATED
identity
.
blockchain_state
=
BlockchainState
.
VALIDATED
except
ValueError
as
e
:
except
ValueError
as
e
:
if
'
404
'
in
str
(
e
)
or
'
400
'
in
str
(
e
):
if
'
404
'
in
str
(
e
)
or
'
400
'
in
str
(
e
):
yield
from
lookup
(
)
identity
=
yield
from
self
.
_find_by_lookup
(
pubkey
,
community
)
return
identity
return
identity
else
:
else
:
tries
+=
1
tries
+=
1
...
...
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