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
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show 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():
...
@@ -87,7 +87,9 @@ class Cache():
if
cache_key
not
in
self
.
data
.
keys
():
if
cache_key
not
in
self
.
data
.
keys
():
result
=
self
.
community
.
request
(
request
,
req_args
,
get_args
,
result
=
self
.
community
.
request
(
request
,
req_args
,
get_args
,
cached
=
False
)
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
self
.
data
[
cache_key
]
=
result
return
self
.
data
[
cache_key
]
return
self
.
data
[
cache_key
]
else
:
else
:
...
@@ -254,11 +256,16 @@ class Community(QObject):
...
@@ -254,11 +256,16 @@ class Community(QObject):
:return: The monetary mass value
:return: The monetary mass value
'''
'''
try
:
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
'
]
return
block
[
'
monetaryMass
'
]
except
ValueError
as
e
:
except
ValueError
as
e
:
if
'
404
'
in
e
:
if
'
404
'
in
e
:
return
0
return
0
except
NoPeerAvailable
as
e
:
return
0
@property
@property
def
nb_members
(
self
):
def
nb_members
(
self
):
...
@@ -268,11 +275,16 @@ class Community(QObject):
...
@@ -268,11 +275,16 @@ class Community(QObject):
:return: The community members number
:return: The community members number
'''
'''
try
:
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
'
]
return
block
[
'
membersCount
'
]
except
ValueError
as
e
:
except
ValueError
as
e
:
if
'
404
'
in
e
:
if
'
404
'
in
e
:
return
0
return
0
except
NoPeerAvailable
as
e
:
return
0
@property
@property
def
network
(
self
):
def
network
(
self
):
...
@@ -369,7 +381,6 @@ class Community(QObject):
...
@@ -369,7 +381,6 @@ class Community(QObject):
'''
'''
Start the refresh processing of the cache
Start the refresh processing of the cache
'''
'''
# We have to refresh node before refresh cache
self
.
_cache
.
refresh
()
self
.
_cache
.
refresh
()
def
request
(
self
,
request
,
req_args
=
{},
get_args
=
{},
cached
=
True
):
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
...
@@ -12,7 +12,8 @@ from ucoinpy import PROTOCOL_VERSION
from
ucoinpy.documents.certification
import
SelfCertification
from
ucoinpy.documents.certification
import
SelfCertification
from
ucoinpy.documents.membership
import
Membership
from
ucoinpy.documents.membership
import
Membership
from
..tools.exceptions
import
Error
,
PersonNotFoundError
,
\
from
..tools.exceptions
import
Error
,
PersonNotFoundError
,
\
MembershipNotFoundError
MembershipNotFoundError
,
\
NoPeerAvailable
from
PyQt5.QtCore
import
QMutex
from
PyQt5.QtCore
import
QMutex
...
@@ -51,6 +52,7 @@ class cached(object):
...
@@ -51,6 +52,7 @@ class cached(object):
except
KeyError
:
except
KeyError
:
value
=
self
.
func
(
inst
,
community
)
value
=
self
.
func
(
inst
,
community
)
inst
.
_cache
[
community
.
currency
][
self
.
func
.
__name__
]
=
value
inst
.
_cache
[
community
.
currency
][
self
.
func
.
__name__
]
=
value
finally
:
finally
:
inst
.
_cache_mutex
.
unlock
()
inst
.
_cache_mutex
.
unlock
()
...
@@ -219,6 +221,9 @@ class Person(object):
...
@@ -219,6 +221,9 @@ class Person(object):
except
ValueError
as
e
:
except
ValueError
as
e
:
if
'
400
'
in
str
(
e
):
if
'
400
'
in
str
(
e
):
raise
MembershipNotFoundError
(
self
.
pubkey
,
community
.
name
)
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 ?
#TODO: Manage 'OUT' memberships ? Maybe ?
@cached
@cached
...
@@ -247,6 +252,9 @@ class Person(object):
...
@@ -247,6 +252,9 @@ class Person(object):
except
ValueError
as
e
:
except
ValueError
as
e
:
if
'
400
'
in
str
(
e
):
if
'
400
'
in
str
(
e
):
raise
MembershipNotFoundError
(
self
.
pubkey
,
community
.
name
)
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
return
membership_data
...
@@ -263,6 +271,9 @@ class Person(object):
...
@@ -263,6 +271,9 @@ class Person(object):
return
certifiers
[
'
isMember
'
]
return
certifiers
[
'
isMember
'
]
except
ValueError
:
except
ValueError
:
return
False
return
False
except
Exception
as
e
:
logging
.
debug
(
'
bma.wot.CertifiersOf request error :
'
+
str
(
e
))
return
False
@cached
@cached
def
certifiers_of
(
self
,
community
):
def
certifiers_of
(
self
,
community
):
...
...
This diff is collapsed.
Click to expand it.
src/cutecoin/gui/mainwindow.py
+
7
−
17
View file @
683c8af3
...
@@ -258,7 +258,6 @@ class MainWindow(QMainWindow, Ui_MainWindow):
...
@@ -258,7 +258,6 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self
.
currencies_tabwidget
.
clear
()
self
.
currencies_tabwidget
.
clear
()
if
self
.
app
.
current_account
:
if
self
.
app
.
current_account
:
for
community
in
self
.
app
.
current_account
.
communities
:
for
community
in
self
.
app
.
current_account
.
communities
:
try
:
tab_currency
=
CurrencyTabWidget
(
self
.
app
,
community
,
tab_currency
=
CurrencyTabWidget
(
self
.
app
,
community
,
self
.
password_asker
,
self
.
password_asker
,
self
.
status_label
)
self
.
status_label
)
...
@@ -266,15 +265,6 @@ class MainWindow(QMainWindow, Ui_MainWindow):
...
@@ -266,15 +265,6 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self
.
currencies_tabwidget
.
addTab
(
tab_currency
,
self
.
currencies_tabwidget
.
addTab
(
tab_currency
,
QIcon
(
"
:/icons/currency_icon
"
),
QIcon
(
"
:/icons/currency_icon
"
),
community
.
name
)
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
)
def
refresh_accounts
(
self
):
def
refresh_accounts
(
self
):
self
.
menu_change_account
.
clear
()
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