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
e361d0ea
Commit
e361d0ea
authored
9 years ago
by
inso
Browse files
Options
Downloads
Patches
Plain Diff
Check if we get a block doc
parent
2119ef99
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/sakia/core/txhistory.py
+23
-20
23 additions, 20 deletions
src/sakia/core/txhistory.py
with
23 additions
and
20 deletions
src/sakia/core/txhistory.py
+
23
−
20
View file @
e361d0ea
...
...
@@ -316,23 +316,25 @@ class TxHistory():
:param int block_number: The block to check for transfers
"""
block_doc
=
await
self
.
_get_block_doc
(
community
,
block_number
)
if
block_doc
:
# We check the block dividend state
match
=
[
d
for
d
in
self
.
_dividends
if
d
[
'
block_number
'
]
==
block_number
]
if
len
(
match
)
>
0
:
if
block_doc
.
ud
:
match
[
0
][
'
amount
'
]
=
block_doc
.
ud
match
[
0
][
'
base
'
]
=
block_doc
.
unit_base
else
:
self
.
_dividends
.
remove
(
match
[
0
])
# We check the block dividend state
match
=
[
d
for
d
in
self
.
_dividends
if
d
[
'
block_number
'
]
==
block_number
]
if
len
(
match
)
>
0
:
if
block_doc
.
ud
:
match
[
0
][
'
amount
'
]
=
block_doc
.
ud
match
[
0
][
'
base
'
]
=
block_doc
.
unit_base
else
:
self
.
_dividends
.
remove
(
match
[
0
])
# We check if transactions are still present
for
transfer
in
[
t
for
t
in
self
.
_transfers
if
t
.
state
in
(
TransferState
.
VALIDATING
,
TransferState
.
VALIDATED
)
and
t
.
blockUID
.
number
==
block_number
]:
if
transfer
.
blockUID
.
sha_hash
==
block_doc
.
blockUID
.
sha_hash
:
return
True
transfer
.
run_state_transitions
((
True
,
block_doc
))
# We check if transactions are still present
for
transfer
in
[
t
for
t
in
self
.
_transfers
if
t
.
state
in
(
TransferState
.
VALIDATING
,
TransferState
.
VALIDATED
)
and
t
.
blockUID
.
number
==
block_number
]:
if
transfer
.
blockUID
.
sha_hash
==
block_doc
.
blockUID
.
sha_hash
:
return
True
transfer
.
run_state_transitions
((
True
,
block_doc
))
else
:
logging
.
debug
(
"
Could not get block document
"
)
return
False
async
def
_rollback
(
self
,
community
):
...
...
@@ -359,10 +361,11 @@ class TxHistory():
break
current_block
=
await
self
.
_get_block_doc
(
community
,
community
.
network
.
current_blockUID
.
number
)
members_pubkeys
=
await
community
.
members_pubkeys
()
for
transfer
in
[
t
for
t
in
self
.
_transfers
if
t
.
state
==
TransferState
.
VALIDATED
]:
transfer
.
run_state_transitions
((
True
,
current_block
,
MAX_CONFIRMATIONS
))
if
current_block
:
members_pubkeys
=
await
community
.
members_pubkeys
()
for
transfer
in
[
t
for
t
in
self
.
_transfers
if
t
.
state
==
TransferState
.
VALIDATED
]:
transfer
.
run_state_transitions
((
True
,
current_block
,
MAX_CONFIRMATIONS
))
except
NoPeerAvailable
:
logging
.
debug
(
"
No peer available
"
)
...
...
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