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
755986ed
Commit
755986ed
authored
9 years ago
by
inso
Browse files
Options
Downloads
Patches
Plain Diff
Fix transaction parsing
parent
28a331ee
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/cutecoin/core/net/node.py
+22
-9
22 additions, 9 deletions
src/cutecoin/core/net/node.py
src/cutecoin/core/transfer.py
+2
-2
2 additions, 2 deletions
src/cutecoin/core/transfer.py
src/cutecoin/core/txhistory.py
+22
-2
22 additions, 2 deletions
src/cutecoin/core/txhistory.py
with
46 additions
and
13 deletions
src/cutecoin/core/net/node.py
+
22
−
9
View file @
755986ed
...
...
@@ -68,6 +68,8 @@ class Node(QObject):
the currency it should have, for example if its the first one we add
:param str address: The node address
:param int port: The node port
:return: A new node
:rtype: cutecoin.core.net.Node
"""
peer_data
=
yield
from
bma
.
network
.
Peering
(
ConnectionHandler
(
address
,
port
)).
get
()
...
...
@@ -93,6 +95,8 @@ class Node(QObject):
:param str currency: The node currency. None if we don
'
t know
\
the currency it should have, for example if its the first one we add
:param peer: The peer document
:return: A new node
:rtype: cutecoin.core.net.Node
"""
if
currency
is
not
None
:
if
peer
.
currency
!=
currency
:
...
...
@@ -265,17 +269,11 @@ class Node(QObject):
self
.
_fork_window
=
new_fork_window
self
.
changed
.
emit
()
def
check_noerror
(
self
,
error_code
,
status_code
):
if
error_code
==
QNetworkReply
.
NoError
:
if
status_code
in
(
200
,
404
):
if
self
.
state
==
Node
.
OFFLINE
:
self
.
state
=
Node
.
ONLINE
return
True
self
.
state
=
Node
.
OFFLINE
return
False
@pyqtSlot
()
def
refresh
(
self
):
"""
Refresh all data of this node
"""
logging
.
debug
(
"
Refresh block
"
)
self
.
refresh_block
()
logging
.
debug
(
"
Refresh info
"
)
...
...
@@ -290,6 +288,9 @@ class Node(QObject):
@asyncify
@asyncio.coroutine
def
refresh_block
(
self
):
"""
Refresh the blocks of this node
"""
conn_handler
=
self
.
endpoint
.
conn_handler
()
logging
.
debug
(
"
Requesting {0}
"
.
format
(
conn_handler
))
...
...
@@ -318,6 +319,9 @@ class Node(QObject):
@asyncify
@asyncio.coroutine
def
refresh_informations
(
self
):
"""
Refresh basic information (pubkey and currency)
"""
conn_handler
=
self
.
endpoint
.
conn_handler
()
try
:
...
...
@@ -352,6 +356,9 @@ class Node(QObject):
@asyncify
@asyncio.coroutine
def
refresh_summary
(
self
):
"""
Refresh the summary of this node
"""
conn_handler
=
self
.
endpoint
.
conn_handler
()
try
:
...
...
@@ -376,6 +383,9 @@ class Node(QObject):
@asyncify
@asyncio.coroutine
def
refresh_uid
(
self
):
"""
Refresh the node UID
"""
conn_handler
=
self
.
endpoint
.
conn_handler
()
try
:
data
=
yield
from
bma
.
wot
.
Lookup
(
conn_handler
,
self
.
pubkey
).
get
()
...
...
@@ -408,6 +418,9 @@ class Node(QObject):
@asyncify
@asyncio.coroutine
def
refresh_peers
(
self
):
"""
Refresh the list of peers knew by this node
"""
conn_handler
=
self
.
endpoint
.
conn_handler
()
try
:
...
...
This diff is collapsed.
Click to expand it.
src/cutecoin/core/transfer.py
+
2
−
2
View file @
755986ed
...
...
@@ -142,8 +142,8 @@ class Transfer(QObject):
self
.
state
=
Transfer
.
VALIDATING
self
.
_metadata
[
'
block
'
]
=
block_number
self
.
_metadata
[
'
time
'
]
=
time
el
if
self
.
state
==
Transfer
.
VALIDATING
and
\
self
.
_metadata
[
'
block
'
]
-
block_number
>
data_validation
:
if
self
.
state
==
Transfer
.
VALIDATING
and
\
self
.
_metadata
[
'
block
'
]
-
block_number
>
=
data_validation
:
self
.
state
=
Transfer
.
VALIDATED
def
check_refused
(
self
,
time
,
block_time
,
mediantime_blocks
):
...
...
This diff is collapsed.
Click to expand it.
src/cutecoin/core/txhistory.py
+
22
−
2
View file @
755986ed
...
...
@@ -76,7 +76,7 @@ class TxHistory():
@asyncio.coroutine
def
_validation_state
(
community
,
block_number
,
current_block
):
members_pubkeys
=
yield
from
community
.
members_pubkeys
()
if
block_number
+
community
.
network
.
fork_window
(
members_pubkeys
)
+
1
<
current_block
[
"
number
"
]:
if
block_number
+
community
.
network
.
fork_window
(
members_pubkeys
)
<
=
current_block
[
"
number
"
]:
state
=
Transfer
.
VALIDATED
else
:
state
=
Transfer
.
VALIDATING
...
...
@@ -86,6 +86,17 @@ class TxHistory():
def
_parse_transaction
(
self
,
community
,
tx
,
block_number
,
mediantime
,
received_list
,
current_block
,
txid
):
"""
Parse a transaction
:param cutecoin.core.Community community: The community
:param dict tx: The tx json data
:param int block_number: The block number were we found the tx
:param int mediantime: Median time on the network
:param list received_list: The list of received transactions
:param int current_block: The current block of the network
:param int txid: The latest txid
:return: the found transaction
"""
receivers
=
[
o
.
pubkey
for
o
in
tx
.
outputs
if
o
.
pubkey
!=
tx
.
issuers
[
0
]]
...
...
@@ -158,11 +169,20 @@ class TxHistory():
transfer
=
[
t
for
t
in
awaiting
if
t
.
hash
==
tx_hash
][
0
]
transfer
.
check_registered
(
tx_hash
,
current_block
[
'
number
'
],
mediantime
,
community
.
network
.
fork_window
(
community
.
members_pubkeys
())
+
1
)
community
.
network
.
fork_window
(
community
.
members_pubkeys
()))
return
None
@asyncio.coroutine
def
_parse_block
(
self
,
community
,
block_number
,
received_list
,
current_block
,
txmax
):
"""
Parse a block
:param cutecoin.core.Community community: The community
:param int block_number: The block to request
:param list received_list: The list where we are appending transactions
:param int current_block: The current block of the network
:param int txmax: Latest tx id
:return: The list of transfers sent
"""
block
=
None
tries
=
0
while
block
is
None
and
tries
<
3
:
...
...
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