1
0

file i/o: use 'with' keyword

This commit is contained in:
SomberNight
2017-11-12 14:33:46 +01:00
parent 8fcf1656d3
commit c65d01ea96
8 changed files with 22 additions and 20 deletions

View File

@@ -247,10 +247,9 @@ class Blockchain(util.PrintError):
delta = height - self.checkpoint
name = self.path()
if os.path.exists(name):
f = open(name, 'rb')
f.seek(delta * 80)
h = f.read(80)
f.close()
with open(name, 'rb') as f:
f.seek(delta * 80)
h = f.read(80)
return deserialize_header(h, height)
def get_hash(self, height):