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
4cda8e93
Commit
4cda8e93
authored
10 years ago
by
inso
Browse files
Options
Downloads
Patches
Plain Diff
Fixed bug when needing to restart cutecoin to join a new community
parent
b51edccb
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/cutecoin/core/community.py
+40
-35
40 additions, 35 deletions
src/cutecoin/core/community.py
src/cutecoin/core/person.py
+3
-2
3 additions, 2 deletions
src/cutecoin/core/person.py
src/cutecoin/gui/process_cfg_community.py
+1
-1
1 addition, 1 deletion
src/cutecoin/gui/process_cfg_community.py
with
44 additions
and
38 deletions
src/cutecoin/core/community.py
+
40
−
35
View file @
4cda8e93
...
@@ -123,43 +123,48 @@ class Community(object):
...
@@ -123,43 +123,48 @@ class Community(object):
self
.
last_block
[
"
number
"
]
=
block_number
self
.
last_block
[
"
number
"
]
=
block_number
self
.
requests_cache
=
{}
self
.
requests_cache
=
{}
def
request
(
self
,
request
,
req_args
=
{},
get_args
=
{}):
def
request
(
self
,
request
,
req_args
=
{},
get_args
=
{}
,
cached
=
True
):
for
peer
in
self
.
peers
:
for
peer
in
self
.
peers
:
try
:
e
=
next
(
e
for
e
in
peer
.
endpoints
if
type
(
e
)
is
BMAEndpoint
)
e
=
next
(
e
for
e
in
peer
.
endpoints
if
type
(
e
)
is
BMAEndpoint
)
if
cached
:
# We request the current block every five minutes
try
:
# If a new block is mined we reset the cache
# We request the current block every five minutes
# If a new block is mined we reset the cache
self
.
check_current_block
(
e
)
cache_key
=
(
hash
(
request
),
self
.
check_current_block
(
e
)
hash
(
tuple
(
frozenset
(
sorted
(
req_args
.
keys
())))),
cache_key
=
(
hash
(
request
),
hash
(
tuple
(
frozenset
(
sorted
(
req_args
.
items
())))),
hash
(
tuple
(
frozenset
(
sorted
(
req_args
.
keys
())))),
hash
(
tuple
(
frozenset
(
sorted
(
get_args
.
keys
())))),
hash
(
tuple
(
frozenset
(
sorted
(
req_args
.
items
())))),
hash
(
tuple
(
frozenset
(
sorted
(
get_args
.
items
())))))
hash
(
tuple
(
frozenset
(
sorted
(
get_args
.
keys
())))),
hash
(
tuple
(
frozenset
(
sorted
(
get_args
.
items
())))))
if
cache_key
not
in
self
.
requests_cache
.
keys
():
if
e
.
server
:
if
cache_key
not
in
self
.
requests_cache
.
keys
():
logging
.
debug
(
"
Connecting to {0}:{1}
"
.
format
(
e
.
server
,
if
e
.
server
:
e
.
port
))
logging
.
debug
(
"
Connecting to {0}:{1}
"
.
format
(
e
.
server
,
else
:
e
.
port
))
logging
.
debug
(
"
Connecting to {0}:{1}
"
.
format
(
e
.
ipv4
,
else
:
e
.
port
))
logging
.
debug
(
"
Connecting to {0}:{1}
"
.
format
(
e
.
ipv4
,
e
.
port
))
req
=
request
(
e
.
conn_handler
(),
**
req_args
)
data
=
req
.
get
(
**
get_args
)
req
=
request
(
e
.
conn_handler
(),
**
req_args
)
if
inspect
.
isgenerator
(
data
):
data
=
req
.
get
(
**
get_args
)
cached_data
=
[]
if
inspect
.
isgenerator
(
data
):
for
d
in
data
:
cached_data
=
[]
cached_data
.
append
(
d
)
for
d
in
data
:
self
.
requests_cache
[
cache_key
]
=
cached_data
cached_data
.
append
(
d
)
self
.
requests_cache
[
cache_key
]
=
cached_data
else
:
self
.
requests_cache
[
cache_key
]
=
data
except
ValueError
as
e
:
if
'
502
'
in
str
(
e
):
continue
else
:
else
:
self
.
requests_cache
[
cache_key
]
=
data
raise
except
ValueError
as
e
:
return
self
.
requests_cache
[
cache_key
]
if
'
502
'
in
str
(
e
):
else
:
continue
req
=
request
(
e
.
conn_handler
(),
**
req_args
)
else
:
data
=
req
.
get
(
**
get_args
)
raise
return
data
return
self
.
requests_cache
[
cache_key
]
raise
NoPeerAvailable
(
self
.
currency
)
raise
NoPeerAvailable
(
self
.
currency
)
def
post
(
self
,
request
,
req_args
=
{},
post_args
=
{}):
def
post
(
self
,
request
,
req_args
=
{},
post_args
=
{}):
...
...
This diff is collapsed.
Click to expand it.
src/cutecoin/core/person.py
+
3
−
2
View file @
4cda8e93
...
@@ -26,11 +26,12 @@ class Person(object):
...
@@ -26,11 +26,12 @@ class Person(object):
self
.
pubkey
=
pubkey
self
.
pubkey
=
pubkey
@classmethod
@classmethod
def
lookup
(
cls
,
pubkey
,
community
):
def
lookup
(
cls
,
pubkey
,
community
,
cached
=
True
):
'''
'''
Create a person from the pubkey found in a community
Create a person from the pubkey found in a community
'''
'''
data
=
community
.
request
(
bma
.
wot
.
Lookup
,
req_args
=
{
'
search
'
:
pubkey
})
data
=
community
.
request
(
bma
.
wot
.
Lookup
,
req_args
=
{
'
search
'
:
pubkey
},
cached
=
cached
)
results
=
data
[
'
results
'
]
results
=
data
[
'
results
'
]
logging
.
debug
(
results
)
logging
.
debug
(
results
)
timestamp
=
0
timestamp
=
0
...
...
This diff is collapsed.
Click to expand it.
src/cutecoin/gui/process_cfg_community.py
+
1
−
1
View file @
4cda8e93
...
@@ -166,7 +166,7 @@ class ProcessConfigureCommunity(QDialog, Ui_CommunityConfigurationDialog):
...
@@ -166,7 +166,7 @@ class ProcessConfigureCommunity(QDialog, Ui_CommunityConfigurationDialog):
def
accept
(
self
):
def
accept
(
self
):
try
:
try
:
Person
.
lookup
(
self
.
account
.
pubkey
,
self
.
community
)
Person
.
lookup
(
self
.
account
.
pubkey
,
self
.
community
,
cached
=
False
)
except
PersonNotFoundError
as
e
:
except
PersonNotFoundError
as
e
:
reply
=
QMessageBox
.
question
(
self
,
"
Pubkey not found
"
,
reply
=
QMessageBox
.
question
(
self
,
"
Pubkey not found
"
,
"
The public key of your account wasn
'
t found in the community. :
\n
\
"
The public key of your account wasn
'
t found in the community. :
\n
\
...
...
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