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
683c8af3
Commit
683c8af3
authored
10 years ago
by
inso
Browse files
Options
Downloads
Patches
Plain Diff
Handling disconnected state
parent
6e842318
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
+15
-4
15 additions, 4 deletions
src/cutecoin/core/community.py
src/cutecoin/core/person.py
+12
-1
12 additions, 1 deletion
src/cutecoin/core/person.py
src/cutecoin/gui/mainwindow.py
+7
-17
7 additions, 17 deletions
src/cutecoin/gui/mainwindow.py
with
34 additions
and
22 deletions
src/cutecoin/core/community.py
+
15
−
4
View file @
683c8af3
...
...
@@ -87,7 +87,9 @@ class Cache():
if
cache_key
not
in
self
.
data
.
keys
():
result
=
self
.
community
.
request
(
request
,
req_args
,
get_args
,
cached
=
False
)
# For block 0, we should have a different behaviour
# Community members and certifications
# Should be requested without caching
self
.
data
[
cache_key
]
=
result
return
self
.
data
[
cache_key
]
else
:
...
...
@@ -254,11 +256,16 @@ class Community(QObject):
:return: The monetary mass value
'''
try
:
block
=
self
.
request
(
bma
.
blockchain
.
Current
)
# Get cached block by block number
block_number
=
self
.
network
.
latest_block
block
=
self
.
request
(
bma
.
blockchain
.
Block
,
req_args
=
{
'
number
'
:
block_number
})
return
block
[
'
monetaryMass
'
]
except
ValueError
as
e
:
if
'
404
'
in
e
:
return
0
except
NoPeerAvailable
as
e
:
return
0
@property
def
nb_members
(
self
):
...
...
@@ -268,11 +275,16 @@ class Community(QObject):
:return: The community members number
'''
try
:
block
=
self
.
request
(
bma
.
blockchain
.
Current
)
# Get cached block by block number
block_number
=
self
.
network
.
latest_block
block
=
self
.
request
(
bma
.
blockchain
.
Block
,
req_args
=
{
'
number
'
:
block_number
})
return
block
[
'
membersCount
'
]
except
ValueError
as
e
:
if
'
404
'
in
e
:
return
0
except
NoPeerAvailable
as
e
:
return
0
@property
def
network
(
self
):
...
...
@@ -369,7 +381,6 @@ class Community(QObject):
'''
Start the refresh processing of the cache
'''
# We have to refresh node before refresh cache
self
.
_cache
.
refresh
()
def
request
(
self
,
request
,
req_args
=
{},
get_args
=
{},
cached
=
True
):
...
...
This diff is collapsed.
Click to expand it.
src/cutecoin/core/person.py
+
12
−
1
View file @
683c8af3
...
...
@@ -12,7 +12,8 @@ from ucoinpy import PROTOCOL_VERSION
from
ucoinpy.documents.certification
import
SelfCertification
from
ucoinpy.documents.membership
import
Membership
from
..tools.exceptions
import
Error
,
PersonNotFoundError
,
\
MembershipNotFoundError
MembershipNotFoundError
,
\
NoPeerAvailable
from
PyQt5.QtCore
import
QMutex
...
...
@@ -51,6 +52,7 @@ class cached(object):
except
KeyError
:
value
=
self
.
func
(
inst
,
community
)
inst
.
_cache
[
community
.
currency
][
self
.
func
.
__name__
]
=
value
finally
:
inst
.
_cache_mutex
.
unlock
()
...
...
@@ -219,6 +221,9 @@ class Person(object):
except
ValueError
as
e
:
if
'
400
'
in
str
(
e
):
raise
MembershipNotFoundError
(
self
.
pubkey
,
community
.
name
)
except
Exception
as
e
:
logging
.
debug
(
'
bma.blockchain.Membership request error :
'
+
str
(
e
))
raise
MembershipNotFoundError
(
self
.
pubkey
,
community
.
name
)
#TODO: Manage 'OUT' memberships ? Maybe ?
@cached
...
...
@@ -247,6 +252,9 @@ class Person(object):
except
ValueError
as
e
:
if
'
400
'
in
str
(
e
):
raise
MembershipNotFoundError
(
self
.
pubkey
,
community
.
name
)
except
Exception
as
e
:
logging
.
debug
(
'
bma.blockchain.Membership request error :
'
+
str
(
e
))
raise
MembershipNotFoundError
(
self
.
pubkey
,
community
.
name
)
return
membership_data
...
...
@@ -263,6 +271,9 @@ class Person(object):
return
certifiers
[
'
isMember
'
]
except
ValueError
:
return
False
except
Exception
as
e
:
logging
.
debug
(
'
bma.wot.CertifiersOf request error :
'
+
str
(
e
))
return
False
@cached
def
certifiers_of
(
self
,
community
):
...
...
This diff is collapsed.
Click to expand it.
src/cutecoin/gui/mainwindow.py
+
7
−
17
View file @
683c8af3
...
...
@@ -258,23 +258,13 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self
.
currencies_tabwidget
.
clear
()
if
self
.
app
.
current_account
:
for
community
in
self
.
app
.
current_account
.
communities
:
try
:
tab_currency
=
CurrencyTabWidget
(
self
.
app
,
community
,
self
.
password_asker
,
self
.
status_label
)
tab_currency
.
refresh
()
self
.
currencies_tabwidget
.
addTab
(
tab_currency
,
QIcon
(
"
:/icons/currency_icon
"
),
community
.
name
)
except
NoPeerAvailable
as
e
:
QMessageBox
.
critical
(
self
,
"
Could not join {0}
"
.
format
(
community
.
currency
),
str
(
e
),
QMessageBox
.
Ok
)
continue
except
requests
.
exceptions
.
RequestException
as
e
:
QMessageBox
.
critical
(
self
,
"
:(
"
,
str
(
e
),
QMessageBox
.
Ok
)
tab_currency
=
CurrencyTabWidget
(
self
.
app
,
community
,
self
.
password_asker
,
self
.
status_label
)
tab_currency
.
refresh
()
self
.
currencies_tabwidget
.
addTab
(
tab_currency
,
QIcon
(
"
:/icons/currency_icon
"
),
community
.
name
)
def
refresh_accounts
(
self
):
self
.
menu_change_account
.
clear
()
...
...
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