Skip to content

Commit

Permalink
Fix issue #69 and fix a bug in batched streaming + cli
Browse files Browse the repository at this point in the history
remove auto_clean from streaming
  • Loading branch information
holgern committed Aug 15, 2018
1 parent 78281e7 commit 6445641
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 28 deletions.
31 changes: 14 additions & 17 deletions beem/blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,6 @@ def blocks(self, start=None, stop=None, max_batch_size=None, threading=False, th
current_block_num = self.get_current_block_num()
head_block = current_block_num
if threading and not head_block_reached:
# disable autoclean
auto_clean = current_block.get_cache_auto_clean()
latest_block = start - 1
result_block_nums = []
for blocknum in range(start, head_block + 1, thread_num):
Expand All @@ -423,8 +421,7 @@ def blocks(self, start=None, stop=None, max_batch_size=None, threading=False, th
if FUTURES_MODULE is not None:
futures = []
block_num_list = []
# current_block.set_cache_auto_clean(False)
freeze = self.steem.rpc.nodes.freeze_current_node
# freeze = self.steem.rpc.nodes.freeze_current_node
num_retries = self.steem.rpc.nodes.num_retries
# self.steem.rpc.nodes.freeze_current_node = True
self.steem.rpc.nodes.num_retries = thread_num
Expand All @@ -448,10 +445,8 @@ def blocks(self, start=None, stop=None, max_batch_size=None, threading=False, th
for result in pool.results():
results.append(result)
pool.abort()
# current_block.clear_cache_from_expired_items()
# current_block.set_cache_auto_clean(auto_clean)
self.steem.rpc.nodes.num_retries = num_retries
self.steem.rpc.nodes.freeze_current_node = freeze
# self.steem.rpc.nodes.freeze_current_node = freeze
new_error_cnt = self.steem.rpc.nodes.node.error_cnt
self.steem.rpc.nodes.node.error_cnt = error_cnt
if new_error_cnt > error_cnt:
Expand All @@ -460,12 +455,11 @@ def blocks(self, start=None, stop=None, max_batch_size=None, threading=False, th

checked_results = []
for b in results:
if len(b.operations) > 0:
if b.block_num is not None and int(b.block_num) not in result_block_nums:
b["id"] = b.block_num
b.identifier = b.block_num
checked_results.append(b)
result_block_nums.append(int(b.block_num))
if b.block_num is not None and int(b.block_num) not in result_block_nums:
b["id"] = b.block_num
b.identifier = b.block_num
checked_results.append(b)
result_block_nums.append(int(b.block_num))

missing_block_num = list(set(block_num_list).difference(set(result_block_nums)))
while len(missing_block_num) > 0:
Expand All @@ -490,7 +484,6 @@ def blocks(self, start=None, stop=None, max_batch_size=None, threading=False, th
block = Block(blocknum, only_ops=only_ops, only_virtual_ops=only_virtual_ops, steem_instance=self.steem)
result_block_nums.append(blocknum)
yield block
current_block.set_cache_auto_clean(auto_clean)
elif max_batch_size is not None and (head_block - start) >= max_batch_size and not head_block_reached:
if not self.steem.is_connected():
raise OfflineHasNoRPCException("No RPC available in offline mode!")
Expand Down Expand Up @@ -534,14 +527,18 @@ def blocks(self, start=None, stop=None, max_batch_size=None, threading=False, th
if not isinstance(block_batch, list):
block_batch = [block_batch]
for block in block_batch:
if not bool(block):
continue
if self.steem.rpc.get_use_appbase():
if only_virtual_ops:
block = block["ops"]
else:
block = block["block"]
block["id"] = blocknum
yield Block(block, only_ops=only_ops, only_virtual_ops=only_virtual_ops, steem_instance=self.steem)
blocknum += 1
block = Block(block, only_ops=only_ops, only_virtual_ops=only_virtual_ops, steem_instance=self.steem)
block["id"] = block.block_num
block.identifier = block.block_num
yield block
blocknum = block.block_num
else:
# Blocks from start until head block
for blocknum in range(start, head_block + 1):
Expand Down
12 changes: 6 additions & 6 deletions beem/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1882,13 +1882,13 @@ def witnessupdate(witness, maximum_block_size, account_creation_fee, sbd_interes
return
witness = Witness(witness, steem_instance=stm)
props = witness["props"]
if account_creation_fee:
if account_creation_fee is not None:
props["account_creation_fee"] = str(
Amount("%f STEEM" % account_creation_fee))
if maximum_block_size:
props["maximum_block_size"] = maximum_block_size
if sbd_interest_rate:
props["sbd_interest_rate"] = int(sbd_interest_rate * 100)
Amount("%f STEEM" % float(account_creation_fee)))
if maximum_block_size is not None:
props["maximum_block_size"] = int(maximum_block_size)
if sbd_interest_rate is not None:
props["sbd_interest_rate"] = int(float(sbd_interest_rate) * 100)
tx = witness.update(signing_key or witness["signing_key"], url or witness["url"], props)
if stm.unsigned and stm.nobroadcast and stm.steemconnect is not None:
tx = stm.steemconnect.url_from_tx(tx)
Expand Down
2 changes: 1 addition & 1 deletion beem/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""THIS FILE IS GENERATED FROM beem SETUP.PY."""
version = '0.19.53'
version = '0.19.54'
2 changes: 1 addition & 1 deletion beemapi/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""THIS FILE IS GENERATED FROM beem SETUP.PY."""
version = '0.19.53'
version = '0.19.54'
2 changes: 1 addition & 1 deletion beembase/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""THIS FILE IS GENERATED FROM beem SETUP.PY."""
version = '0.19.53'
version = '0.19.54'
2 changes: 1 addition & 1 deletion beemgraphenebase/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""THIS FILE IS GENERATED FROM beem SETUP.PY."""
version = '0.19.53'
version = '0.19.54'
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
ascii = codecs.lookup('ascii')
codecs.register(lambda name, enc=ascii: {True: enc}.get(name == 'mbcs'))

VERSION = '0.19.53'
VERSION = '0.19.54'

tests_require = ['mock >= 2.0.0', 'pytest', 'pytest-mock', 'parameterized']

Expand Down

0 comments on commit 6445641

Please sign in to comment.