Merge pull request #77 from cerc-io/ian/v5_dev
fix: err overshadowing in defers
This commit is contained in:
commit
da02e5ac12
@ -110,6 +110,7 @@ func (p *publisher) PublishHeader(header *types.Header) (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
tx := pubTx{snapTx, nil}
|
tx := pubTx{snapTx, nil}
|
||||||
|
// we must avoid overshadowing the `err`
|
||||||
defer func() {
|
defer func() {
|
||||||
err = snapt.CommitOrRollback(tx, err)
|
err = snapt.CommitOrRollback(tx, err)
|
||||||
if err != nil {
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,8 +200,12 @@ func (s *Service) createSnapshot(ctx context.Context, it trie.NodeIterator, head
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
// we must avoid overshadowing the `err`
|
||||||
defer func() {
|
defer func() {
|
||||||
err = CommitOrRollback(tx, err)
|
err = CommitOrRollback(tx, err)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("CommitOrRollback failed: %s", err)
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// path (from recovery dump) to be seeked on recovery
|
// path (from recovery dump) to be seeked on recovery
|
||||||
|
Loading…
Reference in New Issue
Block a user