Skip to content

Commit d8eb1cc

Browse files
committed
default get_block to strict
1 parent 609a39e commit d8eb1cc

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

hive/steem/block/stream.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def start(self, start_block):
8282

8383
while self._gap_ok(curr, head):
8484
head = schedule.wait_for_block(curr)
85-
block = self._client.get_block(curr)
85+
block = self._client.get_block(curr, strict=False)
8686
schedule.check_block(curr, block)
8787

8888
if not block:

hive/steem/client.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,19 @@ def get_content_batch(self, tuples):
4646
assert 'author' in post, "invalid post: %s" % post
4747
return posts
4848

49-
def get_block(self, num):
49+
def get_block(self, num, strict=True):
5050
"""Fetches a single block.
5151
5252
If the result does not contain a `block` key, it's assumed
5353
this block does not yet exist and None is returned.
5454
"""
5555
result = self.__exec('get_block', {'block_num': num})
56-
return result['block'] if 'block' in result else None
56+
if 'block' in result:
57+
return result['block']
58+
elif strict:
59+
raise Exception('block %d not available' % num)
60+
else:
61+
return None
5762

5863
def stream_blocks(self, start_from, trail_blocks=0, max_gap=100):
5964
"""Stream blocks. Returns a generator."""

0 commit comments

Comments
 (0)