diff --git a/examples/README.md b/examples/README.md index 4c496e6a66..c0795436d9 100644 --- a/examples/README.md +++ b/examples/README.md @@ -9,4 +9,4 @@ Let us know if you find any issue or if you want to contribute and add a new tut - [Fetching a UnixFS file by CID](./unixfs-file-cid) - [Gateway backed by a CAR file](./gateway/car) - [Gateway backed by a remote blockstore and IPNS resolver](./gateway/proxy) -- [Delegated Routing V1 Command Line Client](./routing-v1/client/) +- [Delegated Routing V1 Command Line Client](./routing/delegated-routing-client/) diff --git a/examples/routing/delegated-routing-client/main.go b/examples/routing/delegated-routing-client/main.go index 43cf68a410..0b586d4bf0 100644 --- a/examples/routing/delegated-routing-client/main.go +++ b/examples/routing/delegated-routing-client/main.go @@ -125,18 +125,24 @@ func findIPNS(w io.Writer, ctx context.Context, client *client.Client, nameStr s return err } - // Ask for a record. [client.GetIPNS] validates the record for us. + // Fetch an IPNS record for the given name. [client.Client.GetIPNS] verifies + // if the retrieved record is valid against the given name, and errors otherwise. record, err := client.GetIPNS(ctx, name) if err != nil { return err } + fmt.Fprintf(w, "/ipns/%s\n", name) v, err := record.Value() if err != nil { return err } - fmt.Fprintf(w, "/ipns/%s\n", name) + // Since [client.Client.GetIPNS] verifies if the retrieved record is valid, we + // do not need to verify it again. However, if you were not using this specific + // client, but using some other tool, you should always validate the IPNS Record + // using the [ipns.Validate] or [ipns.ValidateWithName] functions. + fmt.Fprintln(w, "\tSignature: VALID") fmt.Fprintln(w, "\tValue:", v.String()) return nil } diff --git a/examples/routing/delegated-routing-client/main_test.go b/examples/routing/delegated-routing-client/main_test.go index 350d25032a..7ad813f136 100644 --- a/examples/routing/delegated-routing-client/main_test.go +++ b/examples/routing/delegated-routing-client/main_test.go @@ -68,7 +68,7 @@ func TestGetIPNS(t *testing.T) { out := &bytes.Buffer{} err := run(out, ts.URL, "", "", name.String(), 1) - assert.Contains(t, out.String(), fmt.Sprintf("/ipns/%s\n\tValue: /ipfs/bafkreifjjcie6lypi6ny7amxnfftagclbuxndqonfipmb64f2km2devei4\n", name.String())) + assert.Contains(t, out.String(), fmt.Sprintf("/ipns/%s\n\tSignature: VALID\n\tValue: /ipfs/bafkreifjjcie6lypi6ny7amxnfftagclbuxndqonfipmb64f2km2devei4\n", name.String())) assert.NoError(t, err) }