Skip to content
Snippets Groups Projects
Commit ae6b65ae authored by roadscape's avatar roadscape
Browse files

default get_block to strict

parent 182ce782
No related branches found
No related tags found
No related merge requests found
...@@ -82,7 +82,7 @@ class BlockStream: ...@@ -82,7 +82,7 @@ class BlockStream:
while self._gap_ok(curr, head): while self._gap_ok(curr, head):
head = schedule.wait_for_block(curr) head = schedule.wait_for_block(curr)
block = self._client.get_block(curr) block = self._client.get_block(curr, strict=False)
schedule.check_block(curr, block) schedule.check_block(curr, block)
if not block: if not block:
......
...@@ -46,14 +46,19 @@ class SteemClient: ...@@ -46,14 +46,19 @@ class SteemClient:
assert 'author' in post, "invalid post: %s" % post assert 'author' in post, "invalid post: %s" % post
return posts return posts
def get_block(self, num): def get_block(self, num, strict=True):
"""Fetches a single block. """Fetches a single block.
If the result does not contain a `block` key, it's assumed If the result does not contain a `block` key, it's assumed
this block does not yet exist and None is returned. this block does not yet exist and None is returned.
""" """
result = self.__exec('get_block', {'block_num': num}) result = self.__exec('get_block', {'block_num': num})
return result['block'] if 'block' in result else None if 'block' in result:
return result['block']
elif strict:
raise Exception('block %d not available' % num)
else:
return None
def stream_blocks(self, start_from, trail_blocks=0, max_gap=100): def stream_blocks(self, start_from, trail_blocks=0, max_gap=100):
"""Stream blocks. Returns a generator.""" """Stream blocks. Returns a generator."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment