Skip to content

Commit cad5034

Browse files
committed
proof: rename methods
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
1 parent 0b9719e commit cad5034

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

cmd/ufsproof/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Only one of these options should be provided.
6363
log.Fatalf("wiring dagservice: %s", err)
6464
}
6565

66-
proof, err := unixfsproof.CreateProof(c.Context(), rootCid, offset, dserv)
66+
proof, err := unixfsproof.Prove(c.Context(), rootCid, offset, dserv)
6767
if err != nil {
6868
log.Fatalf("generating proof: %s", err)
6969
}
@@ -101,7 +101,7 @@ var verifyProofCmd = &cobra.Command{
101101
log.Fatalf("reading proof file: %s", err)
102102
}
103103

104-
ok, err := unixfsproof.ValidateProof(c.Context(), rootCid, offset, proof)
104+
ok, err := unixfsproof.Verify(c.Context(), rootCid, offset, proof)
105105
if err != nil {
106106
log.Fatalf("verifying proof: %s", err)
107107
}

proof.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ import (
2020
"github.com/ipld/go-car/util"
2121
)
2222

23-
// ValidateProof validates a proof for a Cid at a specified offset. If the proof is valid, the return
23+
// Verify validates a proof for a Cid at a specified offset. If the proof is valid, the return
2424
// parameter is true. If the proof is invalid false is returned. In any other case an error is returned.
25-
func ValidateProof(ctx context.Context, root cid.Cid, offset uint64, proof []byte) (bool, error) {
25+
func Verify(ctx context.Context, root cid.Cid, offset uint64, proof []byte) (bool, error) {
2626
r := bufio.NewReader(bytes.NewReader(proof))
2727

2828
bstore := blockstore.NewBlockstore(dssync.MutexWrap(datastore.NewMapDatastore()))
@@ -54,16 +54,16 @@ func ValidateProof(ctx context.Context, root cid.Cid, offset uint64, proof []byt
5454
// Smart (or lazy?) way to verify the proof. If we assume an ideal full DAGStore, trying to
5555
// re-create the proof with the proof as the underlying blockstore should fail if something
5656
// is missing.
57-
regenProof, err := CreateProof(ctx, root, offset, dserv)
57+
regenProof, err := Prove(ctx, root, offset, dserv)
5858
if err != nil {
5959
return false, nil
6060
}
6161

6262
return bytes.Equal(proof, regenProof), nil
6363
}
6464

65-
// CreateProof creates a proof for a Cid at a specified file offset.
66-
func CreateProof(ctx context.Context, root cid.Cid, offset uint64, dserv ipld.DAGService) ([]byte, error) {
65+
// Prove creates a proof for a Cid at a specified file offset.
66+
func Prove(ctx context.Context, root cid.Cid, offset uint64, dserv ipld.DAGService) ([]byte, error) {
6767
n, err := dserv.Get(ctx, root)
6868
if err != nil {
6969
return nil, fmt.Errorf("get %s from dag service: %s", root, err)

proof_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ func TestProofVerify(t *testing.T) {
6161
t.Run(tname, func(t *testing.T) {
6262
t.Parallel()
6363

64-
proof, err := CreateProof(ctx, rootCid, test.proofOffset, dserv)
64+
proof, err := Prove(ctx, rootCid, test.proofOffset, dserv)
6565
if test.notOkProof {
6666
require.Error(t, err)
6767
return
6868
}
6969
require.NoError(t, err)
7070

71-
ok, err := ValidateProof(ctx, rootCid, test.verifOffset, proof)
71+
ok, err := Verify(ctx, rootCid, test.verifOffset, proof)
7272
require.NoError(t, err)
7373
require.Equal(t, !test.notOkVerif, ok)
7474
})

0 commit comments

Comments
 (0)