chunk write fix

This commit is contained in:
nxsofsys 2018-01-15 06:11:35 +03:00
parent 18ca29bfa9
commit 6670b94fc0
1 changed files with 3 additions and 2 deletions

View File

@ -215,12 +215,13 @@ class Blockchain(util.PrintError):
def save_chunk(self, index, chunk): def save_chunk(self, index, chunk):
filename = self.path() filename = self.path()
height = index * NetworkConstants.CHUNK_SIZE - self.checkpoint
with open(filename, 'rb') as f: 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: if d < 0:
chunk = chunk[-d:] chunk = chunk[-d:]
d = 0 d = 0
self.write(chunk, d, index > len(self.checkpoints)) self.write(chunk, height, index > len(self.checkpoints))
self.swap_with_parent() self.swap_with_parent()
def swap_with_parent(self): def swap_with_parent(self):