rename close to flush_out and only use explicitly use if needed inside contextmanager scope
This commit is contained in:
parent
7cffec944d
commit
7e1b6dd7b5
@ -824,7 +824,7 @@ class ApproveTransaction(UserAuthorizedAction):
|
||||
else:
|
||||
self.psbt.serialize(fd)
|
||||
|
||||
fd.close()
|
||||
#fd.flush_out() not needed - flush is part of __exit__
|
||||
self.result = (fd.tell(), fd.checksum.digest())
|
||||
|
||||
self.done(redraw=(not txid))
|
||||
@ -1185,7 +1185,7 @@ async def sign_psbt_file(filename, force_vdisk=False, slot_b=None):
|
||||
with SFFile(TXN_OUTPUT_OFFSET, max_size=MAX_TXN_LEN, message="Saving...") as fd0:
|
||||
await fd0.erase()
|
||||
txid = psbt.finalize(fd0)
|
||||
fd0.close()
|
||||
fd0.flush_out() # need to flush here as we are probably not gona call .read( again
|
||||
tx_len, tx_sha = fd0.tell(), fd0.checksum.digest()
|
||||
if txid and await try_push_tx(tx_len, txid, tx_sha):
|
||||
return # success, exit
|
||||
|
||||
@ -587,7 +587,7 @@ class NFCHandler:
|
||||
else:
|
||||
psbt.serialize(fd)
|
||||
|
||||
fd.close()
|
||||
# fd.flush_out() not needed - flush is part of __exit__
|
||||
self.result = (fd.tell(), fd.checksum.digest())
|
||||
|
||||
out_len, out_sha = self.result
|
||||
|
||||
@ -81,7 +81,7 @@ class SFFile:
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||
self.close()
|
||||
self.flush_out()
|
||||
|
||||
if self.message:
|
||||
from glob import dis
|
||||
@ -89,7 +89,7 @@ class SFFile:
|
||||
|
||||
return False
|
||||
|
||||
def close(self):
|
||||
def flush_out(self):
|
||||
# PSRAM might leave a little behind
|
||||
if self.runt:
|
||||
# write final runt, might be up to 3 bytes (padding w/ zeros)
|
||||
|
||||
@ -975,9 +975,9 @@ async def qr_psbt_sign(decoder, psbt_len, raw):
|
||||
txid = psbt.finalize(fd)
|
||||
else:
|
||||
psbt.serialize(fd)
|
||||
psram.close()
|
||||
data_len = psram.tell()
|
||||
sha = fd.checksum.digest()
|
||||
|
||||
#psram.flush_out() not needed - flush is part of __exit__
|
||||
data_len, sha = psram.tell(), fd.checksum.digest()
|
||||
|
||||
UserAuthorizedAction.cleanup()
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user