Skip to content

Commit a451ade

Browse files
committed
feat(ipns): refactored IPNS package with lean records
1 parent 6f82d77 commit a451ade

27 files changed

Lines changed: 1330 additions & 1399 deletions

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ The following emojis are used to highlight certain changes:
1818

1919
### Changed
2020

21+
* 🛠 The `ipns` package has been refactored. You should no longer use the direct Protobuf
22+
version of the IPNS Record. Instead, we have a shiny new `ipns.Record` type that wraps
23+
all the required functionality to work the best as possible with IPNS v2 Records. Please
24+
check the [documentation](https://pkg.go.dev/github.com/ipfs/boxo/ipns) for more information.
25+
2126
### Removed
2227

2328
### Fixed

examples/gateway/proxy/routing.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ import (
77
"net/http"
88
"strings"
99

10-
"github.com/gogo/protobuf/proto"
1110
"github.com/ipfs/boxo/ipns"
12-
ipns_pb "github.com/ipfs/boxo/ipns/pb"
1311
"github.com/libp2p/go-libp2p/core/peer"
1412
"github.com/libp2p/go-libp2p/core/routing"
1513
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
@@ -104,13 +102,12 @@ func (ps *proxyRouting) fetch(ctx context.Context, id peer.ID) ([]byte, error) {
104102
return nil, err
105103
}
106104

107-
var entry ipns_pb.IpnsEntry
108-
err = proto.Unmarshal(rb, &entry)
105+
rec, err := ipns.UnmarshalRecord(rb)
109106
if err != nil {
110107
return nil, err
111108
}
112109

113-
err = ipns.ValidateWithPeerID(id, &entry)
110+
err = ipns.ValidateWithPeerID(rec, id)
114111
if err != nil {
115112
return nil, err
116113
}

examples/go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ module github.com/ipfs/boxo/examples
33
go 1.19
44

55
require (
6-
github.com/gogo/protobuf v1.3.2
7-
github.com/ipfs/boxo v0.7.1-0.20230323075409-f4a8dd6614df
6+
github.com/ipfs/boxo v0.8.0
87
github.com/ipfs/go-block-format v0.1.2
98
github.com/ipfs/go-cid v0.4.0
109
github.com/ipfs/go-datastore v0.6.0
@@ -45,6 +44,7 @@ require (
4544
github.com/go-logr/stdr v1.2.2 // indirect
4645
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect
4746
github.com/godbus/dbus/v5 v5.1.0 // indirect
47+
github.com/gogo/protobuf v1.3.2 // indirect
4848
github.com/golang/mock v1.6.0 // indirect
4949
github.com/golang/protobuf v1.5.2 // indirect
5050
github.com/google/gopacket v1.1.19 // indirect
@@ -64,7 +64,6 @@ require (
6464
github.com/ipfs/go-ipld-cbor v0.0.6 // indirect
6565
github.com/ipfs/go-ipld-format v0.5.0 // indirect
6666
github.com/ipfs/go-ipld-legacy v0.2.1 // indirect
67-
github.com/ipfs/go-ipns v0.3.0 // indirect
6867
github.com/ipfs/go-log v1.0.5 // indirect
6968
github.com/ipfs/go-log/v2 v2.5.1 // indirect
7069
github.com/ipfs/go-metrics-interface v0.0.1 // indirect
@@ -82,7 +81,7 @@ require (
8281
github.com/libp2p/go-doh-resolver v0.4.0 // indirect
8382
github.com/libp2p/go-flow-metrics v0.1.0 // indirect
8483
github.com/libp2p/go-libp2p-asn-util v0.2.0 // indirect
85-
github.com/libp2p/go-libp2p-kad-dht v0.21.1 // indirect
84+
github.com/libp2p/go-libp2p-kad-dht v0.23.0 // indirect
8685
github.com/libp2p/go-libp2p-kbucket v0.5.0 // indirect
8786
github.com/libp2p/go-libp2p-record v0.2.0 // indirect
8887
github.com/libp2p/go-msgio v0.3.0 // indirect
@@ -160,6 +159,7 @@ require (
160159
golang.org/x/text v0.7.0 // indirect
161160
golang.org/x/tools v0.3.0 // indirect
162161
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
162+
gonum.org/v1/gonum v0.11.0 // indirect
163163
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect
164164
google.golang.org/grpc v1.53.0 // indirect
165165
google.golang.org/protobuf v1.28.1 // indirect

examples/go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,6 @@ github.com/ipfs/go-ipld-format v0.5.0 h1:WyEle9K96MSrvr47zZHKKcDxJ/vlpET6PSiQsAF
312312
github.com/ipfs/go-ipld-format v0.5.0/go.mod h1:ImdZqJQaEouMjCvqCe0ORUS+uoBmf7Hf+EO/jh+nk3M=
313313
github.com/ipfs/go-ipld-legacy v0.2.1 h1:mDFtrBpmU7b//LzLSypVrXsD8QxkEWxu5qVxN99/+tk=
314314
github.com/ipfs/go-ipld-legacy v0.2.1/go.mod h1:782MOUghNzMO2DER0FlBR94mllfdCJCkTtDtPM51otM=
315-
github.com/ipfs/go-ipns v0.3.0 h1:ai791nTgVo+zTuq2bLvEGmWP1M0A6kGTXUsgv/Yq67A=
316-
github.com/ipfs/go-ipns v0.3.0/go.mod h1:3cLT2rbvgPZGkHJoPO1YMJeh6LtkxopCkKFcio/wE24=
317315
github.com/ipfs/go-log v1.0.5 h1:2dOuUCB1Z7uoczMWgAyDck5JLb72zHzrMnGnCNNbvY8=
318316
github.com/ipfs/go-log v1.0.5/go.mod h1:j0b8ZoR+7+R99LD9jZ6+AJsrzkPbSXbZfGakb5JPtIo=
319317
github.com/ipfs/go-log/v2 v2.1.3/go.mod h1:/8d0SH3Su5Ooc31QlL1WysJhvyOTDCjcCZ9Axpmri6g=
@@ -393,8 +391,8 @@ github.com/libp2p/go-libp2p v0.26.3 h1:6g/psubqwdaBqNNoidbRKSTBEYgaOuKBhHl8Q5tO+
393391
github.com/libp2p/go-libp2p v0.26.3/go.mod h1:x75BN32YbwuY0Awm2Uix4d4KOz+/4piInkp4Wr3yOo8=
394392
github.com/libp2p/go-libp2p-asn-util v0.2.0 h1:rg3+Os8jbnO5DxkC7K/Utdi+DkY3q/d1/1q+8WeNAsw=
395393
github.com/libp2p/go-libp2p-asn-util v0.2.0/go.mod h1:WoaWxbHKBymSN41hWSq/lGKJEca7TNm58+gGJi2WsLI=
396-
github.com/libp2p/go-libp2p-kad-dht v0.21.1 h1:xpfp8/t9+X2ip1l8Umap1/UGNnJ3RHJgKGAEsnRAlTo=
397-
github.com/libp2p/go-libp2p-kad-dht v0.21.1/go.mod h1:Oy8wvbdjpB70eS5AaFaI68tOtrdo3KylTvXDjikxqFo=
394+
github.com/libp2p/go-libp2p-kad-dht v0.23.0 h1:sxE6LxLopp79eLeV695n7+c77V/Vn4AMF28AdM/XFqM=
395+
github.com/libp2p/go-libp2p-kad-dht v0.23.0/go.mod h1:oO5N308VT2msnQI6qi5M61wzPmJYg7Tr9e16m5n7uDU=
398396
github.com/libp2p/go-libp2p-kbucket v0.5.0 h1:g/7tVm8ACHDxH29BGrpsQlnNeu+6OF1A9bno/4/U1oA=
399397
github.com/libp2p/go-libp2p-kbucket v0.5.0/go.mod h1:zGzGCpQd78b5BNTDGHNDLaTt9aDK/A02xeZp9QeFC4U=
400398
github.com/libp2p/go-libp2p-record v0.2.0 h1:oiNUOCWno2BFuxt3my4i1frNrt7PerzB3queqa1NkQ0=
@@ -963,6 +961,8 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T
963961
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
964962
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk=
965963
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8=
964+
gonum.org/v1/gonum v0.11.0 h1:f1IJhK4Km5tBJmaiJXtk/PkL4cdVX6J+tGiM187uT5E=
965+
gonum.org/v1/gonum v0.11.0/go.mod h1:fSG4YDCxxUZQJ7rKsQrj0gMOg00Il0Z96/qMA4bVQhA=
966966
google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
967967
google.golang.org/api v0.0.0-20181030000543-1d582fd0359e/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
968968
google.golang.org/api v0.1.0/go.mod h1:UGEZY7KEX120AnNLIHFMKIo4obdJhkp2tPbaPlQx13Y=

gateway/handler_ipns_record.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func (i *handler) serveIpnsRecord(ctx context.Context, w http.ResponseWriter, r
4949
return false
5050
}
5151

52-
record, err := ipns.UnmarshalIpnsEntry(rawRecord)
52+
record, err := ipns.UnmarshalRecord(rawRecord)
5353
if err != nil {
5454
i.webError(w, r, err, http.StatusInternalServerError)
5555
return false
@@ -69,9 +69,8 @@ func (i *handler) serveIpnsRecord(ctx context.Context, w http.ResponseWriter, r
6969
return false
7070
}
7171

72-
if record.Ttl != nil {
73-
seconds := int(time.Duration(*record.Ttl).Seconds())
74-
w.Header().Set("Cache-Control", fmt.Sprintf("public, max-age=%d", seconds))
72+
if ttl, err := record.TTL(); err == nil {
73+
w.Header().Set("Cache-Control", fmt.Sprintf("public, max-age=%d", int(ttl.Seconds())))
7574
} else {
7675
w.Header().Set("Last-Modified", time.Now().UTC().Format(http.TimeFormat))
7776
}

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ require (
3838
github.com/libp2p/go-buffer-pool v0.1.0
3939
github.com/libp2p/go-doh-resolver v0.4.0
4040
github.com/libp2p/go-libp2p v0.26.3
41-
github.com/libp2p/go-libp2p-kad-dht v0.21.1
41+
github.com/libp2p/go-libp2p-kad-dht v0.23.0
4242
github.com/libp2p/go-libp2p-record v0.2.0
4343
github.com/libp2p/go-libp2p-routing-helpers v0.7.0
4444
github.com/libp2p/go-libp2p-testing v0.12.0
@@ -112,7 +112,6 @@ require (
112112
github.com/ipfs/go-ipfs-ds-help v1.1.0 // indirect
113113
github.com/ipfs/go-ipfs-pq v0.0.3 // indirect
114114
github.com/ipfs/go-ipfs-util v0.0.2 // indirect
115-
github.com/ipfs/go-ipns v0.3.0 // indirect
116115
github.com/ipfs/go-log v1.0.5 // indirect
117116
github.com/ipfs/go-unixfs v0.4.5 // indirect
118117
github.com/ipld/go-car/v2 v2.9.1-0.20230325062757-fff0e4397a3d // indirect
@@ -167,6 +166,7 @@ require (
167166
golang.org/x/text v0.7.0 // indirect
168167
golang.org/x/tools v0.3.0 // indirect
169168
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
169+
gonum.org/v1/gonum v0.11.0 // indirect
170170
google.golang.org/appengine v1.6.7 // indirect
171171
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect
172172
google.golang.org/grpc v1.53.0 // indirect

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,6 @@ github.com/ipfs/go-ipld-format v0.5.0 h1:WyEle9K96MSrvr47zZHKKcDxJ/vlpET6PSiQsAF
325325
github.com/ipfs/go-ipld-format v0.5.0/go.mod h1:ImdZqJQaEouMjCvqCe0ORUS+uoBmf7Hf+EO/jh+nk3M=
326326
github.com/ipfs/go-ipld-legacy v0.2.1 h1:mDFtrBpmU7b//LzLSypVrXsD8QxkEWxu5qVxN99/+tk=
327327
github.com/ipfs/go-ipld-legacy v0.2.1/go.mod h1:782MOUghNzMO2DER0FlBR94mllfdCJCkTtDtPM51otM=
328-
github.com/ipfs/go-ipns v0.3.0 h1:ai791nTgVo+zTuq2bLvEGmWP1M0A6kGTXUsgv/Yq67A=
329-
github.com/ipfs/go-ipns v0.3.0/go.mod h1:3cLT2rbvgPZGkHJoPO1YMJeh6LtkxopCkKFcio/wE24=
330328
github.com/ipfs/go-log v0.0.1/go.mod h1:kL1d2/hzSpI0thNYjiKfjanbVNU+IIGA/WnNESY9leM=
331329
github.com/ipfs/go-log v1.0.5 h1:2dOuUCB1Z7uoczMWgAyDck5JLb72zHzrMnGnCNNbvY8=
332330
github.com/ipfs/go-log v1.0.5/go.mod h1:j0b8ZoR+7+R99LD9jZ6+AJsrzkPbSXbZfGakb5JPtIo=
@@ -413,8 +411,8 @@ github.com/libp2p/go-libp2p v0.26.3 h1:6g/psubqwdaBqNNoidbRKSTBEYgaOuKBhHl8Q5tO+
413411
github.com/libp2p/go-libp2p v0.26.3/go.mod h1:x75BN32YbwuY0Awm2Uix4d4KOz+/4piInkp4Wr3yOo8=
414412
github.com/libp2p/go-libp2p-asn-util v0.2.0 h1:rg3+Os8jbnO5DxkC7K/Utdi+DkY3q/d1/1q+8WeNAsw=
415413
github.com/libp2p/go-libp2p-asn-util v0.2.0/go.mod h1:WoaWxbHKBymSN41hWSq/lGKJEca7TNm58+gGJi2WsLI=
416-
github.com/libp2p/go-libp2p-kad-dht v0.21.1 h1:xpfp8/t9+X2ip1l8Umap1/UGNnJ3RHJgKGAEsnRAlTo=
417-
github.com/libp2p/go-libp2p-kad-dht v0.21.1/go.mod h1:Oy8wvbdjpB70eS5AaFaI68tOtrdo3KylTvXDjikxqFo=
414+
github.com/libp2p/go-libp2p-kad-dht v0.23.0 h1:sxE6LxLopp79eLeV695n7+c77V/Vn4AMF28AdM/XFqM=
415+
github.com/libp2p/go-libp2p-kad-dht v0.23.0/go.mod h1:oO5N308VT2msnQI6qi5M61wzPmJYg7Tr9e16m5n7uDU=
418416
github.com/libp2p/go-libp2p-kbucket v0.5.0 h1:g/7tVm8ACHDxH29BGrpsQlnNeu+6OF1A9bno/4/U1oA=
419417
github.com/libp2p/go-libp2p-kbucket v0.5.0/go.mod h1:zGzGCpQd78b5BNTDGHNDLaTt9aDK/A02xeZp9QeFC4U=
420418
github.com/libp2p/go-libp2p-record v0.2.0 h1:oiNUOCWno2BFuxt3my4i1frNrt7PerzB3queqa1NkQ0=
@@ -982,6 +980,8 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T
982980
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
983981
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk=
984982
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8=
983+
gonum.org/v1/gonum v0.11.0 h1:f1IJhK4Km5tBJmaiJXtk/PkL4cdVX6J+tGiM187uT5E=
984+
gonum.org/v1/gonum v0.11.0/go.mod h1:fSG4YDCxxUZQJ7rKsQrj0gMOg00Il0Z96/qMA4bVQhA=
985985
google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
986986
google.golang.org/api v0.0.0-20181030000543-1d582fd0359e/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
987987
google.golang.org/api v0.1.0/go.mod h1:UGEZY7KEX120AnNLIHFMKIo4obdJhkp2tPbaPlQx13Y=

ipns/README.md

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,48 @@
1-
## Usage
1+
# IPNS
22

3-
To create a new IPNS record:
3+
> A reference implementation of the IPNS Record and Verification specification.
4+
5+
## Documentation
6+
7+
- Go Documentation: https://pkg.go.dev/github.com/ipfs/boxo/ipns
8+
- IPNS Record Specification: https://specs.ipfs.tech/ipns/ipns-record/
9+
10+
## Example
11+
12+
Here's an example on how to create an IPNS Record:
413

514
```go
615
import (
16+
"crypto/rand"
717
"time"
818

9-
ipns "github.com/ipfs/boxo/ipns"
10-
crypto "github.com/libp2p/go-libp2p/core/crypto"
19+
"github.com/ipfs/boxo/ipns"
20+
"github.com/ipfs/boxo/path"
21+
ic "github.com/libp2p/go-libp2p/core/crypto"
1122
)
1223

13-
// Generate a private key to sign the IPNS record with. Most of the time,
14-
// however, you'll want to retrieve an already-existing key from IPFS using the
15-
// go-ipfs/core/coreapi CoreAPI.KeyAPI() interface.
16-
privateKey, publicKey, err := crypto.GenerateKeyPair(crypto.RSA, 2048)
17-
if err != nil {
18-
panic(err)
19-
}
24+
func main() {
25+
// Create a private key to sign your IPNS record. Most of the time, you
26+
// will want to retrieve an already-existing key from Kubo, for example.
27+
sk, _, err := ic.GenerateEd25519Key(rand.Reader)
28+
if err != nil {
29+
panic(err)
30+
}
2031

21-
// Create an IPNS record that expires in one hour and points to the IPFS address
22-
// /ipfs/Qme1knMqwt1hKZbc1BmQFmnm9f36nyQGwXxPGVpVJ9rMK5
23-
ipnsRecord, err := ipns.Create(privateKey, []byte("/ipfs/Qme1knMqwt1hKZbc1BmQFmnm9f36nyQGwXxPGVpVJ9rMK5"), 0, time.Now().Add(1*time.Hour))
24-
if err != nil {
25-
panic(err)
26-
}
27-
```
32+
// Define the path this record will point to.
33+
path := path.FromString("/ipfs/bafkqac3jobxhgidsn5rww4yk")
34+
35+
// Until when the record is valid.
36+
eol := time.Now().Add(time.Hour)
37+
38+
// For how long should caches cache the record.
39+
ttl := time.Second * 20
2840

29-
Once you have the record, you’ll need to use IPFS to *publish* it.
41+
record, err := ipns.NewRecord(sk, path, 1, eol, ttl)
42+
if err != nil {
43+
panic(err)
44+
}
3045

31-
There are several other major operations you can do with `go-ipns`. Check out the [API docs](https://pkg.go.dev/github.com/ipfs/boxo/ipns) or look at the tests in this repo for examples.
46+
// Now you have an IPNS Record.
47+
}
48+
```

ipns/errors.go

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,45 @@ import (
44
"errors"
55
)
66

7-
// ErrExpiredRecord should be returned when an ipns record is
8-
// invalid due to being too old
7+
// ErrExpiredRecord is returned when an IPNS Record is invalid due to being expired.
98
var ErrExpiredRecord = errors.New("expired record")
109

11-
// ErrUnrecognizedValidity is returned when an IpnsRecord has an
12-
// unknown validity type.
10+
// ErrUnrecognizedValidity is returned when an IPNS Record has an unknown validity type.
1311
var ErrUnrecognizedValidity = errors.New("unrecognized validity type")
1412

15-
// ErrInvalidPath should be returned when an ipns record path
16-
// is not in a valid format
13+
// ErrInvalidValidity is returned when an IPNS Record has a known validity type,
14+
// but the validity value is invalid.
15+
var ErrInvalidValidity = errors.New("invalid validity")
16+
17+
// ErrInvalidPath is returned when an IPNS Record has an invalid path.
1718
var ErrInvalidPath = errors.New("record path invalid")
1819

19-
// ErrSignature should be returned when an ipns record fails
20-
// signature verification
20+
// ErrInvalidPublicKey is returned when an IPNS Record has an invalid public key,
21+
var ErrInvalidPublicKey = errors.New("record public key invalid")
22+
23+
// ErrSignature is returned when an IPNS Record fails signature verification.
2124
var ErrSignature = errors.New("record signature verification failed")
2225

23-
// ErrKeyFormat should be returned when an ipns record key is
24-
// incorrectly formatted (not a peer ID)
26+
// ErrKeyFormat is returned when an IPNS Record key is incorrectly formatted.
2527
var ErrKeyFormat = errors.New("record key could not be parsed into peer ID")
2628

27-
// ErrPublicKeyNotFound should be returned when the public key
28-
// corresponding to the ipns record path cannot be retrieved
29-
// from the peer store
30-
var ErrPublicKeyNotFound = errors.New("public key not found in peer store")
29+
// ErrPublicKeyNotFound is returned when the public key is not found.
30+
var ErrPublicKeyNotFound = errors.New("public key not found")
3131

32-
// ErrPublicKeyMismatch should be returned when the public key embedded in the
33-
// record doesn't match the expected public key.
34-
var ErrPublicKeyMismatch = errors.New("public key in record did not match expected pubkey")
32+
// ErrPublicKeyMismatch is returned when the public key embedded in the IPNS
33+
// Record doesn't match the expected public key.
34+
var ErrPublicKeyMismatch = errors.New("public key in record did not match expected public key")
3535

36-
// ErrBadRecord should be returned when an ipns record cannot be unmarshalled
36+
// ErrBadRecord is returned when an IPNS Record cannot be unmarshalled.
3737
var ErrBadRecord = errors.New("record could not be unmarshalled")
3838

39-
// 10 KiB limit defined in https://github.com/ipfs/specs/pull/319
40-
const MaxRecordSize int = 10 << (10 * 1)
39+
// ErrDataMissing is returned when the record is missing the data field.
40+
var ErrDataMissing = errors.New("data field is missing from record")
4141

42-
// ErrRecordSize should be returned when an ipns record is
43-
// invalid due to being too big
42+
// ErrRecordSize is returned when an IPNS Record is too long.
4443
var ErrRecordSize = errors.New("record exceeds allowed size limit")
44+
45+
// MaxRecordSize is the IPNS Record [size limit].
46+
//
47+
// [size limit]: https://specs.ipfs.tech/ipns/ipns-record/#record-size-limit
48+
const MaxRecordSize int = 10 << (10 * 1)

ipns/examples/embed.go

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)