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
GitLab 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
02e292c8
Commit
02e292c8
authored
7 years ago
by
inso
Browse files
Options
Downloads
Patches
Plain Diff
Parse sources using URL instead of manually
parent
a1f2f7c7
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/sakia/gui/dialogs/connection_cfg/model.py
+1
-2
1 addition, 2 deletions
src/sakia/gui/dialogs/connection_cfg/model.py
src/sakia/services/sources.py
+31
-9
31 additions, 9 deletions
src/sakia/services/sources.py
with
32 additions
and
11 deletions
src/sakia/gui/dialogs/connection_cfg/model.py
+
1
−
2
View file @
02e292c8
...
@@ -81,8 +81,7 @@ class ConnectionConfigModel(QObject):
...
@@ -81,8 +81,7 @@ class ConnectionConfigModel(QObject):
:return:
:return:
"""
"""
log_stream
(
"
Parsing sources...
"
)
log_stream
(
"
Parsing sources...
"
)
await
self
.
app
.
sources_service
.
refresh_sources_of_pubkey
(
self
.
connection
.
pubkey
,
transactions
,
dividends
,
await
self
.
app
.
sources_service
.
initialize_sources
(
self
.
connection
.
pubkey
,
log_stream
,
progress
)
None
,
log_stream
,
progress
)
log_stream
(
"
Sources parsed succefully !
"
)
log_stream
(
"
Sources parsed succefully !
"
)
async
def
initialize_identity
(
self
,
identity
,
log_stream
,
progress
):
async
def
initialize_identity
(
self
,
identity
,
log_stream
,
progress
):
...
...
This diff is collapsed.
Click to expand it.
src/sakia/services/sources.py
+
31
−
9
View file @
02e292c8
from
PyQt5.QtCore
import
QObject
from
PyQt5.QtCore
import
QObject
from
duniterpy.api
import
bma
,
errors
from
duniterpy.api
import
bma
,
errors
from
duniterpy.documents
import
Transaction
as
TransactionDoc
from
duniterpy.documents
import
Transaction
as
TransactionDoc
from
duniterpy.grammars.output
import
Condition
from
duniterpy.documents
import
BlockUID
from
duniterpy.documents
import
BlockUID
import
logging
import
logging
import
pypeg2
from
sakia.data.entities
import
Source
,
Transaction
,
Dividend
from
sakia.data.entities
import
Source
,
Transaction
,
Dividend
import
hashlib
import
hashlib
...
@@ -43,7 +45,6 @@ class SourcesServices(QObject):
...
@@ -43,7 +45,6 @@ class SourcesServices(QObject):
"""
"""
txdoc
=
TransactionDoc
.
from_signed_raw
(
transaction
.
raw
)
txdoc
=
TransactionDoc
.
from_signed_raw
(
transaction
.
raw
)
for
offset
,
output
in
enumerate
(
txdoc
.
outputs
):
for
offset
,
output
in
enumerate
(
txdoc
.
outputs
):
if
output
.
conditions
.
left
.
pubkey
==
pubkey
:
source
=
Source
(
currency
=
self
.
currency
,
source
=
Source
(
currency
=
self
.
currency
,
pubkey
=
pubkey
,
pubkey
=
pubkey
,
identifier
=
txdoc
.
sha_hash
,
identifier
=
txdoc
.
sha_hash
,
...
@@ -85,6 +86,27 @@ class SourcesServices(QObject):
...
@@ -85,6 +86,27 @@ class SourcesServices(QObject):
base
=
dividend
.
base
)
base
=
dividend
.
base
)
self
.
_sources_processor
.
insert
(
source
)
self
.
_sources_processor
.
insert
(
source
)
async
def
initialize_sources
(
self
,
pubkey
,
log_stream
,
progress
):
sources_data
=
await
self
.
_bma_connector
.
get
(
self
.
currency
,
bma
.
tx
.
sources
,
req_args
=
{
'
pubkey
'
:
pubkey
})
nb_sources
=
len
(
sources_data
[
"
sources
"
])
for
i
,
s
in
enumerate
(
sources_data
[
"
sources
"
]):
log_stream
(
"
Parsing source ud/tx {:}/{:}
"
.
format
(
i
,
nb_sources
))
progress
(
1
/
nb_sources
)
conditions
=
pypeg2
.
parse
(
s
[
"
conditions
"
],
Condition
)
if
conditions
.
left
.
pubkey
==
pubkey
:
try
:
if
conditions
.
left
.
pubkey
==
pubkey
:
source
=
Source
(
currency
=
self
.
currency
,
pubkey
=
pubkey
,
identifier
=
s
[
"
identifier
"
],
type
=
s
[
"
type
"
],
noffset
=
s
[
"
noffset
"
],
amount
=
s
[
"
amount
"
],
base
=
s
[
"
base
"
])
self
.
_sources_processor
.
insert
(
source
)
except
AttributeError
as
e
:
self
.
_logger
.
error
(
str
(
e
))
async
def
check_destruction
(
self
,
pubkey
,
block_number
,
unit_base
):
async
def
check_destruction
(
self
,
pubkey
,
block_number
,
unit_base
):
amount
=
self
.
_sources_processor
.
amount
(
self
.
currency
,
pubkey
)
amount
=
self
.
_sources_processor
.
amount
(
self
.
currency
,
pubkey
)
if
amount
<
100
*
10
**
unit_base
:
if
amount
<
100
*
10
**
unit_base
:
...
...
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