Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
beem
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Show more breadcrumbs
hive
beem
Commits
a6669107
Commit
a6669107
authored
6 years ago
by
Holger
Browse files
Options
Downloads
Patches
Plain Diff
Add blocknumber check to wait_for_and_get_block
parent
c54180ea
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
README.rst
+2
-0
2 additions, 0 deletions
README.rst
beem/blockchain.py
+7
-3
7 additions, 3 deletions
beem/blockchain.py
examples/stream_threading_performance.py
+1
-1
1 addition, 1 deletion
examples/stream_threading_performance.py
with
10 additions
and
4 deletions
README.rst
+
2
−
0
View file @
a6669107
...
@@ -162,6 +162,8 @@ Changelog
...
@@ -162,6 +162,8 @@ Changelog
* Unit tests using testnet fixed
* Unit tests using testnet fixed
* beem.snapshot improved
* beem.snapshot improved
* Example account_sp_over_time added
* Example account_sp_over_time added
* Example account_curation_per_week_and_1k_sp added
* Add block_number check to wait_for_and_get_block
0.19.46
0.19.46
-------
-------
...
...
This diff is collapsed.
Click to expand it.
beem/blockchain.py
+
7
−
3
View file @
a6669107
...
@@ -405,6 +405,7 @@ class Blockchain(object):
...
@@ -405,6 +405,7 @@ class Blockchain(object):
num_retries_call
=
self
.
steem
.
rpc
.
num_retries_call
,
num_retries_call
=
self
.
steem
.
rpc
.
num_retries_call
,
timeout
=
self
.
steem
.
rpc
.
timeout
))
timeout
=
self
.
steem
.
rpc
.
timeout
))
# We are going to loop indefinitely
# We are going to loop indefinitely
latest_block
=
0
while
True
:
while
True
:
# Get chain properies to identify the
# Get chain properies to identify the
...
@@ -547,7 +548,7 @@ class Blockchain(object):
...
@@ -547,7 +548,7 @@ class Blockchain(object):
# Blocks from start until head block
# Blocks from start until head block
for
blocknum
in
range
(
start
,
head_block
+
1
):
for
blocknum
in
range
(
start
,
head_block
+
1
):
# Get full block
# Get full block
block
=
self
.
wait_for_and_get_block
(
blocknum
,
only_ops
=
only_ops
,
only_virtual_ops
=
only_virtual_ops
)
block
=
self
.
wait_for_and_get_block
(
blocknum
,
only_ops
=
only_ops
,
only_virtual_ops
=
only_virtual_ops
,
block_number_check_cnt
=
5
)
yield
block
yield
block
# Set new start
# Set new start
start
=
head_block
+
1
start
=
head_block
+
1
...
@@ -560,7 +561,7 @@ class Blockchain(object):
...
@@ -560,7 +561,7 @@ class Blockchain(object):
# Sleep for one block
# Sleep for one block
time
.
sleep
(
self
.
block_interval
)
time
.
sleep
(
self
.
block_interval
)
def
wait_for_and_get_block
(
self
,
block_number
,
blocks_waiting_for
=
None
,
only_ops
=
False
,
only_virtual_ops
=
False
):
def
wait_for_and_get_block
(
self
,
block_number
,
blocks_waiting_for
=
None
,
only_ops
=
False
,
only_virtual_ops
=
False
,
block_number_check_cnt
=-
1
):
"""
Get the desired block from the chain, if the current head block is smaller (for both head and irreversible)
"""
Get the desired block from the chain, if the current head block is smaller (for both head and irreversible)
then we wait, but a maxmimum of blocks_waiting_for * max_block_wait_repetition time before failure.
then we wait, but a maxmimum of blocks_waiting_for * max_block_wait_repetition time before failure.
...
@@ -569,6 +570,7 @@ class Blockchain(object):
...
@@ -569,6 +570,7 @@ class Blockchain(object):
how many blocks we are willing to wait, positive int (default: None)
how many blocks we are willing to wait, positive int (default: None)
:param bool only_ops: Returns blocks with operations only, when set to True (default: False)
:param bool only_ops: Returns blocks with operations only, when set to True (default: False)
:param bool only_virtual_ops: Includes only virtual operations (default: False)
:param bool only_virtual_ops: Includes only virtual operations (default: False)
:param int block_number_check_cnt: limit the number of retries when greater than -1
"""
"""
if
not
blocks_waiting_for
:
if
not
blocks_waiting_for
:
...
@@ -584,10 +586,12 @@ class Blockchain(object):
...
@@ -584,10 +586,12 @@ class Blockchain(object):
raise
BlockWaitTimeExceeded
(
"
Already waited %d s
"
%
(
blocks_waiting_for
*
self
.
max_block_wait_repetition
*
self
.
block_interval
))
raise
BlockWaitTimeExceeded
(
"
Already waited %d s
"
%
(
blocks_waiting_for
*
self
.
max_block_wait_repetition
*
self
.
block_interval
))
# block has to be returned properly
# block has to be returned properly
repetition
=
0
repetition
=
0
cnt
=
0
block
=
None
block
=
None
while
not
block
:
while
(
block
is
None
or
block
.
block_num
is
None
or
int
(
block
.
block_num
)
!=
block_number
)
and
(
block_number_check_cnt
<
0
or
cnt
<
block_number_check_cnt
)
:
try
:
try
:
block
=
Block
(
block_number
,
only_ops
=
only_ops
,
only_virtual_ops
=
only_virtual_ops
,
steem_instance
=
self
.
steem
)
block
=
Block
(
block_number
,
only_ops
=
only_ops
,
only_virtual_ops
=
only_virtual_ops
,
steem_instance
=
self
.
steem
)
cnt
+=
1
except
BlockDoesNotExistsException
:
except
BlockDoesNotExistsException
:
block
=
None
block
=
None
if
repetition
>
blocks_waiting_for
*
self
.
max_block_wait_repetition
:
if
repetition
>
blocks_waiting_for
*
self
.
max_block_wait_repetition
:
...
...
This diff is collapsed.
Click to expand it.
examples/stream_threading_performance.py
+
1
−
1
View file @
a6669107
...
@@ -47,7 +47,7 @@ if __name__ == "__main__":
...
@@ -47,7 +47,7 @@ if __name__ == "__main__":
stm_https
=
Steem
(
node
=
node_list_https
,
timeout
=
timeout
)
stm_https
=
Steem
(
node
=
node_list_https
,
timeout
=
timeout
)
print
(
"
Without threading wss
"
)
print
(
"
Without threading wss
"
)
opcount_wot_wss
,
total_duration_wot_wss
=
stream_votes
(
stm_wss
,
False
,
8
)
opcount_wot_wss
,
total_duration_wot_wss
=
stream_votes
(
stm_wss
,
False
,
8
)
print
(
"
Without threading
ws
s
"
)
print
(
"
Without threading
http
s
"
)
opcount_wot_https
,
total_duration_wot_https
=
stream_votes
(
stm_https
,
False
,
8
)
opcount_wot_https
,
total_duration_wot_https
=
stream_votes
(
stm_https
,
False
,
8
)
if
threading
:
if
threading
:
print
(
"
\n
Threading with %d threads is activated now.
"
%
thread_num
)
print
(
"
\n
Threading with %d threads is activated now.
"
%
thread_num
)
...
...
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