Merge pull request #6 from BTCP-community/chunk_write_fix
chunk write fix
This commit is contained in:
commit
1dad9e8893
|
@ -215,12 +215,13 @@ class Blockchain(util.PrintError):
|
|||
|
||||
def save_chunk(self, index, chunk):
|
||||
filename = self.path()
|
||||
height = index * NetworkConstants.CHUNK_SIZE - self.checkpoint
|
||||
with open(filename, 'rb') as f:
|
||||
d = self._height_to_offset(f, index * NetworkConstants.CHUNK_SIZE - self.checkpoint)
|
||||
d = self._height_to_offset(f, height)
|
||||
if d < 0:
|
||||
chunk = chunk[-d:]
|
||||
d = 0
|
||||
self.write(chunk, d, index > len(self.checkpoints))
|
||||
self.write(chunk, height, index > len(self.checkpoints))
|
||||
self.swap_with_parent()
|
||||
|
||||
def swap_with_parent(self):
|
||||
|
|
Loading…
Reference in New Issue