mirror of
https://github.com/aljazceru/plugins.git
synced 2025-12-24 08:34:18 +01:00
historian: Make the GossipStream seekable
This commit is contained in:
@@ -57,6 +57,21 @@ class GossipStream:
|
||||
assert header[:3] == b"GSP"
|
||||
assert header[3] == 1
|
||||
|
||||
def seek(self, offset):
|
||||
"""Allow skipping to a specific point in the stream.
|
||||
|
||||
The offset is denoted in bytes from the start, including the
|
||||
header, and matches the value of f.tell()
|
||||
"""
|
||||
self.stream.seek(offset, io.SEEK_SET)
|
||||
|
||||
def tell(self):
|
||||
"""Returns the absolute position in the stream.
|
||||
|
||||
Includes the header, and matches f.seek()
|
||||
"""
|
||||
return self.stream.tell()
|
||||
|
||||
def __iter__(self):
|
||||
return self
|
||||
|
||||
|
||||
Reference in New Issue
Block a user