Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jianoaix committed Feb 5, 2024
1 parent a34e98f commit 8923b84
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions pkg/encoding/utils/pointsIO.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package utils

import (
"bufio"
"fmt"
"io"
"log"
"os"
Expand Down Expand Up @@ -100,6 +101,9 @@ func ReadG1Points(filepath string, n uint64, numWorker uint64) ([]bls.G1Point, e

// from is inclusive, to is exclusive
func ReadG1PointSection(filepath string, from, to uint64, numWorker uint64) ([]bls.G1Point, error) {
if to <= from {
return nil, fmt.Errorf("The range to read is invalid, from: %v, to: %v", from, to)
}
g1f, err := os.Open(filepath)
if err != nil {
log.Println("ReadG1PointSection.ERR.0", err)
Expand Down Expand Up @@ -265,7 +269,11 @@ func ReadG2Points(filepath string, n uint64, numWorker uint64) ([]bls.G2Point, e
return s2Outs, nil
}

// from is inclusive, to is exclusive
func ReadG2PointSection(filepath string, from, to uint64, numWorker uint64) ([]bls.G2Point, error) {
if to <= from {
return nil, fmt.Errorf("The range to read is invalid, from: %v, to: %v", from, to)
}
g2f, err := os.Open(filepath)
if err != nil {
log.Println("ReadG2PointSection.ERR.0", err)
Expand Down Expand Up @@ -298,13 +306,6 @@ func ReadG2PointSection(filepath string, from, to uint64, numWorker uint64) ([]b
return nil, err
}

if uint64(len(buf)) < G2PointBytes*n {
log.Printf("Error. Insufficient G2 points. Only contains %v. Requesting %v\n", len(buf)/G2PointBytes, n)
log.Println()
log.Println("ReadG2PointSection.ERR.1", err)
return nil, err
}

// measure reading time
t := time.Now()
elapsed := t.Sub(startTimer)
Expand Down

0 comments on commit 8923b84

Please sign in to comment.