diff --git a/docs/data_format_changes/i2696-support-encryption-for-counters.md b/docs/data_format_changes/i2696-support-encryption-for-counters.md new file mode 100644 index 0000000000..dd53e57898 --- /dev/null +++ b/docs/data_format_changes/i2696-support-encryption-for-counters.md @@ -0,0 +1,2 @@ +# Support encryption for counters +We changed the data format of counters from int64 and float64 to bytes to support encryption. This changes the generated CIDs for counters. \ No newline at end of file diff --git a/internal/core/crdt/counter.go b/internal/core/crdt/counter.go index 76bd99fa51..4aa9a40793 100644 --- a/internal/core/crdt/counter.go +++ b/internal/core/crdt/counter.go @@ -187,6 +187,13 @@ func (c Counter) incrementValue( return c.setPriority(ctx, c.key, priority) } +func (c Counter) CType() client.CType { + if c.AllowDecrement { + return client.PN_COUNTER + } + return client.P_COUNTER +} + func validateAndIncrement[T Incrementable]( ctx context.Context, store datastore.DSReaderWriter, @@ -212,13 +219,6 @@ func validateAndIncrement[T Incrementable]( return cbor.Marshal(newValue) } -func (c Counter) CType() client.CType { - if c.AllowDecrement { - return client.PN_COUNTER - } - return client.P_COUNTER -} - func getCurrentValue[T Incrementable]( ctx context.Context, store datastore.DSReaderWriter,