Skip to content

Commit 5ebb39f

Browse files
committed
feat: flip to v1+v2 by default
1 parent c5a71fa commit 5ebb39f

File tree

3 files changed

+20
-14
lines changed

3 files changed

+20
-14
lines changed

ipns/record.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,12 @@ func WithPublicKey(embedded bool) Option {
213213
}
214214

215215
func processOptions(opts ...Option) *options {
216-
options := &options{}
216+
options := &options{
217+
// TODO: produce V2-only records by default after IPIP-XXXX ships with Kubo
218+
// and Helia for at least 6 months.
219+
v1Compatibility: true,
220+
}
221+
217222
for _, opt := range opts {
218223
opt(options)
219224
}
@@ -223,7 +228,8 @@ func processOptions(opts ...Option) *options {
223228
// NewRecord creates a new IPNS [Record] and signs it with the given private key.
224229
// By default, we embed the public key for key types whose peer IDs do not encode
225230
// the public key, such as RSA and ECDSA key types. This can be changed with the
226-
// option [WithPublicKey].
231+
// option [WithPublicKey]. In addition, records are, by default created with V1
232+
// compatibility.
227233
func NewRecord(sk ic.PrivKey, value path.Path, seq uint64, eol time.Time, ttl time.Duration, opts ...Option) (*Record, error) {
228234
options := processOptions(opts...)
229235

ipns/record_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,34 +88,34 @@ func TestNewRecord(t *testing.T) {
8888
eol := time.Now().Add(time.Hour)
8989
ttl := time.Minute * 10
9090

91-
t.Run("V2 only record by default", func(t *testing.T) {
91+
t.Run("V1+V2 records by default", func(t *testing.T) {
9292
t.Parallel()
9393

9494
rec := mustNewRecord(t, sk, testPath, seq, eol, ttl)
95-
require.Empty(t, rec.pb.SignatureV1)
95+
require.NotEmpty(t, rec.pb.SignatureV1)
9696

9797
_, err := rec.PubKey()
9898
require.ErrorIs(t, err, ErrPublicKeyNotFound)
9999

100100
fieldsMatch(t, rec, testPath, seq, eol, ttl)
101-
require.Empty(t, rec.pb.GetValue())
102-
require.Empty(t, rec.pb.GetSequence())
103-
require.Empty(t, rec.pb.GetValidity())
104-
require.Empty(t, rec.pb.GetValidityType())
105-
require.Empty(t, rec.pb.GetTtl())
101+
fieldsMatchV1(t, rec, testPath, seq, eol, ttl)
106102
})
107103

108-
t.Run("V1+V2 with option", func(t *testing.T) {
104+
t.Run("V2 records with option", func(t *testing.T) {
109105
t.Parallel()
110106

111-
rec := mustNewRecord(t, sk, testPath, seq, eol, ttl, WithV1Compatibility(true))
112-
require.NotEmpty(t, rec.pb.SignatureV1)
107+
rec := mustNewRecord(t, sk, testPath, seq, eol, ttl, WithV1Compatibility(false))
108+
require.Empty(t, rec.pb.SignatureV1)
113109

114110
_, err := rec.PubKey()
115111
require.ErrorIs(t, err, ErrPublicKeyNotFound)
116112

117113
fieldsMatch(t, rec, testPath, seq, eol, ttl)
118-
fieldsMatchV1(t, rec, testPath, seq, eol, ttl)
114+
require.Empty(t, rec.pb.GetValue())
115+
require.Empty(t, rec.pb.GetSequence())
116+
require.Empty(t, rec.pb.GetValidity())
117+
require.Empty(t, rec.pb.GetValidityType())
118+
require.Empty(t, rec.pb.GetTtl())
119119
})
120120

121121
t.Run("Public key embedded by default for RSA and ECDSA keys", func(t *testing.T) {

namesys/publisher.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ func (p *IpnsPublisher) updateRecord(ctx context.Context, k crypto.PrivKey, valu
178178
opts := opts.ProcessPublishOptions(options)
179179

180180
// Create record
181-
r, err := ipns.NewRecord(k, value, seqno, opts.EOL, opts.TTL, ipns.WithV1Compatibility(opts.CompatibleWithV1))
181+
r, err := ipns.NewRecord(k, value, seqno, opts.EOL, opts.TTL)
182182
if err != nil {
183183
return nil, err
184184
}

0 commit comments

Comments
 (0)