mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 03:16:45 +01:00
Add missing tracerr.Wrap
This commit is contained in:
@@ -220,7 +220,7 @@ func (s *StateDB) DeleteCheckpoint(batchNum common.BatchNum) error {
|
|||||||
func (s *StateDB) listCheckpoints() ([]int, error) {
|
func (s *StateDB) listCheckpoints() ([]int, error) {
|
||||||
files, err := ioutil.ReadDir(s.path)
|
files, err := ioutil.ReadDir(s.path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, tracerr.Wrap(err)
|
||||||
}
|
}
|
||||||
checkpoints := []int{}
|
checkpoints := []int{}
|
||||||
var checkpoint int
|
var checkpoint int
|
||||||
@@ -229,7 +229,7 @@ func (s *StateDB) listCheckpoints() ([]int, error) {
|
|||||||
fileName := file.Name()
|
fileName := file.Name()
|
||||||
if file.IsDir() && strings.HasPrefix(fileName, PathBatchNum) {
|
if file.IsDir() && strings.HasPrefix(fileName, PathBatchNum) {
|
||||||
if _, err := fmt.Sscanf(fileName, pattern, &checkpoint); err != nil {
|
if _, err := fmt.Sscanf(fileName, pattern, &checkpoint); err != nil {
|
||||||
return nil, err
|
return nil, tracerr.Wrap(err)
|
||||||
}
|
}
|
||||||
checkpoints = append(checkpoints, checkpoint)
|
checkpoints = append(checkpoints, checkpoint)
|
||||||
}
|
}
|
||||||
@@ -240,7 +240,7 @@ func (s *StateDB) listCheckpoints() ([]int, error) {
|
|||||||
for _, checkpoint := range checkpoints[1:] {
|
for _, checkpoint := range checkpoints[1:] {
|
||||||
first++
|
first++
|
||||||
if checkpoint != 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 {
|
func (s *StateDB) deleteOldCheckpoints() error {
|
||||||
list, err := s.listCheckpoints()
|
list, err := s.listCheckpoints()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return tracerr.Wrap(err)
|
||||||
}
|
}
|
||||||
if len(list) > s.keep {
|
if len(list) > s.keep {
|
||||||
for _, checkpoint := range list[:len(list)-s.keep] {
|
for _, checkpoint := range list[:len(list)-s.keep] {
|
||||||
if err := s.DeleteCheckpoint(common.BatchNum(checkpoint)); err != nil {
|
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
|
// remove all checkpoints > batchNum
|
||||||
for i := batchNum + 1; i <= s.currentBatch; i++ {
|
for i := batchNum + 1; i <= s.currentBatch; i++ {
|
||||||
if err := s.DeleteCheckpoint(i); err != nil {
|
if err := s.DeleteCheckpoint(i); err != nil {
|
||||||
return err
|
return tracerr.Wrap(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if batchNum == 0 {
|
if batchNum == 0 {
|
||||||
|
|||||||
@@ -419,7 +419,7 @@ func (n *Node) syncLoopFn(ctx context.Context, lastBlock *common.Block) (*common
|
|||||||
stats := n.sync.Stats()
|
stats := n.sync.Stats()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// case: error
|
// case: error
|
||||||
return nil, n.cfg.Synchronizer.SyncLoopInterval.Duration, err
|
return nil, n.cfg.Synchronizer.SyncLoopInterval.Duration, tracerr.Wrap(err)
|
||||||
} else if discarded != nil {
|
} else if discarded != nil {
|
||||||
// case: reorg
|
// case: reorg
|
||||||
log.Infow("Synchronizer.Sync reorg", "discarded", *discarded)
|
log.Infow("Synchronizer.Sync reorg", "discarded", *discarded)
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ func getTokenPriceBitfinex(ctx context.Context, client *sling.Sling,
|
|||||||
return 0, tracerr.Wrap(err)
|
return 0, tracerr.Wrap(err)
|
||||||
}
|
}
|
||||||
if res.StatusCode != http.StatusOK {
|
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
|
return state[6], nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ func (p *Proof) UnmarshalJSON(data []byte) error {
|
|||||||
p.PiA[1] = (*big.Int)(proof.PiA[1])
|
p.PiA[1] = (*big.Int)(proof.PiA[1])
|
||||||
p.PiA[2] = (*big.Int)(proof.PiA[2])
|
p.PiA[2] = (*big.Int)(proof.PiA[2])
|
||||||
if p.PiA[2].Int64() != 1 {
|
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][0] = (*big.Int)(proof.PiB[0][0])
|
||||||
p.PiB[0][1] = (*big.Int)(proof.PiB[0][1])
|
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][0] = (*big.Int)(proof.PiB[2][0])
|
||||||
p.PiB[2][1] = (*big.Int)(proof.PiB[2][1])
|
p.PiB[2][1] = (*big.Int)(proof.PiB[2][1])
|
||||||
if p.PiB[2][0].Int64() != 1 || p.PiB[2][1].Int64() != 0 {
|
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[0] = (*big.Int)(proof.PiC[0])
|
||||||
p.PiC[1] = (*big.Int)(proof.PiC[1])
|
p.PiC[1] = (*big.Int)(proof.PiC[1])
|
||||||
p.PiC[2] = (*big.Int)(proof.PiC[2])
|
p.PiC[2] = (*big.Int)(proof.PiC[2])
|
||||||
if p.PiC[2].Int64() != 1 {
|
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
|
// TODO: Assert ones and zeroes
|
||||||
p.Protocol = proof.Protocol
|
p.Protocol = proof.Protocol
|
||||||
|
|||||||
Reference in New Issue
Block a user