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
5db412ea
Commit
5db412ea
authored
10 years ago
by
Vincent Texier
Browse files
Options
Downloads
Patches
Plain Diff
wot display certifiers-of and certified-by of a newcomer
parent
6092b9b7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/cutecoin/gui/wot_tab.py
+131
-21
131 additions, 21 deletions
src/cutecoin/gui/wot_tab.py
with
131 additions
and
21 deletions
src/cutecoin/gui/wot_tab.py
+
131
−
21
View file @
5db412ea
...
@@ -11,7 +11,7 @@ from ucoinpy.api import bma
...
@@ -11,7 +11,7 @@ from ucoinpy.api import bma
from
.certification
import
CertificationDialog
from
.certification
import
CertificationDialog
from
.add_contact
import
AddContactDialog
from
.add_contact
import
AddContactDialog
from
.transfer
import
TransferMoneyDialog
from
.transfer
import
TransferMoneyDialog
from
cutecoin.core.person
import
Person
class
WotTabWidget
(
QWidget
,
Ui_WotTabWidget
):
class
WotTabWidget
(
QWidget
,
Ui_WotTabWidget
):
def
__init__
(
self
,
account
,
community
,
password_asker
,
parent
=
None
):
def
__init__
(
self
,
account
,
community
,
password_asker
,
parent
=
None
):
...
@@ -56,36 +56,25 @@ class WotTabWidget(QWidget, Ui_WotTabWidget):
...
@@ -56,36 +56,25 @@ class WotTabWidget(QWidget, Ui_WotTabWidget):
:param public_key: Public key of the identity
:param public_key: Public key of the identity
"""
"""
# reset graph
graph
=
dict
()
try
:
try
:
certifiers
=
self
.
community
.
request
(
bma
.
wot
.
CertifiersOf
,
{
'
search
'
:
public_key
})
certifiers
=
self
.
community
.
request
(
bma
.
wot
.
CertifiersOf
,
{
'
search
'
:
public_key
})
except
ValueError
as
e
:
except
ValueError
as
e
:
logging
.
debug
(
'
bma.wot.CertifiersOf request
e
rror :
'
+
str
(
e
))
logging
.
debug
(
'
bma.wot.CertifiersOf request
ValueE
rror :
'
+
str
(
e
))
try
:
try
:
results
=
self
.
community
.
request
(
bma
.
wot
.
Lookup
,
{
'
search
'
:
public_key
})
data
=
self
.
community
.
request
(
bma
.
wot
.
Lookup
,
{
'
search
'
:
public_key
})
except
ValueError
as
e
:
except
ValueError
as
e
:
logging
.
debug
(
'
bma.wot.
CertifiersOf
request
e
rror :
'
+
str
(
e
))
logging
.
debug
(
'
bma.wot.
Lookup
request
ValueE
rror :
'
+
str
(
e
))
return
False
return
False
# construct and display non member graph
# show only node of this non member (to certify him)
self
.
setNonMemberGraph
(
public_key
,
data
)
node_status
=
0
if
public_key
==
self
.
account
.
pubkey
:
node_status
+=
NODE_STATUS_HIGHLIGHTED
node_status
+=
NODE_STATUS_OUT
node_status
+=
NODE_STATUS_SELECTED
# selected node
graph
[
public_key
]
=
{
'
id
'
:
public_key
,
'
arcs
'
:
list
(),
'
text
'
:
results
[
'
results
'
][
0
][
'
uids
'
][
0
][
'
uid
'
],
'
tooltip
'
:
public_key
,
'
status
'
:
node_status
}
# draw graph in qt scene
self
.
graphicsView
.
scene
().
update_wot
(
graph
)
return
False
return
False
except
Exception
as
e
:
except
Exception
as
e
:
logging
.
debug
(
'
bma.wot.CertifiersOf request error :
'
+
str
(
e
))
logging
.
debug
(
'
bma.wot.CertifiersOf request error :
'
+
str
(
e
))
return
False
return
False
# reset graph
graph
=
dict
()
# add wallet node
# add wallet node
node_status
=
0
node_status
=
0
if
public_key
==
self
.
account
.
pubkey
:
if
public_key
==
self
.
account
.
pubkey
:
...
@@ -188,6 +177,119 @@ class WotTabWidget(QWidget, Ui_WotTabWidget):
...
@@ -188,6 +177,119 @@ class WotTabWidget(QWidget, Ui_WotTabWidget):
# draw graph in qt scene
# draw graph in qt scene
self
.
graphicsView
.
scene
().
update_wot
(
graph
)
self
.
graphicsView
.
scene
().
update_wot
(
graph
)
def
setNonMemberGraph
(
self
,
public_key
,
data
):
# reset graph
graph
=
dict
()
# show only node of this non member (to certify him)
node_status
=
0
if
public_key
==
self
.
account
.
pubkey
:
node_status
+=
NODE_STATUS_HIGHLIGHTED
node_status
+=
NODE_STATUS_OUT
node_status
+=
NODE_STATUS_SELECTED
# selected node
graph
[
public_key
]
=
{
'
id
'
:
public_key
,
'
arcs
'
:
list
(),
'
text
'
:
data
[
'
results
'
][
0
][
'
uids
'
][
0
][
'
uid
'
],
'
tooltip
'
:
public_key
,
'
status
'
:
node_status
}
# add certifiers of uid
for
certifier
in
data
[
'
results
'
][
0
][
'
uids
'
][
0
][
'
others
'
]:
# for each uid found for this pubkey...
for
uid
in
certifier
[
'
uids
'
]:
# new node
if
certifier
[
'
pubkey
'
]
not
in
graph
.
keys
():
node_status
=
0
if
certifier
[
'
pubkey
'
]
==
self
.
account
.
pubkey
:
node_status
+=
NODE_STATUS_HIGHLIGHTED
if
certifier
[
'
isMember
'
]
is
False
:
node_status
+=
NODE_STATUS_OUT
graph
[
certifier
[
'
pubkey
'
]]
=
{
'
id
'
:
certifier
[
'
pubkey
'
],
'
arcs
'
:
list
(),
'
text
'
:
uid
,
'
tooltip
'
:
certifier
[
'
pubkey
'
],
'
status
'
:
node_status
}
cert_time
=
self
.
get_block_median_time
(
certifier
[
'
meta
'
][
'
block_number
'
])
# add only valid certification...
if
(
time
.
time
()
-
cert_time
)
>
self
.
signature_validity
:
continue
# keep only the latest certification
if
graph
[
certifier
[
'
pubkey
'
]][
'
arcs
'
]:
if
cert_time
<
graph
[
certifier
[
'
pubkey
'
]][
'
arcs
'
][
0
][
'
cert_time
'
]:
continue
# display validity status
if
(
time
.
time
()
-
cert_time
)
>
self
.
ARC_STATUS_STRONG_time
:
arc_status
=
ARC_STATUS_WEAK
else
:
arc_status
=
ARC_STATUS_STRONG
arc
=
{
'
id
'
:
public_key
,
'
status
'
:
arc_status
,
'
tooltip
'
:
datetime
.
datetime
.
fromtimestamp
(
cert_time
+
self
.
signature_validity
).
strftime
(
"
%Y/%m/%d
"
),
'
cert_time
'
:
cert_time
}
graph
[
certifier
[
'
pubkey
'
]][
'
arcs
'
]
=
[
arc
]
# add certified by non member uid
for
certified
in
data
[
'
results
'
][
0
][
'
signed
'
]:
if
certified
[
'
pubkey
'
]
not
in
graph
.
keys
():
node_status
=
0
if
certified
[
'
pubkey
'
]
==
self
.
account
.
pubkey
:
node_status
+=
NODE_STATUS_HIGHLIGHTED
if
certified
[
'
isMember
'
]
is
False
:
node_status
+=
NODE_STATUS_OUT
graph
[
certified
[
'
pubkey
'
]]
=
{
'
id
'
:
certified
[
'
pubkey
'
],
'
arcs
'
:
list
(),
'
text
'
:
certified
[
'
uid
'
],
'
tooltip
'
:
certified
[
'
pubkey
'
],
'
status
'
:
node_status
}
# add only valid certification...
if
(
time
.
time
()
-
certified
[
'
meta
'
][
'
timestamp
'
])
>
self
.
signature_validity
:
continue
# display validity status
if
(
time
.
time
()
-
certified
[
'
meta
'
][
'
timestamp
'
])
>
self
.
ARC_STATUS_STRONG_time
:
arc_status
=
ARC_STATUS_WEAK
else
:
arc_status
=
ARC_STATUS_STRONG
arc
=
{
'
id
'
:
certified
[
'
pubkey
'
],
'
status
'
:
arc_status
,
'
tooltip
'
:
datetime
.
datetime
.
fromtimestamp
(
certified
[
'
meta
'
][
'
timestamp
'
]
+
self
.
signature_validity
).
strftime
(
"
%Y/%m/%d
"
),
'
cert_time
'
:
certified
[
'
meta
'
][
'
timestamp
'
]
}
# replace old arc if this one is more recent
new_arc
=
True
index
=
0
for
a
in
graph
[
public_key
][
'
arcs
'
]:
# if same arc already exists...
if
a
[
'
id
'
]
==
arc
[
'
id
'
]:
# if arc more recent, dont keep old one...
if
arc
[
'
cert_time
'
]
>=
a
[
'
cert_time
'
]:
graph
[
public_key
][
'
arcs
'
][
index
]
=
arc
new_arc
=
False
index
+=
1
# if arc not in graph...
if
new_arc
:
# add arc in graph
graph
[
public_key
][
'
arcs
'
].
append
(
arc
)
# draw graph in qt scene
self
.
graphicsView
.
scene
().
update_wot
(
graph
)
return
False
def
reset
(
self
):
def
reset
(
self
):
"""
"""
Reset graph scene to wallet identity
Reset graph scene to wallet identity
...
@@ -236,7 +338,7 @@ class WotTabWidget(QWidget, Ui_WotTabWidget):
...
@@ -236,7 +338,7 @@ class WotTabWidget(QWidget, Ui_WotTabWidget):
return
False
return
False
node
=
self
.
nodes
[
index
]
node
=
self
.
nodes
[
index
]
self
.
draw_graph
(
self
.
draw_graph
(
node
[
'
pubkey
'
]
node
[
'
pubkey
'
]
)
)
def
sign_node
(
self
,
metadata
):
def
sign_node
(
self
,
metadata
):
...
@@ -263,3 +365,11 @@ class WotTabWidget(QWidget, Ui_WotTabWidget):
...
@@ -263,3 +365,11 @@ class WotTabWidget(QWidget, Ui_WotTabWidget):
dialog
.
edit_name
.
setText
(
metadata
[
'
text
'
])
dialog
.
edit_name
.
setText
(
metadata
[
'
text
'
])
dialog
.
edit_pubkey
.
setText
(
metadata
[
'
id
'
])
dialog
.
edit_pubkey
.
setText
(
metadata
[
'
id
'
])
dialog
.
exec_
()
dialog
.
exec_
()
def
get_block_median_time
(
self
,
number
):
try
:
block
=
self
.
community
.
get_block
(
number
)
except
Exception
as
e
:
logging
.
debug
(
'
community.get_block request error :
'
+
str
(
e
))
return
False
return
block
.
mediantime
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