avoid overshadowing err in defers
This commit is contained in:
parent
768357293c
commit
fe88e90181
@ -110,6 +110,7 @@ func (p *publisher) PublishHeader(header *types.Header) (err error) {
|
||||
return err
|
||||
}
|
||||
tx := pubTx{snapTx, nil}
|
||||
// we must avoid overshadowing the `err`
|
||||
defer func() {
|
||||
err = snapt.CommitOrRollback(tx, err)
|
||||
if err != nil {
|
||||
@ -117,7 +118,7 @@ func (p *publisher) PublishHeader(header *types.Header) (err error) {
|
||||
}
|
||||
}()
|
||||
|
||||
if err := tx.publishIPLD(headerNode.Cid(), headerNode.RawData(), header.Number); err != nil {
|
||||
if err = tx.publishIPLD(headerNode.Cid(), headerNode.RawData(), header.Number); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -200,8 +200,12 @@ func (s *Service) createSnapshot(ctx context.Context, it trie.NodeIterator, head
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// we must avoid overshadowing the `err`
|
||||
defer func() {
|
||||
err = CommitOrRollback(tx, err)
|
||||
if err != nil {
|
||||
log.Errorf("CommitOrRollback failed: %s", err)
|
||||
}
|
||||
}()
|
||||
|
||||
// path (from recovery dump) to be seeked on recovery
|
||||
|
Loading…
Reference in New Issue
Block a user