From a0c8ace38d4707ec10567a153f5c16f3902ae294 Mon Sep 17 00:00:00 2001 From: Eduard S Date: Thu, 24 Dec 2020 13:39:27 +0100 Subject: [PATCH] Add missing tracerr.Wrap --- db/statedb/statedb.go | 12 ++++++------ node/node.go | 2 +- priceupdater/priceupdater.go | 2 +- prover/prover.go | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/db/statedb/statedb.go b/db/statedb/statedb.go index 050f756..5b3a4d7 100644 --- a/db/statedb/statedb.go +++ b/db/statedb/statedb.go @@ -220,7 +220,7 @@ func (s *StateDB) DeleteCheckpoint(batchNum common.BatchNum) error { func (s *StateDB) listCheckpoints() ([]int, error) { files, err := ioutil.ReadDir(s.path) if err != nil { - return nil, err + return nil, tracerr.Wrap(err) } checkpoints := []int{} var checkpoint int @@ -229,7 +229,7 @@ func (s *StateDB) listCheckpoints() ([]int, error) { fileName := file.Name() if file.IsDir() && strings.HasPrefix(fileName, PathBatchNum) { if _, err := fmt.Sscanf(fileName, pattern, &checkpoint); err != nil { - return nil, err + return nil, tracerr.Wrap(err) } checkpoints = append(checkpoints, checkpoint) } @@ -240,7 +240,7 @@ func (s *StateDB) listCheckpoints() ([]int, error) { for _, checkpoint := range checkpoints[1:] { first++ if checkpoint != first { - return nil, fmt.Errorf("checkpoint gap at %v", checkpoint) + return nil, tracerr.Wrap(fmt.Errorf("checkpoint gap at %v", checkpoint)) } } } @@ -252,12 +252,12 @@ func (s *StateDB) listCheckpoints() ([]int, error) { func (s *StateDB) deleteOldCheckpoints() error { list, err := s.listCheckpoints() if err != nil { - return err + return tracerr.Wrap(err) } if len(list) > s.keep { for _, checkpoint := range list[:len(list)-s.keep] { if err := s.DeleteCheckpoint(common.BatchNum(checkpoint)); err != nil { - return err + return tracerr.Wrap(err) } } } @@ -324,7 +324,7 @@ func (s *StateDB) reset(batchNum common.BatchNum, closeCurrent bool) error { // remove all checkpoints > batchNum for i := batchNum + 1; i <= s.currentBatch; i++ { if err := s.DeleteCheckpoint(i); err != nil { - return err + return tracerr.Wrap(err) } } if batchNum == 0 { diff --git a/node/node.go b/node/node.go index 5363828..13c065a 100644 --- a/node/node.go +++ b/node/node.go @@ -419,7 +419,7 @@ func (n *Node) syncLoopFn(ctx context.Context, lastBlock *common.Block) (*common stats := n.sync.Stats() if err != nil { // case: error - return nil, n.cfg.Synchronizer.SyncLoopInterval.Duration, err + return nil, n.cfg.Synchronizer.SyncLoopInterval.Duration, tracerr.Wrap(err) } else if discarded != nil { // case: reorg log.Infow("Synchronizer.Sync reorg", "discarded", *discarded) diff --git a/priceupdater/priceupdater.go b/priceupdater/priceupdater.go index f8a87c8..75ae273 100644 --- a/priceupdater/priceupdater.go +++ b/priceupdater/priceupdater.go @@ -68,7 +68,7 @@ func getTokenPriceBitfinex(ctx context.Context, client *sling.Sling, return 0, tracerr.Wrap(err) } if res.StatusCode != http.StatusOK { - return 0, fmt.Errorf("http response is not is %v", res.StatusCode) + return 0, tracerr.Wrap(fmt.Errorf("http response is not is %v", res.StatusCode)) } return state[6], nil } diff --git a/prover/prover.go b/prover/prover.go index 3d8c6ba..53ddca4 100644 --- a/prover/prover.go +++ b/prover/prover.go @@ -48,7 +48,7 @@ func (p *Proof) UnmarshalJSON(data []byte) error { p.PiA[1] = (*big.Int)(proof.PiA[1]) p.PiA[2] = (*big.Int)(proof.PiA[2]) if p.PiA[2].Int64() != 1 { - return fmt.Errorf("Expected PiA[2] == 1, but got %v", p.PiA[2]) + return tracerr.Wrap(fmt.Errorf("Expected PiA[2] == 1, but got %v", p.PiA[2])) } p.PiB[0][0] = (*big.Int)(proof.PiB[0][0]) p.PiB[0][1] = (*big.Int)(proof.PiB[0][1]) @@ -57,13 +57,13 @@ func (p *Proof) UnmarshalJSON(data []byte) error { p.PiB[2][0] = (*big.Int)(proof.PiB[2][0]) p.PiB[2][1] = (*big.Int)(proof.PiB[2][1]) if p.PiB[2][0].Int64() != 1 || p.PiB[2][1].Int64() != 0 { - return fmt.Errorf("Expected PiB[2] == [1, 0], but got %v", p.PiB[2]) + return tracerr.Wrap(fmt.Errorf("Expected PiB[2] == [1, 0], but got %v", p.PiB[2])) } p.PiC[0] = (*big.Int)(proof.PiC[0]) p.PiC[1] = (*big.Int)(proof.PiC[1]) p.PiC[2] = (*big.Int)(proof.PiC[2]) if p.PiC[2].Int64() != 1 { - return fmt.Errorf("Expected PiC[2] == 1, but got %v", p.PiC[2]) + return tracerr.Wrap(fmt.Errorf("Expected PiC[2] == 1, but got %v", p.PiC[2])) } // TODO: Assert ones and zeroes p.Protocol = proof.Protocol