Add missing tracerr.Wrap
Eduard S eduard@iden3.io
Thu, 24 Dec 2020 13:39:27 +0100
4 files changed,
11 insertions(+),
11 deletions(-)
M
db/statedb/statedb.go
→
db/statedb/statedb.go
@@ -220,7 +220,7 @@ // If there's a gap between the list of checkpoints, an error is returned.
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 @@ for _, file := range files {
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 @@ first := checkpoints[0]
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 @@ // `s.keep` checkpoints
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 @@ }
// 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 {
M
node/node.go
→
node/node.go
@@ -419,7 +419,7 @@ blockData, discarded, err := n.sync.Sync2(ctx, lastBlock)
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)
M
priceupdater/priceupdater.go
→
priceupdater/priceupdater.go
@@ -68,7 +68,7 @@ if err != nil {
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 }
M
prover/prover.go
→
prover/prover.go
@@ -48,7 +48,7 @@ p.PiA[0] = (*big.Int)(proof.PiA[0])
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 @@ p.PiB[1][1] = (*big.Int)(proof.PiB[1][1])
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