Skip to content

Commit 8206414

Browse files
committed
chore: apply suggestions
1 parent c872b4a commit 8206414

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

examples/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ Let us know if you find any issue or if you want to contribute and add a new tut
99
- [Fetching a UnixFS file by CID](./unixfs-file-cid)
1010
- [Gateway backed by a CAR file](./gateway/car)
1111
- [Gateway backed by a remote blockstore and IPNS resolver](./gateway/proxy)
12-
- [Delegated Routing V1 Command Line Client](./routing-v1/client/)
12+
- [Delegated Routing V1 Command Line Client](./routing/delegated-routing-client/)

examples/routing/delegated-routing-client/main.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -125,18 +125,24 @@ func findIPNS(w io.Writer, ctx context.Context, client *client.Client, nameStr s
125125
return err
126126
}
127127

128-
// Ask for a record. [client.GetIPNS] validates the record for us.
128+
// Fetch an IPNS record for the given name. [client.Client.GetIPNS] verifies
129+
// if the retrieved record is valid against the given name, and errors otherwise.
129130
record, err := client.GetIPNS(ctx, name)
130131
if err != nil {
131132
return err
132133
}
133134

135+
fmt.Fprintf(w, "/ipns/%s\n", name)
134136
v, err := record.Value()
135137
if err != nil {
136138
return err
137139
}
138140

139-
fmt.Fprintf(w, "/ipns/%s\n", name)
141+
// Since [client.Client.GetIPNS] verifies if the retrieved record is valid, we
142+
// do not need to verify it again. However, if you were not using this specific
143+
// client, but using some other tool, you should always validate the IPNS Record
144+
// using the [ipns.Validate] or [ipns.ValidateWithName] functions.
145+
fmt.Fprintln(w, "\tSignature: VALID")
140146
fmt.Fprintln(w, "\tValue:", v.String())
141147
return nil
142148
}

examples/routing/delegated-routing-client/main_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func TestGetIPNS(t *testing.T) {
6868

6969
out := &bytes.Buffer{}
7070
err := run(out, ts.URL, "", "", name.String(), 1)
71-
assert.Contains(t, out.String(), fmt.Sprintf("/ipns/%s\n\tValue: /ipfs/bafkreifjjcie6lypi6ny7amxnfftagclbuxndqonfipmb64f2km2devei4\n", name.String()))
71+
assert.Contains(t, out.String(), fmt.Sprintf("/ipns/%s\n\tSignature: VALID\n\tValue: /ipfs/bafkreifjjcie6lypi6ny7amxnfftagclbuxndqonfipmb64f2km2devei4\n", name.String()))
7272
assert.NoError(t, err)
7373
}
7474

0 commit comments

Comments
 (0)