Browse Source

Add missing tracerr.Wrap

feature/sql-semaphore1
Eduard S 3 years ago
parent
commit
a0c8ace38d
4 changed files with 11 additions and 11 deletions
  1. +6
    -6
      db/statedb/statedb.go
  2. +1
    -1
      node/node.go
  3. +1
    -1
      priceupdater/priceupdater.go
  4. +3
    -3
      prover/prover.go

+ 6
- 6
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 {

+ 1
- 1
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)

+ 1
- 1
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
}

+ 3
- 3
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

Loading…
Cancel
Save