Merge pull request #6 from BTCP-community/chunk_write_fix

chunk write fix
This commit is contained in:
Jon Layton 2018-01-14 21:15:44 -06:00 committed by GitHub
commit 1dad9e8893
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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):
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):