cmd/utils: defer close in ImportHistory

This commit is contained in:
lightclient 2026-01-30 07:06:46 -07:00
parent 2dafd06f23
commit 9755543d30
No known key found for this signature in database
GPG key ID: 657913021EF45A6A

View file

@ -286,8 +286,8 @@ func ImportHistory(chain *core.BlockChain, dir string, network string, from func
if err != nil {
return fmt.Errorf("open %s: %w", path, err)
}
defer f.Close()
if _, err := io.Copy(h, f); err != nil {
f.Close()
return fmt.Errorf("checksum %s: %w", path, err)
}
got := common.BytesToHash(h.Sum(scratch.Bytes()[:])).Hex()
@ -296,7 +296,6 @@ func ImportHistory(chain *core.BlockChain, dir string, network string, from func
scratch.Reset()
if got != want {
f.Close()
return fmt.Errorf("%s checksum mismatch: have %s want %s", file, got, want)
}
// Import all block data from Era1.