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
0062a30b
Commit
0062a30b
authored
9 years ago
by
inso
Browse files
Options
Downloads
Patches
Plain Diff
Fix crash when doc could not be found or parsed
parent
6c6db2ac
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/cutecoin/core/txhistory.py
+28
-20
28 additions, 20 deletions
src/cutecoin/core/txhistory.py
with
28 additions
and
20 deletions
src/cutecoin/core/txhistory.py
+
28
−
20
View file @
0062a30b
...
@@ -89,7 +89,7 @@ class TxHistory():
...
@@ -89,7 +89,7 @@ class TxHistory():
"""
"""
Parse a transaction
Parse a transaction
:param cutecoin.core.Community community: The community
:param cutecoin.core.Community community: The community
:param
dict
tx: The tx json data
:param
ucoinpy.documents.Transaction
tx: The tx json data
:param int block_number: The block number were we found the tx
:param int block_number: The block number were we found the tx
:param int mediantime: Median time on the network
:param int mediantime: Median time on the network
:param list received_list: The list of received transactions
:param list received_list: The list of received transactions
...
@@ -184,29 +184,37 @@ class TxHistory():
...
@@ -184,29 +184,37 @@ class TxHistory():
:return: The list of transfers sent
:return: The list of transfers sent
"""
"""
block
=
None
block
=
None
block_doc
=
None
tries
=
0
tries
=
0
while
block
is
None
and
tries
<
3
:
while
block
is
None
and
tries
<
3
:
block
=
yield
from
community
.
bma_access
.
future_request
(
bma
.
blockchain
.
Block
,
try
:
block
=
yield
from
community
.
bma_access
.
future_request
(
bma
.
blockchain
.
Block
,
req_args
=
{
'
number
'
:
block_number
})
req_args
=
{
'
number
'
:
block_number
})
signed_raw
=
"
{0}{1}
\n
"
.
format
(
block
[
'
raw
'
],
signed_raw
=
"
{0}{1}
\n
"
.
format
(
block
[
'
raw
'
],
block
[
'
signature
'
])
block
[
'
signature
'
])
transfers
=
[]
transfers
=
[]
try
:
try
:
block_doc
=
Block
.
from_signed_raw
(
signed_raw
)
block_doc
=
Block
.
from_signed_raw
(
signed_raw
)
except
:
except
TypeError
:
logging
.
debug
(
"
Error in {0}
"
.
format
(
block_number
))
logging
.
debug
(
"
Error in {0}
"
.
format
(
block_number
))
block
=
None
block
=
None
tries
+=
1
tries
+=
1
except
ValueError
as
e
:
for
(
txid
,
tx
)
in
enumerate
(
block_doc
.
transactions
):
if
'
404
'
in
str
(
e
):
transfer
=
yield
from
self
.
_parse_transaction
(
community
,
tx
,
block_number
,
block
=
None
block_doc
.
mediantime
,
received_list
,
tries
+=
1
current_block
,
txid
+
txmax
)
if
block_doc
:
if
transfer
!=
None
:
for
(
txid
,
tx
)
in
enumerate
(
block_doc
.
transactions
):
logging
.
debug
(
"
Transfer amount : {0}
"
.
format
(
transfer
.
metadata
[
'
amount
'
]))
transfer
=
yield
from
self
.
_parse_transaction
(
community
,
tx
,
block_number
,
transfers
.
append
(
transfer
)
block_doc
.
mediantime
,
received_list
,
else
:
current_block
,
txid
+
txmax
)
logging
.
debug
(
"
None transfer
"
)
if
transfer
!=
None
:
logging
.
debug
(
"
Transfer amount : {0}
"
.
format
(
transfer
.
metadata
[
'
amount
'
]))
transfers
.
append
(
transfer
)
else
:
logging
.
debug
(
"
None transfer
"
)
else
:
logging
.
debug
(
"
Could not find or parse block {0}
"
.
format
(
block_number
))
return
transfers
return
transfers
@asyncio.coroutine
@asyncio.coroutine
...
...
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