diff --git a/cmd/frostfs-node/tree.go b/cmd/frostfs-node/tree.go index f188e2fbc..320e75c1a 100644 --- a/cmd/frostfs-node/tree.go +++ b/cmd/frostfs-node/tree.go @@ -58,6 +58,7 @@ func initTreeService(c *cfg) { tree.WithPrivateKey(&c.key.PrivateKey), tree.WithLogger(c.log), tree.WithStorage(c.cfgObject.cfgLocalStorage.localStorage), + tree.WithBurnedStorage(c.cfgObject.cfgLocalStorage.localStorage), tree.WithContainerCacheSize(treeConfig.CacheSize()), tree.WithReplicationTimeout(treeConfig.ReplicationTimeout()), tree.WithReplicationChannelCapacity(treeConfig.ReplicationChannelCapacity()), diff --git a/go.mod b/go.mod index aefe2889a..f130e592e 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.22 require ( code.gitea.io/sdk/gitea v0.17.1 - git.frostfs.info/TrueCloudLab/frostfs-api-go/v2 v2.16.1-0.20241007120543-29c522d5d8a3 + git.frostfs.info/TrueCloudLab/frostfs-api-go/v2 v2.16.1-0.20241011114054-f0fc40e116d1 git.frostfs.info/TrueCloudLab/frostfs-contract v0.20.0 git.frostfs.info/TrueCloudLab/frostfs-crypto v0.6.0 git.frostfs.info/TrueCloudLab/frostfs-locode-db v0.4.1-0.20240710074952-65761deb5c0d diff --git a/go.sum b/go.sum index 4d44079d4..ac9211f80 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,8 @@ code.gitea.io/sdk/gitea v0.17.1 h1:3jCPOG2ojbl8AcfaUCRYLT5MUcBMFwS0OSK2mA5Zok8= code.gitea.io/sdk/gitea v0.17.1/go.mod h1:aCnBqhHpoEWA180gMbaCtdX9Pl6BWBAuuP2miadoTNM= git.frostfs.info/TrueCloudLab/frostfs-api-go/v2 v2.16.1-0.20241007120543-29c522d5d8a3 h1:6QXNnfBgYx81UZsBdpPnQY+ZMSKGFbFc29wV7DJ/UG4= git.frostfs.info/TrueCloudLab/frostfs-api-go/v2 v2.16.1-0.20241007120543-29c522d5d8a3/go.mod h1:F5GS7hRb62PUy5sTYDC4ajVdeffoAfjHSSHTKUJEaYU= +git.frostfs.info/TrueCloudLab/frostfs-api-go/v2 v2.16.1-0.20241011114054-f0fc40e116d1 h1:ivcdxQeQDnx4srF2ezoaeVlF0FAycSAztwfIUJnUI4s= +git.frostfs.info/TrueCloudLab/frostfs-api-go/v2 v2.16.1-0.20241011114054-f0fc40e116d1/go.mod h1:F5GS7hRb62PUy5sTYDC4ajVdeffoAfjHSSHTKUJEaYU= git.frostfs.info/TrueCloudLab/frostfs-contract v0.20.0 h1:8Z5iPhieCrbcdhxBuY/Bajh6V5fki7Whh0b4S2zYJYU= git.frostfs.info/TrueCloudLab/frostfs-contract v0.20.0/go.mod h1:Y2Xorxc8SBO4phoek7n3XxaPZz5rIrFgDsU4TOjmlGA= git.frostfs.info/TrueCloudLab/frostfs-crypto v0.6.0 h1:FxqFDhQYYgpe41qsIHVOcdzSVCB8JNSfPG7Uk4r2oSk= diff --git a/pkg/local_object_storage/engine/tree.go b/pkg/local_object_storage/engine/tree.go index 39122628f..c85d01a79 100644 --- a/pkg/local_object_storage/engine/tree.go +++ b/pkg/local_object_storage/engine/tree.go @@ -9,6 +9,7 @@ import ( "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard" tracingPkg "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/tracing" "git.frostfs.info/TrueCloudLab/frostfs-observability/tracing" + cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id" cidSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" @@ -440,3 +441,32 @@ func (e *StorageEngine) getTreeShard(ctx context.Context, cid cidSDK.ID, treeID return 0, lst, pilorama.ErrTreeNotFound } + +func (e *StorageEngine) Add(d pilorama.CIDDescriptor, treeID string, key []byte, meta pilorama.Meta) (pilorama.Operation, error) { + lst := e.sortShards(d.CID) + return lst[0].Add(d, treeID, key, meta) +} +func (e *StorageEngine) Remove(d pilorama.CIDDescriptor, treeID string, key []byte) (pilorama.Operation, error) { + lst := e.sortShards(d.CID) + return lst[0].Remove(d, treeID, key) +} +func (e *StorageEngine) Apply(cnr cid.ID, treeID string, op pilorama.Operation) error { + lst := e.sortShards(cnr) + return lst[0].Apply(cnr, treeID, op) +} +func (e *StorageEngine) GetLatestByPrefix(cnr cid.ID, treeID string, key []byte) (pilorama.MetaVersion, error) { + lst := e.sortShards(cnr) + return lst[0].GetLatestByPrefix(cnr, treeID, key) +} +func (e *StorageEngine) GetLatest(cnr cid.ID, treeID string, key []byte) (pilorama.Meta, error) { + lst := e.sortShards(cnr) + return lst[0].GetLatest(cnr, treeID, key) +} +func (e *StorageEngine) ListByPrefix(cnr cid.ID, treeID string, key []byte) ([]pilorama.MetaVersion, error) { + lst := e.sortShards(cnr) + return lst[0].ListByPrefix(cnr, treeID, key) +} +func (e *StorageEngine) ListAll(cnr cid.ID, treeID string, param pilorama.ListParam) ([][]byte, error) { + lst := e.sortShards(cnr) + return lst[0].ListAll(cnr, treeID, param) +} diff --git a/pkg/local_object_storage/pilorama/new_pilorama.go b/pkg/local_object_storage/pilorama/new_pilorama.go new file mode 100644 index 000000000..f5c26db84 --- /dev/null +++ b/pkg/local_object_storage/pilorama/new_pilorama.go @@ -0,0 +1,420 @@ +package pilorama + +import ( + "bytes" + "context" + "encoding/binary" + "errors" + "fmt" + "os" + "path/filepath" + "sync" + "time" + + "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/metaerr" + "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode" + "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util" + cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id" + "github.com/nspcc-dev/neo-go/pkg/io" + "go.etcd.io/bbolt" +) + +type BurnedForest interface { + SetMode(m mode.Mode) error + Open(_ context.Context, mode mode.Mode) error + Init() error + Close() error + BurnedFully +} + +type BurnedFully interface { + Add(d CIDDescriptor, treeID string, key []byte, meta Meta) (Operation, error) + Remove(d CIDDescriptor, treeID string, key []byte) (Operation, error) + Apply(cnr cid.ID, treeID string, op Operation) error + GetLatestByPrefix(cnr cid.ID, treeID string, prefix []byte) (MetaVersion, error) + GetLatest(cnr cid.ID, treeID string, key []byte) (Meta, error) + ListByPrefix(cnr cid.ID, treeID string, key []byte) ([]MetaVersion, error) + ListAll(cnr cid.ID, treeID string, param ListParam) ([][]byte, error) +} + +type newPilorama struct { + db *bbolt.DB + + modeMtx sync.RWMutex + mode mode.Mode + + cfg +} + +var ErrValueNotFound = metaerr.New("value not found") + +type Kind byte + +const ( + OpInsert = iota + OpDelete = iota +) + +type Operation struct { + Kind Kind + Key []byte + Meta Meta +} + +func NewPilorama(opts ...Option) *newPilorama { + p := &newPilorama{ + cfg: cfg{ + perm: os.ModePerm, + maxBatchDelay: bbolt.DefaultMaxBatchDelay, + maxBatchSize: bbolt.DefaultMaxBatchSize, + openFile: os.OpenFile, + metrics: &noopMetrics{}, + }, + } + for i := range opts { + opts[i](&p.cfg) + } + + // p.cfg.path = filepath.Join(p.cfg.path, ".new") + return p +} + +func (p *newPilorama) SetMode(m mode.Mode) error { + p.modeMtx.Lock() + defer p.modeMtx.Unlock() + + if p.mode == m { + return nil + } + + err := p.Close() + if err == nil && !m.NoMetabase() { + if err = p.openBolt(m); err == nil { + err = p.Init() + } + } + if err != nil { + return fmt.Errorf("can't set pilorama mode (old=%s, new=%s): %w", p.mode, m, err) + } + + p.mode = m + p.metrics.SetMode(mode.ConvertToComponentMode(m)) + return nil +} + +func (p *newPilorama) Open(_ context.Context, mode mode.Mode) error { + p.modeMtx.Lock() + defer p.modeMtx.Unlock() + p.mode = mode + if mode.NoMetabase() { + return nil + } + return p.openBolt(mode) +} + +func (p *newPilorama) openBolt(m mode.Mode) error { + readOnly := m.ReadOnly() + err := util.MkdirAllX(filepath.Dir(p.path), p.perm) + if err != nil { + return metaerr.Wrap(fmt.Errorf("can't create dir %s for the pilorama: %w", p.path, err)) + } + + opts := *bbolt.DefaultOptions + opts.ReadOnly = readOnly + opts.NoSync = p.noSync + opts.Timeout = 100 * time.Millisecond + opts.OpenFile = p.openFile + + p.db, err = bbolt.Open(p.path, p.perm, &opts) + if err != nil { + return metaerr.Wrap(fmt.Errorf("can't open the pilorama DB: %w", err)) + } + + p.db.MaxBatchSize = p.maxBatchSize + p.db.MaxBatchDelay = p.maxBatchDelay + p.metrics.SetMode(mode.ConvertToComponentMode(m)) + return nil +} + +func (p *newPilorama) Init() error { + if p.mode.NoMetabase() || p.db.IsReadOnly() { + return nil + } + return nil +} + +func (p *newPilorama) Close() error { + var err error + if p.db != nil { + err = p.db.Close() + } + if err == nil { + p.metrics.Close() + } + return err +} + +var ErrInvalidOperation = errors.New("invalid operation") + +func (op *Operation) Bytes() []byte { + w := io.NewBufBinWriter() + w.WriteB(byte(op.Kind)) + w.WriteVarBytes(op.Key) + op.Meta.EncodeBinary(w.BinWriter) + return w.Bytes() +} + +func (op *Operation) FromBytes(data []byte) error { + r := io.NewBinReaderFromBuf(data) + op.Kind = Kind(r.ReadB()) + op.Key = r.ReadVarBytes() + op.Meta.DecodeBinary(r) + return r.Err +} + +func (p *newPilorama) Add(d CIDDescriptor, treeID string, key []byte, meta Meta) (Operation, error) { + op := Operation{ + Kind: OpInsert, + Key: key, + Meta: meta, + } + + err := p.db.Batch(func(tx *bbolt.Tx) error { + blog, btree, err := p.getTreeBuckets(tx, d.CID, treeID) + if err != nil { + return err + } + + ts := p.getLatestTimestamp(blog, d.Position, d.Size) + op.Meta.Time = ts + + return p.apply(blog, btree, op) + }) + return op, err +} + +func (p *newPilorama) Remove(d CIDDescriptor, treeID string, key []byte) (Operation, error) { + op := Operation{ + Kind: OpDelete, + Key: key, + } + + err := p.db.Batch(func(tx *bbolt.Tx) error { + blog, btree, err := p.getTreeBuckets(tx, d.CID, treeID) + if err != nil { + return err + } + + ts := p.getLatestTimestamp(blog, d.Position, d.Size) + op.Meta.Time = ts + + return p.apply(blog, btree, op) + }) + return op, err +} + +func (p *newPilorama) getLatestTimestamp(b *bbolt.Bucket, pos, size int) uint64 { + var ts uint64 + + c := b.Cursor() + key, _ := c.Last() + if len(key) != 0 { + ts = binary.BigEndian.Uint64(key) + } + return nextTimestamp(ts, uint64(pos), uint64(size)) +} + +func (p *newPilorama) Apply(cnr cid.ID, treeID string, op Operation) error { + return p.db.Batch(func(tx *bbolt.Tx) error { + blog, btree, err := p.getTreeBuckets(tx, cnr, treeID) + if err != nil { + return err + } + return p.apply(blog, btree, op) + }) +} + +func (p *newPilorama) apply(blog, btree *bbolt.Bucket, op Operation) error { + ts := make([]byte, 8) + binary.BigEndian.PutUint64(ts, op.Meta.Time) + if err := blog.Put(ts, op.Bytes()); err != nil { + return err + } + + current := btree.Get(op.Key) + if len(current) == 8 && op.Meta.Time <= binary.BigEndian.Uint64(current) { + return nil + } + return btree.Put(op.Key, ts) +} + +func (p *newPilorama) getTreeBuckets(tx *bbolt.Tx, cnr cid.ID, treeID string) (*bbolt.Bucket, *bbolt.Bucket, error) { + namelog, nametree := burnedNames(cnr, treeID) + + blog := tx.Bucket(namelog) + if blog == nil { + var err error + blog, err = tx.CreateBucketIfNotExists(namelog) + if err != nil { + return nil, nil, err + } + } + + btree := tx.Bucket(nametree) + if btree == nil { + var err error + btree, err = tx.CreateBucketIfNotExists(nametree) + if err != nil { + return nil, nil, err + } + } + return blog, btree, nil +} + +func burnedName(cnr cid.ID, treeID string, typ byte) []byte { + b := make([]byte, 32+len(treeID)+1) + cnr.Encode(b) + copy(b[32:], treeID) + b[len(b)-1] = typ + return b +} + +func burnedNames(cnr cid.ID, treeID string) ([]byte, []byte) { + blog := burnedName(cnr, treeID, 'L') + btree := burnedName(cnr, treeID, 'T') + return blog, btree +} + +func (p *newPilorama) GetLatestByPrefix(cnr cid.ID, treeID string, prefix []byte) (MetaVersion, error) { + // TODO(@fyrchik): can be more optimal + ms, err := p.ListByPrefix(cnr, treeID, prefix) + if err != nil { + return MetaVersion{}, err + } + var maxIndex int + for i := 1; i < len(ms); i++ { + if ms[i].Meta.Time > ms[maxIndex].Meta.Time { + maxIndex = i + } + } + return ms[maxIndex], nil +} + +func (p *newPilorama) GetLatest(cnr cid.ID, treeID string, key []byte) (Meta, error) { + var rawMeta []byte + + nlog, ntree := burnedNames(cnr, treeID) + err := p.db.View(func(tx *bbolt.Tx) error { + blog := tx.Bucket(nlog) + btree := tx.Bucket(ntree) + if blog == nil || btree == nil { + return ErrTreeNotFound + } + + ts := btree.Get(key) + if ts == nil { + return ErrValueNotFound + } + rawMeta = bytes.Clone(blog.Get(ts)) + return nil + }) + if err != nil { + return Meta{}, err + } + + var m Meta + if err := m.FromBytes(rawMeta); err != nil { + return Meta{}, err + } + return m, nil +} + +type MetaVersion struct { + Key []byte + Meta Meta +} + +func (p *newPilorama) ListByPrefix(cnr cid.ID, treeID string, prefix []byte) ([]MetaVersion, error) { + var rawMetas [][]byte + + nlog, ntree := burnedNames(cnr, treeID) + err := p.db.View(func(tx *bbolt.Tx) error { + blog := tx.Bucket(nlog) + btree := tx.Bucket(ntree) + if blog == nil || btree == nil { + return ErrTreeNotFound + } + + c := btree.Cursor() + for k, v := c.Seek(prefix); k != nil && bytes.HasPrefix(k, prefix); k, v = c.Next() { + rawMetas = append(rawMetas, bytes.Clone(blog.Get(v))) + } + return nil + }) + if err != nil { + return nil, err + } + + res := make([]MetaVersion, 0, len(rawMetas)) + for i := range rawMetas { + var op Operation + if err := op.FromBytes(rawMetas[i]); err != nil { + return nil, err + } + res = append(res, MetaVersion{ + Key: op.Key, + Meta: op.Meta, + }) + } + return res, err +} + +type ListParam struct { + Inclusive bool + Start []byte // Non-inclusive + Count int +} + +func (p *newPilorama) ListAll(cnr cid.ID, treeID string, param ListParam) ([][]byte, error) { + var keys [][]byte + + _, ntree := burnedNames(cnr, treeID) + exact := make([]byte, len(param.Start)) + copy(exact, param.Start) + + err := p.db.View(func(tx *bbolt.Tx) error { + btree := tx.Bucket(ntree) + if btree == nil { + return ErrTreeNotFound + } + + c := btree.Cursor() + k, _ := c.Seek(exact) + if !param.Inclusive && bytes.Equal(k, exact) { + k, _ = c.Next() + } + + for ; k != nil; k, _ = c.Next() { + keys = append(keys, bytes.Clone(k)) + if len(keys) == param.Count { + return nil + } + } + return nil + }) + if err != nil { + return nil, err + } + return keys, nil +} + +func makeFilenameKey(key []byte, version []byte) []byte { + filenameKey := make([]byte, len(key)+len(version)+1) + n := copy(filenameKey, key) + + filenameKey[n] = 0 + n++ + + copy(filenameKey[n:], version) + return filenameKey +} diff --git a/pkg/local_object_storage/pilorama/new_pilorama_test.go b/pkg/local_object_storage/pilorama/new_pilorama_test.go new file mode 100644 index 000000000..ed0f6d8ef --- /dev/null +++ b/pkg/local_object_storage/pilorama/new_pilorama_test.go @@ -0,0 +1,151 @@ +package pilorama + +import ( + "context" + mrand "math/rand" + "path/filepath" + "strconv" + "testing" + "time" + + "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode" + cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id" + cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test" + "github.com/stretchr/testify/require" +) + +func newTestNewPilorama(t testing.TB, opts ...Option) BurnedForest { + f := NewPilorama( + append([]Option{ + WithPath(filepath.Join(t.TempDir(), "test.db")), + WithMaxBatchSize(1), + }, opts...)...) + require.NoError(t, f.Open(context.Background(), mode.ReadWrite)) + require.NoError(t, f.Init()) + return f +} + +func BenchmarkBurnedForestApply(b *testing.B) { + for _, bs := range batchSizes { + b.Run("batchsize="+strconv.Itoa(bs), func(b *testing.B) { + r := mrand.New(mrand.NewSource(time.Now().Unix())) + s := newTestNewPilorama(b, WithMaxBatchSize(bs)) + defer func() { require.NoError(b, s.Close()) }() + + benchmarkApplyBurned(b, s, func(opCount int) []Operation { + ops := make([]Operation, opCount) + for i := range ops { + ops[i] = randomOp(b, r) + ops[i].Meta.Time = Timestamp(i) + } + return ops + }) + }) + } +} + +func benchmarkApplyBurned(b *testing.B, s BurnedForest, genFunc func(int) []Operation) { + ops := genFunc(b.N) + cid := cidtest.ID() + treeID := "version" + ch := make(chan int, b.N) + for i := 0; i < b.N; i++ { + ch <- i + } + + b.ResetTimer() + b.ReportAllocs() + b.SetParallelism(10) + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + if err := s.Apply(cid, treeID, ops[<-ch]); err != nil { + b.Fatalf("error in `Apply`: %v", err) + } + } + }) +} + +func TestBurnedForestApplyRandom(t *testing.T) { + r := mrand.New(mrand.NewSource(42)) + + const ( + nodeCount = 5 + opCount = 20 + ) + + ops := prepareRandomBurnedForest(t, nodeCount, opCount) + + cnr := cidtest.ID() + treeID := "version" + + expected := newTestNewPilorama(t, WithNoSync(true)) + defer func() { require.NoError(t, expected.Close()) }() + + for i := range ops { + require.NoError(t, expected.Apply(cnr, treeID, ops[i])) + } + + const iterCount = 200 + for i := 0; i < iterCount; i++ { + // Shuffle random operations, leave initialization in place. + r.Shuffle(len(ops), func(i, j int) { ops[i], ops[j] = ops[j], ops[i] }) + + actual := newTestNewPilorama(t, WithNoSync(true)) + for i := range ops { + require.NoError(t, actual.Apply(cnr, treeID, ops[i])) + } + compareBurnedForests(t, expected, actual, cnr, treeID, nodeCount) + require.NoError(t, actual.Close()) + } +} + +func compareBurnedForests(t testing.TB, expected, actual BurnedForest, cnr cid.ID, treeID string, nodeCount int) { + for i := 0; i < nodeCount; i++ { + expectedMetas, err := expected.ListByPrefix(cnr, treeID, []byte(strconv.Itoa(i))) + require.NoError(t, err) + actualMetas, err := actual.ListByPrefix(cnr, treeID, []byte(strconv.Itoa(i))) + require.NoError(t, err) + + require.Equal(t, expectedMetas, actualMetas) + + r1, err := expected.ListAll(cnr, treeID, ListParam{Start: nil, Count: 100}) + require.NoError(t, err) + r2, err := actual.ListAll(cnr, treeID, ListParam{Start: nil, Count: 100}) + require.NoError(t, err) + require.Equal(t, r1, r2) + } +} + +func prepareRandomBurnedForest(t testing.TB, nodeCount, opCount int) []Operation { + r := mrand.New(mrand.NewSource(42)) + ops := make([]Operation, nodeCount+opCount) + for i := 0; i < nodeCount; i++ { + ops[i] = randomOp(t, r) + ops[i].Key = []byte(strconv.Itoa(i)) + } + + for i := nodeCount; i < len(ops); i++ { + ops[i] = randomOp(t, r) + ops[i].Key = ops[r.Intn(nodeCount)].Key + } + + return ops +} + +func randomOp(t testing.TB, r *mrand.Rand) Operation { + kv := make([][]byte, 5) + for i := range kv { + kv[i] = make([]byte, r.Intn(10)+1) + r.Read(kv[i]) + } + return Operation{ + Key: []byte(strconv.Itoa(r.Int())), + Meta: Meta{ + Time: Timestamp(r.Uint64()), + Items: []KeyValue{ + {Key: string(kv[0]), Value: kv[1]}, + {Key: string(kv[2]), Value: kv[3]}, + }, + }, + } +} diff --git a/pkg/local_object_storage/pilorama/router.go b/pkg/local_object_storage/pilorama/router.go new file mode 100644 index 000000000..2080c164f --- /dev/null +++ b/pkg/local_object_storage/pilorama/router.go @@ -0,0 +1,326 @@ +package pilorama + +import ( + "encoding/binary" + "errors" + "fmt" + + cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id" + "go.etcd.io/bbolt" +) + +const ( + systemTreeID = "system" + versionTreeID = "version" + + versionAttribute = "OID" + isUnversionedAttribute = "IsUnversioned" + nullVersionValue = "null" + versionTagAttribute = "IsTag" + versionLockAttribute = "IsLock" + + multipartInfoNumberAttribute = "Number" + multipartInfoUploadIDAttribute = "UploadId" + multipartInfoNewKeySuffix = "Info" + + systemSettingsKey = "bucket-settings" + systemCorsKey = "bucket-cors" + systemTaggingKey = "bucket-tagging" + systemLifecycleKey = "bucket-lifecycle" +) + +type keyValue struct { + timestamp uint64 + key []byte + value []byte +} + +type migrationContext struct { + treeID string + blog *bbolt.Bucket + btree *bbolt.Bucket +} + +func (t *boltForest) migrateVersionAndSystem(tx *bbolt.Tx, cnr cid.ID) error { + if err := t.iterateFull(tx, cnr, versionTreeID); err != nil { + return err + } + if err := t.iterateFull(tx, cnr, systemTreeID); err != nil { + return err + } + return nil +} + +func (t *boltForest) iterateFull(tx *bbolt.Tx, cnr cid.ID, treeID string) error { + switch treeID { + case versionTreeID, systemTreeID: + default: + return fmt.Errorf("unexpected tree ID: '%s'", treeID) + } + _, oldTree, err := t.getTreeBuckets(tx, bucketName(cnr, treeID)) + if err != nil { + return err + } + + logName, treeName := burnedNames(cnr, treeID) + blog, err := tx.CreateBucketIfNotExists(logName) + if err != nil { + return err + } + btree, err := tx.CreateBucketIfNotExists(treeName) + if err != nil { + return err + } + ctx := migrationContext{ + treeID: treeID, + blog: blog, + btree: btree, + } + + var filePath []string + + stack := [][]Node{{RootID}} + for len(stack) != 0 { + if len(stack[len(stack)-1]) == 0 { + stack = stack[:len(stack)-1] + if len(filePath) != 0 { + filePath = filePath[:len(filePath)-1] + } + continue + } + + var next Node + next, stack[len(stack)-1] = stack[len(stack)-1][0], stack[len(stack)-1][1:] + + _, _, rawMeta, _ := t.getState(oldTree, stateKey(make([]byte, 9), next)) + var m Meta + if err := m.FromBytes(rawMeta); err != nil { + return err + } + + fileName := m.GetAttr(AttributeFilename) + filePath = append(filePath, string(fileName)) + descend, err := t.duplicateOnUpdate(ctx, oldTree, next, filePath) + if err != nil { + return err + } + var childIDs []Node + if descend { + key := make([]byte, 9) + key[0] = 'c' + binary.LittleEndian.PutUint64(key[1:], next) + + c := oldTree.Cursor() + for k, _ := c.Seek(key); len(k) == childrenKeySize && binary.LittleEndian.Uint64(k[1:]) == next; k, _ = c.Next() { + childID := binary.LittleEndian.Uint64(k[9:]) + childIDs = append(childIDs, childID) + } + } + + stack = append(stack, childIDs) + } + return nil +} + +func (t *boltForest) duplicateOnUpdate(ctx migrationContext, oldTree *bbolt.Bucket, nodeID Node, filePath []string) (bool, error) { + fmt.Println("duplicateOnUpdate(", filePath, ")") + + const () + + var kvs []keyValue + var err error + switch ctx.treeID { + case systemTreeID: + kvs, err = t.systemRouter(oldTree, nodeID) + case versionTreeID: + kvs, err = t.versionRouter(oldTree, nodeID) + default: + return false, fmt.Errorf("unexpected tree ID: '%s'", ctx.treeID) + } + if err != nil { + return false, err + } + + for _, kv := range kvs { + ts := make([]byte, 8) + binary.BigEndian.PutUint64(ts, kv.timestamp) + if err := ctx.blog.Put(ts, kv.value); err != nil { + return false, err + } + + current := ctx.btree.Get(kv.key) + if len(current) == 8 && kv.timestamp <= binary.BigEndian.Uint64(current) { + continue + } + if err := ctx.btree.Put(kv.key, ts); err != nil { + return false, err + } + } + return len(kvs) == 0, nil +} + +func (t *boltForest) buildPathInreverse(bTree *bbolt.Bucket, nodeID Node) (bool, Timestamp, Meta, []byte, error) { + // 1. Get filepath to the current node. + var components [][]byte + var size int + + parent, ts, rawMeta, _ := t.getState(bTree, stateKey(make([]byte, 9), nodeID)) + var meta Meta + if err := meta.FromBytes(rawMeta); err != nil { + return false, 0, Meta{}, nil, err + } + if len(meta.Items) <= 1 { + return false, 0, Meta{}, nil, nil + } + + for { + var m Meta + if err := m.FromBytes(rawMeta); err != nil { + return false, 0, Meta{}, nil, err + } + + fname := m.GetAttr(AttributeFilename) + if fname == nil { + return false, 0, Meta{}, nil, fmt.Errorf("empty '%s' was found in ancestors", AttributeFilename) + } + + size += len(fname) + components = append(components, fname) + + if parent == RootID { + break + } + nodeID = parent + parent, _, rawMeta, _ = t.getState(bTree, stateKey(make([]byte, 9), nodeID)) + } + + var prefix []byte + for i := len(components) - 1; i >= 0; i-- { + prefix = append(prefix, components[i]...) + if i > 0 { + prefix = append(prefix, '/') + } + } + return true, ts, meta, prefix, nil +} + +func (t *boltForest) systemRouter(bTree *bbolt.Bucket, nodeID Node) ([]keyValue, error) { + // 1. Get filepath to the current node. + isExternalNode, ts, systemMeta, prefix, err := t.buildPathInreverse(bTree, nodeID) + if err != nil || !isExternalNode { + return nil, err + } + + uploadID := systemMeta.GetAttr(multipartInfoUploadIDAttribute) + if uploadID == nil { + attr := systemMeta.GetAttr(AttributeFilename) + switch fname := string(systemMeta.GetAttr(AttributeFilename)); fname { + case systemSettingsKey, systemCorsKey, systemTaggingKey, systemLifecycleKey: + return []keyValue{{ + timestamp: ts, + key: attr, + value: systemMeta.Bytes(), + }}, nil + default: + return nil, fmt.Errorf("neither %s nor %s ('%s') are found in system tree", multipartInfoUploadIDAttribute, AttributeFilename, fname) + } + } + + // The key is '\u0000\u0000Info'. + prefix = append(prefix, 0) + prefix = append(prefix, uploadID...) + prefix = append(prefix, 0) + prefix = prefix[:len(prefix):len(prefix)] + + kvs := []keyValue{{ + timestamp: ts, + key: append(prefix, multipartInfoNewKeySuffix...), + value: systemMeta.Bytes(), + }} + + t.forEachChild(bTree, nodeID, func(info childInfo) error { + number := info.meta.GetAttr(multipartInfoNumberAttribute) + if len(number) == 0 { + return errors.New("empty 'Number' attribute in multipart info") + } + + // The key is '\u0000\u0000', where `` is the `Number` attribute. + newKey := make([]byte, len(prefix)+len(number)) + copy(newKey, prefix) + copy(newKey[len(prefix):], number) + + kvs = append(kvs, keyValue{ + timestamp: info.time, + key: newKey, + value: info.rawMeta, + }) + return nil + }) + + return kvs, nil +} + +func (t *boltForest) versionRouter(bTree *bbolt.Bucket, nodeID Node) ([]keyValue, error) { + // 1. Get filepath to the current node. + isExternalNode, ts, versionMeta, prefix, err := t.buildPathInreverse(bTree, nodeID) + if err != nil || !isExternalNode { + return nil, err + } + + version := versionMeta.GetAttr(versionAttribute) + if version == nil { + if len(versionMeta.GetAttr(isUnversionedAttribute)) == 0 { + return nil, fmt.Errorf("both '%s' and '%s' attributes are empty", versionAttribute, isUnversionedAttribute) + } + version = []byte(nullVersionValue) + } + + t.forEachChild(bTree, nodeID, func(info childInfo) error { + if info.meta.GetAttr(versionTagAttribute) != nil || info.meta.GetAttr(versionLockAttribute) != nil { + versionMeta.Items = append(versionMeta.Items, info.meta.Items...) + } + return nil + }) + + // The key is '\u0000'. + prefix = append(prefix, 0) + prefix = append(prefix, version...) + prefix = prefix[:len(prefix):len(prefix)] + return []keyValue{{ + timestamp: ts, + key: prefix, + value: versionMeta.Bytes(), + }}, nil +} + +type childInfo struct { + time Timestamp + meta Meta + rawMeta []byte +} + +func (t *boltForest) forEachChild(bTree *bbolt.Bucket, nodeID Node, f func(childInfo) error) error { + key := make([]byte, 9) + key[0] = 'c' + binary.LittleEndian.PutUint64(key[1:], nodeID) + + c := bTree.Cursor() + + for k, _ := c.Seek(key); len(k) == childrenKeySize && binary.LittleEndian.Uint64(k[1:]) == nodeID; k, _ = c.Next() { + childID := binary.LittleEndian.Uint64(k[9:]) + + _, ts, rawMeta, inTree := t.getState(bTree, stateKey(make([]byte, 9), childID)) + if !inTree { + continue + } + var m Meta + if err := m.FromBytes(rawMeta); err != nil { + return err + } + + if err := f(childInfo{time: ts, rawMeta: rawMeta, meta: m}); err != nil { + return err + } + } + return nil +} diff --git a/pkg/local_object_storage/pilorama/upgrade_test.go b/pkg/local_object_storage/pilorama/upgrade_test.go new file mode 100644 index 000000000..5651be77c --- /dev/null +++ b/pkg/local_object_storage/pilorama/upgrade_test.go @@ -0,0 +1,371 @@ +package pilorama + +import ( + "context" + "crypto/rand" + "encoding/base64" + "encoding/hex" + "fmt" + randv2 "math/rand/v2" + "path/filepath" + "strconv" + "strings" + "testing" + "time" + + "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode" + cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id" + cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test" + oidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id/test" + usertest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/user/test" + "github.com/davecgh/go-spew/spew" + "github.com/stretchr/testify/require" + "go.etcd.io/bbolt" +) + +/* +Ниже представлены текущие данные в деревяшке и их новые аналоги. +system tree - настройки бакета, информация о мультипартах + + settings (при миграции атрибуты не меняются, ключ в новом дереве bucket-settings): + FileName: bucket-settings + Versioning + LockConfiguration + cannedACL + ownerKey + cors (при миграции атрибуты не меняются, ключ в новом дереве bucket-cors): + FileName: bucket-cors + OID + bucket-tagging (при миграции атрибуты не меняются, ключ в новом дереве bucket-tagging): + FileName: bucket-tagging + User-Tag- + multiparts info (при миграции атрибуты не меняются, ключ в новом дереве \u0000\u0000Info): + FileName + UploadId + Owner + Created + Finished + multiparts parts (были дочерними для multipart info; при миграции атрибуты не меняются, ключ в новом дереве \u0000\u0000) + Number + OID + Size + Created + ETag + MD5 + +version tree - хранит информацию о конкретных версиях объетов и их дополнительной мета информации (в том числе теги/локи) + + version + old attrs: + OID + FileName + Owner + Created + Size + ETag + MD5 + IdDeleteMarker + IsCombined + IsUnversioned + new attrs: + OID + FilePath + Key + Owner + Created + Size + ETag + MD5 + IdDeleteMarker + IsCombined + IsUnversioned + User-Tag- + LegalHoldOID + RetentionOID + UntilDate + IsCompliance + Ключ по которому сохраняется информация о версии \u0000 (где version-id это OID либо null если установлен флаг IsUnversioned) + Часть новых атрибутов в мете версии взята из тегов и локов, которые были раньше отдельными дочерними узлами версии. + теги: + IsTag + User-Tag- + локи: + IsLock + LegalHoldOID + RetentionOID + UntilDate + IsCompliance +*/ + +func toKeyValue(m map[string]string) []KeyValue { + kvs := make([]KeyValue, 0, len(m)) + for k, v := range m { + kvs = append(kvs, KeyValue{Key: k, Value: []byte(v)}) + } + return kvs +} + +func randBytes(n int) []byte { + a := make([]byte, n) + rand.Read(a) + return a +} + +func newMultipartInfo(filename string) (string, []KeyValue) { + uploadID := base64.StdEncoding.EncodeToString(randBytes(10)) + return uploadID, toKeyValue(map[string]string{ + AttributeFilename: filename, + multipartInfoUploadIDAttribute: uploadID, + "Owner": usertest.ID().EncodeToString(), + "Created": time.Now().String(), + "Finished": time.Now().Add(time.Hour).String(), + }) +} + +func newVersionKV(filename string) (string, []KeyValue) { + objID := oidtest.ID().EncodeToString() + return objID, toKeyValue(map[string]string{ + versionAttribute: objID, + AttributeFilename: filename, + "Owner": usertest.ID().EncodeToString(), + "Created": time.Now().String(), + "Size": strconv.Itoa(randv2.Int()), + "ETag": hex.EncodeToString(randBytes(32)), + "MD5": hex.EncodeToString(randBytes(16)), + "IdDeleteMarker": "false", + "IsCombined": "false", + "IsUnversioned": "false", + }) +} + +func TestUpgradeReal(t *testing.T) { + ctx := context.Background() + filename := filepath.Join("./testpilorama.db") + f := NewBoltForest(WithPath(filename)) + require.NoError(t, f.Open(ctx, mode.ReadWrite)) + require.NoError(t, f.Init()) + + seen := make(map[cid.ID]struct{}) + err := f.(*boltForest).db.Update(func(tx *bbolt.Tx) error { + c := tx.Cursor() + for key, _ := c.First(); key != nil; key, _ = c.Next() { + if len(key) < 32 { + spew.Dump(key) + continue + } + var cnr cid.ID + if err := cnr.Decode(key[:32]); err != nil { + return fmt.Errorf("(%T).Decode: %w", cnr, err) + } + fmt.Println(cnr.String(), string(key[32:])) + if _, ok := seen[cnr]; ok { + continue + } + seen[cnr] = struct{}{} + if err := f.(*boltForest).migrateVersionAndSystem(tx, cnr); err != nil { + return err + } + } + return nil + }) + require.NoError(t, err) + require.NoError(t, f.Close()) + + nf := NewPilorama(WithPath(filename)) + require.NoError(t, nf.Open(ctx, mode.ReadOnly)) + require.NoError(t, nf.Init()) + + defer nf.Close() +} + +func TestUpgrade(t *testing.T) { + ctx := context.Background() + filename := filepath.Join(t.TempDir(), "pilorama") + f := NewBoltForest(WithPath(filename)) + require.NoError(t, f.Open(ctx, mode.ReadWrite)) + require.NoError(t, f.Init()) + + cnr := cidtest.ID() + d := CIDDescriptor{CID: cnr, Position: 1, Size: 4} + + addByPath := func(treeID string, filePath []string, meta []KeyValue) []Move { + res, err := f.TreeAddByPath(ctx, d, treeID, AttributeFilename, filePath, meta) + require.NoError(t, err) + return res + } + + move := func(treeID string, parent Node, meta []KeyValue) { + _, err := f.TreeMove(ctx, d, treeID, &Move{ + Parent: parent, + Meta: Meta{Items: meta}, + }) + require.NoError(t, err) + } + + type addOp struct { + filepath string + version string + meta []KeyValue + unversionedMeta []KeyValue + } + ops := []addOp{ + {filepath: "my/dir/object1"}, + {filepath: "my/dir/object2"}, + {filepath: "my/dir1/object1"}, + {filepath: "toplevel"}, + } + + for i := range ops { + fp := strings.Split(ops[i].filepath, "/") + version, m := newVersionKV(fp[len(fp)-1]) + res := addByPath(versionTreeID, fp[:len(fp)-1], m) + + switch i { + case 0: + // Attach lock info to the first object. + aux := toKeyValue(map[string]string{ + versionLockAttribute: "true", + "LegalHoldOID": "garbage1", + "RetentionOID": "garbage2", + "UntilDate": time.Now().String(), + "IsCompliance": "false", + }) + move(versionTreeID, res[len(res)-1].Child, aux) + m = append(m, aux...) + case 1: + // Attach user tag info to the second object. + aux := toKeyValue(map[string]string{ + versionTagAttribute: "true", + "User-Tag-kek": "my-user-tag", + }) + move(versionTreeID, res[len(res)-1].Child, aux) + m = append(m, aux...) + case 2: + // Add multiple unversioned objects. The last one should remain. + aux := toKeyValue(map[string]string{ + isUnversionedAttribute: "true", + AttributeFilename: fp[len(fp)-1], + "attempt": "1", + }) + addByPath(versionTreeID, fp[:len(fp)-1], aux) + + aux = toKeyValue(map[string]string{ + isUnversionedAttribute: "true", + AttributeFilename: fp[len(fp)-1], + "attempt": "2", + }) + addByPath(versionTreeID, fp[:len(fp)-1], aux) + + ops[i].unversionedMeta = aux + } + + ops[i].version = version + ops[i].meta = m + } + + // System tree. + type multipart struct { + filepath string + uploadID string + meta []KeyValue + parts []int + partsMeta [][]KeyValue + } + + multipartOps := []multipart{ + {filepath: "path1/object1"}, + {filepath: "path1/object2"}, + {filepath: "path2"}, + {filepath: systemSettingsKey}, // Dirty test for naming conflict. + } + + settingsMeta := toKeyValue(map[string]string{ + AttributeFilename: systemSettingsKey, + "Versioning": "enabled", + "LockConfiguration": "something", + }) + addByPath(systemTreeID, nil, settingsMeta) + + lifecycleMeta := toKeyValue(map[string]string{ + AttributeFilename: systemLifecycleKey, + "LockConfiguration": "something", + }) + addByPath(systemTreeID, nil, lifecycleMeta) + + corsMeta := toKeyValue(map[string]string{ + AttributeFilename: systemCorsKey, + "OID": oidtest.ID().String(), + }) + addByPath(systemTreeID, nil, corsMeta) + + taggingMeta := toKeyValue(map[string]string{ + AttributeFilename: systemTaggingKey, + "User-Tag-mytag": "abc", + }) + addByPath(systemTreeID, nil, taggingMeta) + + for i := range multipartOps { + fp := strings.Split(multipartOps[i].filepath, "/") + uploadID, m := newMultipartInfo(fp[len(fp)-1]) + res := addByPath(systemTreeID, fp[:len(fp)-1], m) + for j := 0; j < 4; j++ { + if randv2.Int()%2 == 0 { + aux := toKeyValue(map[string]string{ + multipartInfoNumberAttribute: strconv.Itoa(j), + "OID": oidtest.ID().EncodeToString(), + "Size": strconv.Itoa(randv2.Int()), + "Created": time.Now().String(), + "ETag": hex.EncodeToString(randBytes(10)), + "MD5": hex.EncodeToString(randBytes(16)), + }) + move(systemTreeID, res[len(res)-1].Child, aux) + + multipartOps[i].parts = append(multipartOps[i].parts, j) + multipartOps[i].partsMeta = append(multipartOps[i].partsMeta, aux) + } + } + + multipartOps[i].uploadID = uploadID + multipartOps[i].meta = m + } + + err := f.(*boltForest).db.Update(func(tx *bbolt.Tx) error { + return f.(*boltForest).migrateVersionAndSystem(tx, cnr) + }) + require.NoError(t, err) + require.NoError(t, f.Close()) + + nf := NewPilorama(WithPath(filename)) + require.NoError(t, nf.Open(ctx, mode.ReadOnly)) + require.NoError(t, nf.Init()) + + checkMeta := func(treeID string, key []byte, expected []KeyValue) { + meta, err := nf.GetLatest(cnr, treeID, key) + require.NoError(t, err) + require.Equal(t, expected, meta.Items) + } + for i := range ops { + key := []byte(ops[i].filepath + "\x00" + ops[i].version) + checkMeta(versionTreeID, key, ops[i].meta) + + if ops[i].unversionedMeta != nil { + key := []byte(ops[i].filepath + "\x00" + nullVersionValue) + checkMeta(versionTreeID, key, ops[i].unversionedMeta) + } + } + + checkMeta(systemTreeID, []byte(systemSettingsKey), settingsMeta) + checkMeta(systemTreeID, []byte(systemCorsKey), corsMeta) + checkMeta(systemTreeID, []byte(systemLifecycleKey), lifecycleMeta) + checkMeta(systemTreeID, []byte(systemTaggingKey), taggingMeta) + + for i := range multipartOps { + key := []byte(multipartOps[i].filepath + "\x00" + multipartOps[i].uploadID + "\x00" + "Info") + checkMeta(systemTreeID, key, multipartOps[i].meta) + + for j, number := range multipartOps[i].parts { + key := []byte(multipartOps[i].filepath + "\x00" + multipartOps[i].uploadID + "\x00" + strconv.Itoa(number)) + checkMeta(systemTreeID, key, multipartOps[i].partsMeta[j]) + } + } +} diff --git a/pkg/local_object_storage/shard/control.go b/pkg/local_object_storage/shard/control.go index 62800dbd0..2585efa4c 100644 --- a/pkg/local_object_storage/shard/control.go +++ b/pkg/local_object_storage/shard/control.go @@ -63,6 +63,9 @@ func (s *Shard) Open(ctx context.Context) error { if s.pilorama != nil { components = append(components, s.pilorama) } + if s.burned != nil { + components = append(components, s.burned) + } for i, component := range components { if err := component.Open(ctx, m); err != nil { @@ -168,6 +171,9 @@ func (s *Shard) initializeComponents(m mode.Mode) error { if s.pilorama != nil { components = append(components, s.pilorama) } + if s.burned != nil { + components = append(components, s.burned) + } for _, component := range components { if err := component.Init(); err != nil { @@ -373,6 +379,9 @@ func (s *Shard) Close() error { if s.pilorama != nil { components = append(components, s.pilorama) } + if s.burned != nil { + components = append(components, s.burned) + } if s.hasWriteCache() { prev := s.writecacheSealCancel.Swap(notInitializedCancel) diff --git a/pkg/local_object_storage/shard/mode.go b/pkg/local_object_storage/shard/mode.go index d90a5f4b6..d9c573f73 100644 --- a/pkg/local_object_storage/shard/mode.go +++ b/pkg/local_object_storage/shard/mode.go @@ -41,6 +41,9 @@ func (s *Shard) setMode(m mode.Mode) error { if s.pilorama != nil { components = append(components, s.pilorama) } + if s.burned != nil { + components = append(components, s.burned) + } // The usual flow of the requests (pilorama is independent): // writecache -> blobstor -> metabase diff --git a/pkg/local_object_storage/shard/shard.go b/pkg/local_object_storage/shard/shard.go index 413bfd2f7..b40dcc694 100644 --- a/pkg/local_object_storage/shard/shard.go +++ b/pkg/local_object_storage/shard/shard.go @@ -32,6 +32,8 @@ type Shard struct { pilorama pilorama.ForestStorage + burned pilorama.BurnedForest + metaBase *meta.DB tsSource TombstoneSource @@ -146,7 +148,8 @@ func New(opts ...Option) *Shard { } if s.piloramaOpts != nil { - s.pilorama = pilorama.NewBoltForest(c.piloramaOpts...) + //s.pilorama = pilorama.NewBoltForest(c.piloramaOpts...) + s.burned = pilorama.NewPilorama(c.piloramaOpts...) } s.fillInfo() diff --git a/pkg/local_object_storage/shard/tree.go b/pkg/local_object_storage/shard/tree.go index 26dc8ec1e..d89c52fa8 100644 --- a/pkg/local_object_storage/shard/tree.go +++ b/pkg/local_object_storage/shard/tree.go @@ -7,6 +7,7 @@ import ( "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/pilorama" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/util/logicerr" "git.frostfs.info/TrueCloudLab/frostfs-observability/tracing" + cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id" cidSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" @@ -427,3 +428,110 @@ func (s *Shard) TreeApplyStream(ctx context.Context, cnr cidSDK.ID, treeID strin } return s.pilorama.TreeApplyStream(ctx, cnr, treeID, source) } + +func (s *Shard) Add(d pilorama.CIDDescriptor, treeID string, key []byte, meta pilorama.Meta) (pilorama.Operation, error) { + if s.burned == nil { + return pilorama.Operation{}, ErrPiloramaDisabled + } + + s.m.RLock() + defer s.m.RUnlock() + + if s.info.Mode.ReadOnly() { + return pilorama.Operation{}, ErrReadOnlyMode + } + if s.info.Mode.NoMetabase() { + return pilorama.Operation{}, ErrDegradedMode + } + return s.burned.Add(d, treeID, key, meta) +} + +func (s *Shard) Remove(d pilorama.CIDDescriptor, treeID string, key []byte) (pilorama.Operation, error) { + if s.burned == nil { + return pilorama.Operation{}, ErrPiloramaDisabled + } + + s.m.RLock() + defer s.m.RUnlock() + + if s.info.Mode.ReadOnly() { + return pilorama.Operation{}, ErrReadOnlyMode + } + if s.info.Mode.NoMetabase() { + return pilorama.Operation{}, ErrDegradedMode + } + return s.burned.Remove(d, treeID, key) +} + +func (s *Shard) Apply(cnr cid.ID, treeID string, op pilorama.Operation) error { + if s.burned == nil { + return ErrPiloramaDisabled + } + + s.m.RLock() + defer s.m.RUnlock() + + if s.info.Mode.ReadOnly() { + return ErrReadOnlyMode + } + if s.info.Mode.NoMetabase() { + return ErrDegradedMode + } + return s.burned.Apply(cnr, treeID, op) +} + +func (s *Shard) GetLatest(cnr cid.ID, treeID string, key []byte) (pilorama.Meta, error) { + if s.burned == nil { + return pilorama.Meta{}, ErrPiloramaDisabled + } + + s.m.RLock() + defer s.m.RUnlock() + + if s.info.Mode.NoMetabase() { + return pilorama.Meta{}, ErrDegradedMode + } + return s.burned.GetLatest(cnr, treeID, key) +} + +func (s *Shard) GetLatestByPrefix(cnr cid.ID, treeID string, prefix []byte) (pilorama.MetaVersion, error) { + if s.burned == nil { + return pilorama.MetaVersion{}, ErrPiloramaDisabled + } + + s.m.RLock() + defer s.m.RUnlock() + + if s.info.Mode.NoMetabase() { + return pilorama.MetaVersion{}, ErrDegradedMode + } + return s.burned.GetLatestByPrefix(cnr, treeID, prefix) +} + +func (s *Shard) ListByPrefix(cnr cid.ID, treeID string, key []byte) ([]pilorama.MetaVersion, error) { + if s.burned == nil { + return nil, ErrPiloramaDisabled + } + + s.m.RLock() + defer s.m.RUnlock() + + if s.info.Mode.NoMetabase() { + return nil, ErrDegradedMode + } + return s.burned.ListByPrefix(cnr, treeID, key) +} + +func (s *Shard) ListAll(cnr cid.ID, treeID string, param pilorama.ListParam) ([][]byte, error) { + if s.burned == nil { + return nil, ErrPiloramaDisabled + } + + s.m.RLock() + defer s.m.RUnlock() + + if s.info.Mode.NoMetabase() { + return nil, ErrDegradedMode + } + return s.burned.ListAll(cnr, treeID, param) +} diff --git a/pkg/services/tree/options.go b/pkg/services/tree/options.go index 1633ae557..e5950fc46 100644 --- a/pkg/services/tree/options.go +++ b/pkg/services/tree/options.go @@ -35,6 +35,8 @@ type cfg struct { cnrSource ContainerSource frostfsidSubjectProvider frostfsidcore.SubjectProvider forest pilorama.Forest + burned pilorama.BurnedFully + // replication-related parameters replicatorChannelCapacity int replicatorWorkerCount int @@ -97,6 +99,13 @@ func WithStorage(s pilorama.Forest) Option { } } +// WithBurnedStorage sets tree storage for a service. +func WithBurnedStorage(s pilorama.BurnedFully) Option { + return func(c *cfg) { + c.burned = s + } +} + func WithReplicationChannelCapacity(n int) Option { return func(c *cfg) { if n > 0 { diff --git a/pkg/services/tree/service.proto b/pkg/services/tree/service.proto index 88bf0bca4..5284b79ff 100644 --- a/pkg/services/tree/service.proto +++ b/pkg/services/tree/service.proto @@ -51,6 +51,146 @@ service TreeService { rpc GetOpLog(GetOpLogRequest) returns (stream GetOpLogResponse); // Healthcheck is a dummy rpc to check service availability rpc Healthcheck(HealthcheckRequest) returns (HealthcheckResponse); + + rpc BurnedAdd(BurnedAddRequest) returns (BurnedAddResponse); + rpc BurnedRemove(BurnedRemoveRequest) returns (BurnedRemoveResponse); + rpc BurnedApply(BurnedApplyRequest) returns (BurnedApplyResponse); + rpc BurnedGet(BurnedGetRequest) returns (BurnedGetResponse); + rpc BurnedGetLatestByPrefix(BurnedGetLatestByPrefixRequest) + returns (BurnedGetLatestByPrefixResponse); + rpc BurnedListByPrefix(BurnedListByPrefixRequest) + returns (BurnedListByPrefixResponse); + rpc BurnedList(BurnedListRequest) returns (stream BurnedListResponse); +} + +message BurnedAddRequest { + message Body { + bytes container_id = 1; + string tree_id = 2; + string key = 3; + repeated KeyValue meta = 4; + } + Body body = 1; + Signature signature = 2; +} +message BurnedAddResponse { + message Body {} + Body body = 1; + Signature signature = 2; +} + +message BurnedRemoveRequest { + message Body { + bytes container_id = 1; + string tree_id = 2; + string key = 3; + } + Body body = 1; + Signature signature = 2; +} +message BurnedRemoveResponse { + message Body {} + Body body = 1; + Signature signature = 2; +} + +message BurnedApplyRequest { + message Body { + bytes container_id = 1; + string tree_id = 2; + bytes op = 3; + } + Body body = 1; + Signature signature = 2; +} +message BurnedApplyResponse { + message Body {} + Body body = 1; + Signature signature = 2; +} + +message BurnedGetRequest { + message Body { + bytes container_id = 1; + string tree_id = 2; + string key = 3; + bytes bearer_token = 5; + } + Body body = 1; + Signature signature = 2; +} + +message BurnedGetResponse { + message Body { + uint64 timestamp = 1; + repeated KeyValue meta = 2; + } + Body body = 1; + Signature signature = 2; +} + +message BurnedGetLatestByPrefixRequest { + message Body { + bytes container_id = 1; + string tree_id = 2; + string prefix = 3; + bytes bearer_token = 5; + } + Body body = 1; + Signature signature = 2; +} + +message BurnedGetLatestByPrefixResponse { + message Body { + string key = 1; + uint64 timestamp = 2; + repeated KeyValue meta = 3; + } + Body body = 1; + Signature signature = 2; +} + +message BurnedListByPrefixRequest { + message Body { + bytes container_id = 1; + string tree_id = 2; + string key = 3; + } + Body body = 1; + Signature signature = 2; +} + +message BurnedListByPrefixResponse { + message Body { + message Info { + string key = 1; + uint64 timestamp = 2; + repeated KeyValue meta = 3; + } + repeated Info list = 1; + } + Body body = 1; + Signature signature = 2; +} + +message BurnedListRequest { + message Body { + bytes container_id = 1; + string tree_id = 2; + string start = 3; + } + Body body = 1; + Signature signature = 2; +} + +message BurnedListResponse { + message Body { + string key = 1; + uint64 timestamp = 2; + repeated KeyValue meta = 3; + } + Body body = 1; + Signature signature = 2; } message AddRequest { diff --git a/pkg/services/tree/service_frostfs.pb.go b/pkg/services/tree/service_frostfs.pb.go index 7b6abb1dd..16dc0a060 100644 --- a/pkg/services/tree/service_frostfs.pb.go +++ b/pkg/services/tree/service_frostfs.pb.go @@ -15,6 +15,5799 @@ import ( strconv "strconv" ) +type BurnedAddRequest_Body struct { + ContainerId []byte `json:"containerId"` + TreeId string `json:"treeId"` + Key string `json:"key"` + Meta []KeyValue `json:"meta"` +} + +var ( + _ encoding.ProtoMarshaler = (*BurnedAddRequest_Body)(nil) + _ encoding.ProtoUnmarshaler = (*BurnedAddRequest_Body)(nil) + _ json.Marshaler = (*BurnedAddRequest_Body)(nil) + _ json.Unmarshaler = (*BurnedAddRequest_Body)(nil) +) + +// StableSize returns the size of x in protobuf format. +// +// Structures with the same field values have the same binary size. +func (x *BurnedAddRequest_Body) StableSize() (size int) { + if x == nil { + return 0 + } + size += proto.BytesSize(1, x.ContainerId) + size += proto.StringSize(2, x.TreeId) + size += proto.StringSize(3, x.Key) + for i := range x.Meta { + size += proto.NestedStructureSizeUnchecked(4, &x.Meta[i]) + } + return size +} + +// MarshalProtobuf implements the encoding.ProtoMarshaler interface. +func (x *BurnedAddRequest_Body) MarshalProtobuf(dst []byte) []byte { + m := pool.MarshalerPool.Get() + defer pool.MarshalerPool.Put(m) + x.EmitProtobuf(m.MessageMarshaler()) + dst = m.Marshal(dst) + return dst +} + +func (x *BurnedAddRequest_Body) EmitProtobuf(mm *easyproto.MessageMarshaler) { + if x == nil { + return + } + if len(x.ContainerId) != 0 { + mm.AppendBytes(1, x.ContainerId) + } + if len(x.TreeId) != 0 { + mm.AppendString(2, x.TreeId) + } + if len(x.Key) != 0 { + mm.AppendString(3, x.Key) + } + for i := range x.Meta { + x.Meta[i].EmitProtobuf(mm.AppendMessage(4)) + } +} + +// UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface. +func (x *BurnedAddRequest_Body) UnmarshalProtobuf(src []byte) (err error) { + var fc easyproto.FieldContext + for len(src) > 0 { + src, err = fc.NextField(src) + if err != nil { + return fmt.Errorf("cannot read next field in %s", "BurnedAddRequest_Body") + } + switch fc.FieldNum { + case 1: // ContainerId + data, ok := fc.Bytes() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "ContainerId") + } + x.ContainerId = data + case 2: // TreeId + data, ok := fc.String() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "TreeId") + } + x.TreeId = data + case 3: // Key + data, ok := fc.String() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Key") + } + x.Key = data + case 4: // Meta + data, ok := fc.MessageData() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Meta") + } + x.Meta = append(x.Meta, KeyValue{}) + ff := &x.Meta[len(x.Meta)-1] + if err := ff.UnmarshalProtobuf(data); err != nil { + return fmt.Errorf("unmarshal: %w", err) + } + } + } + return nil +} +func (x *BurnedAddRequest_Body) GetContainerId() []byte { + if x != nil { + return x.ContainerId + } + return nil +} +func (x *BurnedAddRequest_Body) SetContainerId(v []byte) { + x.ContainerId = v +} +func (x *BurnedAddRequest_Body) GetTreeId() string { + if x != nil { + return x.TreeId + } + return "" +} +func (x *BurnedAddRequest_Body) SetTreeId(v string) { + x.TreeId = v +} +func (x *BurnedAddRequest_Body) GetKey() string { + if x != nil { + return x.Key + } + return "" +} +func (x *BurnedAddRequest_Body) SetKey(v string) { + x.Key = v +} +func (x *BurnedAddRequest_Body) GetMeta() []KeyValue { + if x != nil { + return x.Meta + } + return nil +} +func (x *BurnedAddRequest_Body) SetMeta(v []KeyValue) { + x.Meta = v +} + +// MarshalJSON implements the json.Marshaler interface. +func (x *BurnedAddRequest_Body) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + x.MarshalEasyJSON(&w) + return w.Buffer.BuildBytes(), w.Error +} +func (x *BurnedAddRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { + if x == nil { + out.RawString("null") + return + } + first := true + out.RawByte('{') + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"containerId\":" + out.RawString(prefix) + if x.ContainerId != nil { + out.Base64Bytes(x.ContainerId) + } else { + out.String("") + } + } + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"treeId\":" + out.RawString(prefix) + out.String(x.TreeId) + } + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"key\":" + out.RawString(prefix) + out.String(x.Key) + } + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"meta\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.Meta { + if i != 0 { + out.RawByte(',') + } + x.Meta[i].MarshalEasyJSON(out) + } + out.RawByte(']') + } + out.RawByte('}') +} + +// UnmarshalJSON implements the json.Unmarshaler interface. +func (x *BurnedAddRequest_Body) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + x.UnmarshalEasyJSON(&r) + return r.Error() +} +func (x *BurnedAddRequest_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "containerId": + { + var f []byte + { + tmp := in.Bytes() + if len(tmp) == 0 { + tmp = nil + } + f = tmp + } + x.ContainerId = f + } + case "treeId": + { + var f string + f = in.String() + x.TreeId = f + } + case "key": + { + var f string + f = in.String() + x.Key = f + } + case "meta": + { + var f KeyValue + var list []KeyValue + in.Delim('[') + for !in.IsDelim(']') { + f = KeyValue{} + f.UnmarshalEasyJSON(in) + list = append(list, f) + in.WantComma() + } + x.Meta = list + in.Delim(']') + } + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} + +type BurnedAddRequest struct { + Body *BurnedAddRequest_Body `json:"body"` + Signature *Signature `json:"signature"` +} + +var ( + _ encoding.ProtoMarshaler = (*BurnedAddRequest)(nil) + _ encoding.ProtoUnmarshaler = (*BurnedAddRequest)(nil) + _ json.Marshaler = (*BurnedAddRequest)(nil) + _ json.Unmarshaler = (*BurnedAddRequest)(nil) +) + +// StableSize returns the size of x in protobuf format. +// +// Structures with the same field values have the same binary size. +func (x *BurnedAddRequest) StableSize() (size int) { + if x == nil { + return 0 + } + size += proto.NestedStructureSize(1, x.Body) + size += proto.NestedStructureSize(2, x.Signature) + return size +} + +// ReadSignedData fills buf with signed data of x. +// If buffer length is less than x.SignedDataSize(), new buffer is allocated. +// +// Returns any error encountered which did not allow writing the data completely. +// Otherwise, returns the buffer in which the data is written. +// +// Structures with the same field values have the same signed data. +func (x *BurnedAddRequest) SignedDataSize() int { + return x.GetBody().StableSize() +} + +// SignedDataSize returns size of the request signed data in bytes. +// +// Structures with the same field values have the same signed data size. +func (x *BurnedAddRequest) ReadSignedData(buf []byte) ([]byte, error) { + return x.GetBody().MarshalProtobuf(buf), nil +} + +// MarshalProtobuf implements the encoding.ProtoMarshaler interface. +func (x *BurnedAddRequest) MarshalProtobuf(dst []byte) []byte { + m := pool.MarshalerPool.Get() + defer pool.MarshalerPool.Put(m) + x.EmitProtobuf(m.MessageMarshaler()) + dst = m.Marshal(dst) + return dst +} + +func (x *BurnedAddRequest) EmitProtobuf(mm *easyproto.MessageMarshaler) { + if x == nil { + return + } + if x.Body != nil { + x.Body.EmitProtobuf(mm.AppendMessage(1)) + } + if x.Signature != nil { + x.Signature.EmitProtobuf(mm.AppendMessage(2)) + } +} + +// UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface. +func (x *BurnedAddRequest) UnmarshalProtobuf(src []byte) (err error) { + var fc easyproto.FieldContext + for len(src) > 0 { + src, err = fc.NextField(src) + if err != nil { + return fmt.Errorf("cannot read next field in %s", "BurnedAddRequest") + } + switch fc.FieldNum { + case 1: // Body + data, ok := fc.MessageData() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Body") + } + x.Body = new(BurnedAddRequest_Body) + if err := x.Body.UnmarshalProtobuf(data); err != nil { + return fmt.Errorf("unmarshal: %w", err) + } + case 2: // Signature + data, ok := fc.MessageData() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Signature") + } + x.Signature = new(Signature) + if err := x.Signature.UnmarshalProtobuf(data); err != nil { + return fmt.Errorf("unmarshal: %w", err) + } + } + } + return nil +} +func (x *BurnedAddRequest) GetBody() *BurnedAddRequest_Body { + if x != nil { + return x.Body + } + return nil +} +func (x *BurnedAddRequest) SetBody(v *BurnedAddRequest_Body) { + x.Body = v +} +func (x *BurnedAddRequest) GetSignature() *Signature { + if x != nil { + return x.Signature + } + return nil +} +func (x *BurnedAddRequest) SetSignature(v *Signature) { + x.Signature = v +} + +// MarshalJSON implements the json.Marshaler interface. +func (x *BurnedAddRequest) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + x.MarshalEasyJSON(&w) + return w.Buffer.BuildBytes(), w.Error +} +func (x *BurnedAddRequest) MarshalEasyJSON(out *jwriter.Writer) { + if x == nil { + out.RawString("null") + return + } + first := true + out.RawByte('{') + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" + out.RawString(prefix) + x.Signature.MarshalEasyJSON(out) + } + out.RawByte('}') +} + +// UnmarshalJSON implements the json.Unmarshaler interface. +func (x *BurnedAddRequest) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + x.UnmarshalEasyJSON(&r) + return r.Error() +} +func (x *BurnedAddRequest) UnmarshalEasyJSON(in *jlexer.Lexer) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "body": + { + var f *BurnedAddRequest_Body + f = new(BurnedAddRequest_Body) + f.UnmarshalEasyJSON(in) + x.Body = f + } + case "signature": + { + var f *Signature + f = new(Signature) + f.UnmarshalEasyJSON(in) + x.Signature = f + } + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} + +type BurnedAddResponse_Body struct { +} + +var ( + _ encoding.ProtoMarshaler = (*BurnedAddResponse_Body)(nil) + _ encoding.ProtoUnmarshaler = (*BurnedAddResponse_Body)(nil) + _ json.Marshaler = (*BurnedAddResponse_Body)(nil) + _ json.Unmarshaler = (*BurnedAddResponse_Body)(nil) +) + +// StableSize returns the size of x in protobuf format. +// +// Structures with the same field values have the same binary size. +func (x *BurnedAddResponse_Body) StableSize() (size int) { + if x == nil { + return 0 + } + return size +} + +// MarshalProtobuf implements the encoding.ProtoMarshaler interface. +func (x *BurnedAddResponse_Body) MarshalProtobuf(dst []byte) []byte { + m := pool.MarshalerPool.Get() + defer pool.MarshalerPool.Put(m) + x.EmitProtobuf(m.MessageMarshaler()) + dst = m.Marshal(dst) + return dst +} + +func (x *BurnedAddResponse_Body) EmitProtobuf(mm *easyproto.MessageMarshaler) { +} + +// UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface. +func (x *BurnedAddResponse_Body) UnmarshalProtobuf(src []byte) (err error) { + var fc easyproto.FieldContext + for len(src) > 0 { + src, err = fc.NextField(src) + if err != nil { + return fmt.Errorf("cannot read next field in %s", "BurnedAddResponse_Body") + } + switch fc.FieldNum { + } + } + return nil +} + +// MarshalJSON implements the json.Marshaler interface. +func (x *BurnedAddResponse_Body) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + x.MarshalEasyJSON(&w) + return w.Buffer.BuildBytes(), w.Error +} +func (x *BurnedAddResponse_Body) MarshalEasyJSON(out *jwriter.Writer) { + if x == nil { + out.RawString("null") + return + } + out.RawByte('{') + out.RawByte('}') +} + +// UnmarshalJSON implements the json.Unmarshaler interface. +func (x *BurnedAddResponse_Body) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + x.UnmarshalEasyJSON(&r) + return r.Error() +} +func (x *BurnedAddResponse_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} + +type BurnedAddResponse struct { + Body *BurnedAddResponse_Body `json:"body"` + Signature *Signature `json:"signature"` +} + +var ( + _ encoding.ProtoMarshaler = (*BurnedAddResponse)(nil) + _ encoding.ProtoUnmarshaler = (*BurnedAddResponse)(nil) + _ json.Marshaler = (*BurnedAddResponse)(nil) + _ json.Unmarshaler = (*BurnedAddResponse)(nil) +) + +// StableSize returns the size of x in protobuf format. +// +// Structures with the same field values have the same binary size. +func (x *BurnedAddResponse) StableSize() (size int) { + if x == nil { + return 0 + } + size += proto.NestedStructureSize(1, x.Body) + size += proto.NestedStructureSize(2, x.Signature) + return size +} + +// ReadSignedData fills buf with signed data of x. +// If buffer length is less than x.SignedDataSize(), new buffer is allocated. +// +// Returns any error encountered which did not allow writing the data completely. +// Otherwise, returns the buffer in which the data is written. +// +// Structures with the same field values have the same signed data. +func (x *BurnedAddResponse) SignedDataSize() int { + return x.GetBody().StableSize() +} + +// SignedDataSize returns size of the request signed data in bytes. +// +// Structures with the same field values have the same signed data size. +func (x *BurnedAddResponse) ReadSignedData(buf []byte) ([]byte, error) { + return x.GetBody().MarshalProtobuf(buf), nil +} + +// MarshalProtobuf implements the encoding.ProtoMarshaler interface. +func (x *BurnedAddResponse) MarshalProtobuf(dst []byte) []byte { + m := pool.MarshalerPool.Get() + defer pool.MarshalerPool.Put(m) + x.EmitProtobuf(m.MessageMarshaler()) + dst = m.Marshal(dst) + return dst +} + +func (x *BurnedAddResponse) EmitProtobuf(mm *easyproto.MessageMarshaler) { + if x == nil { + return + } + if x.Body != nil { + x.Body.EmitProtobuf(mm.AppendMessage(1)) + } + if x.Signature != nil { + x.Signature.EmitProtobuf(mm.AppendMessage(2)) + } +} + +// UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface. +func (x *BurnedAddResponse) UnmarshalProtobuf(src []byte) (err error) { + var fc easyproto.FieldContext + for len(src) > 0 { + src, err = fc.NextField(src) + if err != nil { + return fmt.Errorf("cannot read next field in %s", "BurnedAddResponse") + } + switch fc.FieldNum { + case 1: // Body + data, ok := fc.MessageData() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Body") + } + x.Body = new(BurnedAddResponse_Body) + if err := x.Body.UnmarshalProtobuf(data); err != nil { + return fmt.Errorf("unmarshal: %w", err) + } + case 2: // Signature + data, ok := fc.MessageData() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Signature") + } + x.Signature = new(Signature) + if err := x.Signature.UnmarshalProtobuf(data); err != nil { + return fmt.Errorf("unmarshal: %w", err) + } + } + } + return nil +} +func (x *BurnedAddResponse) GetBody() *BurnedAddResponse_Body { + if x != nil { + return x.Body + } + return nil +} +func (x *BurnedAddResponse) SetBody(v *BurnedAddResponse_Body) { + x.Body = v +} +func (x *BurnedAddResponse) GetSignature() *Signature { + if x != nil { + return x.Signature + } + return nil +} +func (x *BurnedAddResponse) SetSignature(v *Signature) { + x.Signature = v +} + +// MarshalJSON implements the json.Marshaler interface. +func (x *BurnedAddResponse) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + x.MarshalEasyJSON(&w) + return w.Buffer.BuildBytes(), w.Error +} +func (x *BurnedAddResponse) MarshalEasyJSON(out *jwriter.Writer) { + if x == nil { + out.RawString("null") + return + } + first := true + out.RawByte('{') + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" + out.RawString(prefix) + x.Signature.MarshalEasyJSON(out) + } + out.RawByte('}') +} + +// UnmarshalJSON implements the json.Unmarshaler interface. +func (x *BurnedAddResponse) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + x.UnmarshalEasyJSON(&r) + return r.Error() +} +func (x *BurnedAddResponse) UnmarshalEasyJSON(in *jlexer.Lexer) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "body": + { + var f *BurnedAddResponse_Body + f = new(BurnedAddResponse_Body) + f.UnmarshalEasyJSON(in) + x.Body = f + } + case "signature": + { + var f *Signature + f = new(Signature) + f.UnmarshalEasyJSON(in) + x.Signature = f + } + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} + +type BurnedRemoveRequest_Body struct { + ContainerId []byte `json:"containerId"` + TreeId string `json:"treeId"` + Key string `json:"key"` +} + +var ( + _ encoding.ProtoMarshaler = (*BurnedRemoveRequest_Body)(nil) + _ encoding.ProtoUnmarshaler = (*BurnedRemoveRequest_Body)(nil) + _ json.Marshaler = (*BurnedRemoveRequest_Body)(nil) + _ json.Unmarshaler = (*BurnedRemoveRequest_Body)(nil) +) + +// StableSize returns the size of x in protobuf format. +// +// Structures with the same field values have the same binary size. +func (x *BurnedRemoveRequest_Body) StableSize() (size int) { + if x == nil { + return 0 + } + size += proto.BytesSize(1, x.ContainerId) + size += proto.StringSize(2, x.TreeId) + size += proto.StringSize(3, x.Key) + return size +} + +// MarshalProtobuf implements the encoding.ProtoMarshaler interface. +func (x *BurnedRemoveRequest_Body) MarshalProtobuf(dst []byte) []byte { + m := pool.MarshalerPool.Get() + defer pool.MarshalerPool.Put(m) + x.EmitProtobuf(m.MessageMarshaler()) + dst = m.Marshal(dst) + return dst +} + +func (x *BurnedRemoveRequest_Body) EmitProtobuf(mm *easyproto.MessageMarshaler) { + if x == nil { + return + } + if len(x.ContainerId) != 0 { + mm.AppendBytes(1, x.ContainerId) + } + if len(x.TreeId) != 0 { + mm.AppendString(2, x.TreeId) + } + if len(x.Key) != 0 { + mm.AppendString(3, x.Key) + } +} + +// UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface. +func (x *BurnedRemoveRequest_Body) UnmarshalProtobuf(src []byte) (err error) { + var fc easyproto.FieldContext + for len(src) > 0 { + src, err = fc.NextField(src) + if err != nil { + return fmt.Errorf("cannot read next field in %s", "BurnedRemoveRequest_Body") + } + switch fc.FieldNum { + case 1: // ContainerId + data, ok := fc.Bytes() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "ContainerId") + } + x.ContainerId = data + case 2: // TreeId + data, ok := fc.String() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "TreeId") + } + x.TreeId = data + case 3: // Key + data, ok := fc.String() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Key") + } + x.Key = data + } + } + return nil +} +func (x *BurnedRemoveRequest_Body) GetContainerId() []byte { + if x != nil { + return x.ContainerId + } + return nil +} +func (x *BurnedRemoveRequest_Body) SetContainerId(v []byte) { + x.ContainerId = v +} +func (x *BurnedRemoveRequest_Body) GetTreeId() string { + if x != nil { + return x.TreeId + } + return "" +} +func (x *BurnedRemoveRequest_Body) SetTreeId(v string) { + x.TreeId = v +} +func (x *BurnedRemoveRequest_Body) GetKey() string { + if x != nil { + return x.Key + } + return "" +} +func (x *BurnedRemoveRequest_Body) SetKey(v string) { + x.Key = v +} + +// MarshalJSON implements the json.Marshaler interface. +func (x *BurnedRemoveRequest_Body) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + x.MarshalEasyJSON(&w) + return w.Buffer.BuildBytes(), w.Error +} +func (x *BurnedRemoveRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { + if x == nil { + out.RawString("null") + return + } + first := true + out.RawByte('{') + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"containerId\":" + out.RawString(prefix) + if x.ContainerId != nil { + out.Base64Bytes(x.ContainerId) + } else { + out.String("") + } + } + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"treeId\":" + out.RawString(prefix) + out.String(x.TreeId) + } + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"key\":" + out.RawString(prefix) + out.String(x.Key) + } + out.RawByte('}') +} + +// UnmarshalJSON implements the json.Unmarshaler interface. +func (x *BurnedRemoveRequest_Body) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + x.UnmarshalEasyJSON(&r) + return r.Error() +} +func (x *BurnedRemoveRequest_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "containerId": + { + var f []byte + { + tmp := in.Bytes() + if len(tmp) == 0 { + tmp = nil + } + f = tmp + } + x.ContainerId = f + } + case "treeId": + { + var f string + f = in.String() + x.TreeId = f + } + case "key": + { + var f string + f = in.String() + x.Key = f + } + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} + +type BurnedRemoveRequest struct { + Body *BurnedRemoveRequest_Body `json:"body"` + Signature *Signature `json:"signature"` +} + +var ( + _ encoding.ProtoMarshaler = (*BurnedRemoveRequest)(nil) + _ encoding.ProtoUnmarshaler = (*BurnedRemoveRequest)(nil) + _ json.Marshaler = (*BurnedRemoveRequest)(nil) + _ json.Unmarshaler = (*BurnedRemoveRequest)(nil) +) + +// StableSize returns the size of x in protobuf format. +// +// Structures with the same field values have the same binary size. +func (x *BurnedRemoveRequest) StableSize() (size int) { + if x == nil { + return 0 + } + size += proto.NestedStructureSize(1, x.Body) + size += proto.NestedStructureSize(2, x.Signature) + return size +} + +// ReadSignedData fills buf with signed data of x. +// If buffer length is less than x.SignedDataSize(), new buffer is allocated. +// +// Returns any error encountered which did not allow writing the data completely. +// Otherwise, returns the buffer in which the data is written. +// +// Structures with the same field values have the same signed data. +func (x *BurnedRemoveRequest) SignedDataSize() int { + return x.GetBody().StableSize() +} + +// SignedDataSize returns size of the request signed data in bytes. +// +// Structures with the same field values have the same signed data size. +func (x *BurnedRemoveRequest) ReadSignedData(buf []byte) ([]byte, error) { + return x.GetBody().MarshalProtobuf(buf), nil +} + +// MarshalProtobuf implements the encoding.ProtoMarshaler interface. +func (x *BurnedRemoveRequest) MarshalProtobuf(dst []byte) []byte { + m := pool.MarshalerPool.Get() + defer pool.MarshalerPool.Put(m) + x.EmitProtobuf(m.MessageMarshaler()) + dst = m.Marshal(dst) + return dst +} + +func (x *BurnedRemoveRequest) EmitProtobuf(mm *easyproto.MessageMarshaler) { + if x == nil { + return + } + if x.Body != nil { + x.Body.EmitProtobuf(mm.AppendMessage(1)) + } + if x.Signature != nil { + x.Signature.EmitProtobuf(mm.AppendMessage(2)) + } +} + +// UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface. +func (x *BurnedRemoveRequest) UnmarshalProtobuf(src []byte) (err error) { + var fc easyproto.FieldContext + for len(src) > 0 { + src, err = fc.NextField(src) + if err != nil { + return fmt.Errorf("cannot read next field in %s", "BurnedRemoveRequest") + } + switch fc.FieldNum { + case 1: // Body + data, ok := fc.MessageData() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Body") + } + x.Body = new(BurnedRemoveRequest_Body) + if err := x.Body.UnmarshalProtobuf(data); err != nil { + return fmt.Errorf("unmarshal: %w", err) + } + case 2: // Signature + data, ok := fc.MessageData() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Signature") + } + x.Signature = new(Signature) + if err := x.Signature.UnmarshalProtobuf(data); err != nil { + return fmt.Errorf("unmarshal: %w", err) + } + } + } + return nil +} +func (x *BurnedRemoveRequest) GetBody() *BurnedRemoveRequest_Body { + if x != nil { + return x.Body + } + return nil +} +func (x *BurnedRemoveRequest) SetBody(v *BurnedRemoveRequest_Body) { + x.Body = v +} +func (x *BurnedRemoveRequest) GetSignature() *Signature { + if x != nil { + return x.Signature + } + return nil +} +func (x *BurnedRemoveRequest) SetSignature(v *Signature) { + x.Signature = v +} + +// MarshalJSON implements the json.Marshaler interface. +func (x *BurnedRemoveRequest) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + x.MarshalEasyJSON(&w) + return w.Buffer.BuildBytes(), w.Error +} +func (x *BurnedRemoveRequest) MarshalEasyJSON(out *jwriter.Writer) { + if x == nil { + out.RawString("null") + return + } + first := true + out.RawByte('{') + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" + out.RawString(prefix) + x.Signature.MarshalEasyJSON(out) + } + out.RawByte('}') +} + +// UnmarshalJSON implements the json.Unmarshaler interface. +func (x *BurnedRemoveRequest) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + x.UnmarshalEasyJSON(&r) + return r.Error() +} +func (x *BurnedRemoveRequest) UnmarshalEasyJSON(in *jlexer.Lexer) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "body": + { + var f *BurnedRemoveRequest_Body + f = new(BurnedRemoveRequest_Body) + f.UnmarshalEasyJSON(in) + x.Body = f + } + case "signature": + { + var f *Signature + f = new(Signature) + f.UnmarshalEasyJSON(in) + x.Signature = f + } + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} + +type BurnedRemoveResponse_Body struct { +} + +var ( + _ encoding.ProtoMarshaler = (*BurnedRemoveResponse_Body)(nil) + _ encoding.ProtoUnmarshaler = (*BurnedRemoveResponse_Body)(nil) + _ json.Marshaler = (*BurnedRemoveResponse_Body)(nil) + _ json.Unmarshaler = (*BurnedRemoveResponse_Body)(nil) +) + +// StableSize returns the size of x in protobuf format. +// +// Structures with the same field values have the same binary size. +func (x *BurnedRemoveResponse_Body) StableSize() (size int) { + if x == nil { + return 0 + } + return size +} + +// MarshalProtobuf implements the encoding.ProtoMarshaler interface. +func (x *BurnedRemoveResponse_Body) MarshalProtobuf(dst []byte) []byte { + m := pool.MarshalerPool.Get() + defer pool.MarshalerPool.Put(m) + x.EmitProtobuf(m.MessageMarshaler()) + dst = m.Marshal(dst) + return dst +} + +func (x *BurnedRemoveResponse_Body) EmitProtobuf(mm *easyproto.MessageMarshaler) { +} + +// UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface. +func (x *BurnedRemoveResponse_Body) UnmarshalProtobuf(src []byte) (err error) { + var fc easyproto.FieldContext + for len(src) > 0 { + src, err = fc.NextField(src) + if err != nil { + return fmt.Errorf("cannot read next field in %s", "BurnedRemoveResponse_Body") + } + switch fc.FieldNum { + } + } + return nil +} + +// MarshalJSON implements the json.Marshaler interface. +func (x *BurnedRemoveResponse_Body) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + x.MarshalEasyJSON(&w) + return w.Buffer.BuildBytes(), w.Error +} +func (x *BurnedRemoveResponse_Body) MarshalEasyJSON(out *jwriter.Writer) { + if x == nil { + out.RawString("null") + return + } + out.RawByte('{') + out.RawByte('}') +} + +// UnmarshalJSON implements the json.Unmarshaler interface. +func (x *BurnedRemoveResponse_Body) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + x.UnmarshalEasyJSON(&r) + return r.Error() +} +func (x *BurnedRemoveResponse_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} + +type BurnedRemoveResponse struct { + Body *BurnedRemoveResponse_Body `json:"body"` + Signature *Signature `json:"signature"` +} + +var ( + _ encoding.ProtoMarshaler = (*BurnedRemoveResponse)(nil) + _ encoding.ProtoUnmarshaler = (*BurnedRemoveResponse)(nil) + _ json.Marshaler = (*BurnedRemoveResponse)(nil) + _ json.Unmarshaler = (*BurnedRemoveResponse)(nil) +) + +// StableSize returns the size of x in protobuf format. +// +// Structures with the same field values have the same binary size. +func (x *BurnedRemoveResponse) StableSize() (size int) { + if x == nil { + return 0 + } + size += proto.NestedStructureSize(1, x.Body) + size += proto.NestedStructureSize(2, x.Signature) + return size +} + +// ReadSignedData fills buf with signed data of x. +// If buffer length is less than x.SignedDataSize(), new buffer is allocated. +// +// Returns any error encountered which did not allow writing the data completely. +// Otherwise, returns the buffer in which the data is written. +// +// Structures with the same field values have the same signed data. +func (x *BurnedRemoveResponse) SignedDataSize() int { + return x.GetBody().StableSize() +} + +// SignedDataSize returns size of the request signed data in bytes. +// +// Structures with the same field values have the same signed data size. +func (x *BurnedRemoveResponse) ReadSignedData(buf []byte) ([]byte, error) { + return x.GetBody().MarshalProtobuf(buf), nil +} + +// MarshalProtobuf implements the encoding.ProtoMarshaler interface. +func (x *BurnedRemoveResponse) MarshalProtobuf(dst []byte) []byte { + m := pool.MarshalerPool.Get() + defer pool.MarshalerPool.Put(m) + x.EmitProtobuf(m.MessageMarshaler()) + dst = m.Marshal(dst) + return dst +} + +func (x *BurnedRemoveResponse) EmitProtobuf(mm *easyproto.MessageMarshaler) { + if x == nil { + return + } + if x.Body != nil { + x.Body.EmitProtobuf(mm.AppendMessage(1)) + } + if x.Signature != nil { + x.Signature.EmitProtobuf(mm.AppendMessage(2)) + } +} + +// UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface. +func (x *BurnedRemoveResponse) UnmarshalProtobuf(src []byte) (err error) { + var fc easyproto.FieldContext + for len(src) > 0 { + src, err = fc.NextField(src) + if err != nil { + return fmt.Errorf("cannot read next field in %s", "BurnedRemoveResponse") + } + switch fc.FieldNum { + case 1: // Body + data, ok := fc.MessageData() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Body") + } + x.Body = new(BurnedRemoveResponse_Body) + if err := x.Body.UnmarshalProtobuf(data); err != nil { + return fmt.Errorf("unmarshal: %w", err) + } + case 2: // Signature + data, ok := fc.MessageData() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Signature") + } + x.Signature = new(Signature) + if err := x.Signature.UnmarshalProtobuf(data); err != nil { + return fmt.Errorf("unmarshal: %w", err) + } + } + } + return nil +} +func (x *BurnedRemoveResponse) GetBody() *BurnedRemoveResponse_Body { + if x != nil { + return x.Body + } + return nil +} +func (x *BurnedRemoveResponse) SetBody(v *BurnedRemoveResponse_Body) { + x.Body = v +} +func (x *BurnedRemoveResponse) GetSignature() *Signature { + if x != nil { + return x.Signature + } + return nil +} +func (x *BurnedRemoveResponse) SetSignature(v *Signature) { + x.Signature = v +} + +// MarshalJSON implements the json.Marshaler interface. +func (x *BurnedRemoveResponse) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + x.MarshalEasyJSON(&w) + return w.Buffer.BuildBytes(), w.Error +} +func (x *BurnedRemoveResponse) MarshalEasyJSON(out *jwriter.Writer) { + if x == nil { + out.RawString("null") + return + } + first := true + out.RawByte('{') + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" + out.RawString(prefix) + x.Signature.MarshalEasyJSON(out) + } + out.RawByte('}') +} + +// UnmarshalJSON implements the json.Unmarshaler interface. +func (x *BurnedRemoveResponse) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + x.UnmarshalEasyJSON(&r) + return r.Error() +} +func (x *BurnedRemoveResponse) UnmarshalEasyJSON(in *jlexer.Lexer) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "body": + { + var f *BurnedRemoveResponse_Body + f = new(BurnedRemoveResponse_Body) + f.UnmarshalEasyJSON(in) + x.Body = f + } + case "signature": + { + var f *Signature + f = new(Signature) + f.UnmarshalEasyJSON(in) + x.Signature = f + } + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} + +type BurnedApplyRequest_Body struct { + ContainerId []byte `json:"containerId"` + TreeId string `json:"treeId"` + Op []byte `json:"op"` +} + +var ( + _ encoding.ProtoMarshaler = (*BurnedApplyRequest_Body)(nil) + _ encoding.ProtoUnmarshaler = (*BurnedApplyRequest_Body)(nil) + _ json.Marshaler = (*BurnedApplyRequest_Body)(nil) + _ json.Unmarshaler = (*BurnedApplyRequest_Body)(nil) +) + +// StableSize returns the size of x in protobuf format. +// +// Structures with the same field values have the same binary size. +func (x *BurnedApplyRequest_Body) StableSize() (size int) { + if x == nil { + return 0 + } + size += proto.BytesSize(1, x.ContainerId) + size += proto.StringSize(2, x.TreeId) + size += proto.BytesSize(3, x.Op) + return size +} + +// MarshalProtobuf implements the encoding.ProtoMarshaler interface. +func (x *BurnedApplyRequest_Body) MarshalProtobuf(dst []byte) []byte { + m := pool.MarshalerPool.Get() + defer pool.MarshalerPool.Put(m) + x.EmitProtobuf(m.MessageMarshaler()) + dst = m.Marshal(dst) + return dst +} + +func (x *BurnedApplyRequest_Body) EmitProtobuf(mm *easyproto.MessageMarshaler) { + if x == nil { + return + } + if len(x.ContainerId) != 0 { + mm.AppendBytes(1, x.ContainerId) + } + if len(x.TreeId) != 0 { + mm.AppendString(2, x.TreeId) + } + if len(x.Op) != 0 { + mm.AppendBytes(3, x.Op) + } +} + +// UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface. +func (x *BurnedApplyRequest_Body) UnmarshalProtobuf(src []byte) (err error) { + var fc easyproto.FieldContext + for len(src) > 0 { + src, err = fc.NextField(src) + if err != nil { + return fmt.Errorf("cannot read next field in %s", "BurnedApplyRequest_Body") + } + switch fc.FieldNum { + case 1: // ContainerId + data, ok := fc.Bytes() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "ContainerId") + } + x.ContainerId = data + case 2: // TreeId + data, ok := fc.String() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "TreeId") + } + x.TreeId = data + case 3: // Op + data, ok := fc.Bytes() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Op") + } + x.Op = data + } + } + return nil +} +func (x *BurnedApplyRequest_Body) GetContainerId() []byte { + if x != nil { + return x.ContainerId + } + return nil +} +func (x *BurnedApplyRequest_Body) SetContainerId(v []byte) { + x.ContainerId = v +} +func (x *BurnedApplyRequest_Body) GetTreeId() string { + if x != nil { + return x.TreeId + } + return "" +} +func (x *BurnedApplyRequest_Body) SetTreeId(v string) { + x.TreeId = v +} +func (x *BurnedApplyRequest_Body) GetOp() []byte { + if x != nil { + return x.Op + } + return nil +} +func (x *BurnedApplyRequest_Body) SetOp(v []byte) { + x.Op = v +} + +// MarshalJSON implements the json.Marshaler interface. +func (x *BurnedApplyRequest_Body) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + x.MarshalEasyJSON(&w) + return w.Buffer.BuildBytes(), w.Error +} +func (x *BurnedApplyRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { + if x == nil { + out.RawString("null") + return + } + first := true + out.RawByte('{') + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"containerId\":" + out.RawString(prefix) + if x.ContainerId != nil { + out.Base64Bytes(x.ContainerId) + } else { + out.String("") + } + } + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"treeId\":" + out.RawString(prefix) + out.String(x.TreeId) + } + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"op\":" + out.RawString(prefix) + if x.Op != nil { + out.Base64Bytes(x.Op) + } else { + out.String("") + } + } + out.RawByte('}') +} + +// UnmarshalJSON implements the json.Unmarshaler interface. +func (x *BurnedApplyRequest_Body) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + x.UnmarshalEasyJSON(&r) + return r.Error() +} +func (x *BurnedApplyRequest_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "containerId": + { + var f []byte + { + tmp := in.Bytes() + if len(tmp) == 0 { + tmp = nil + } + f = tmp + } + x.ContainerId = f + } + case "treeId": + { + var f string + f = in.String() + x.TreeId = f + } + case "op": + { + var f []byte + { + tmp := in.Bytes() + if len(tmp) == 0 { + tmp = nil + } + f = tmp + } + x.Op = f + } + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} + +type BurnedApplyRequest struct { + Body *BurnedApplyRequest_Body `json:"body"` + Signature *Signature `json:"signature"` +} + +var ( + _ encoding.ProtoMarshaler = (*BurnedApplyRequest)(nil) + _ encoding.ProtoUnmarshaler = (*BurnedApplyRequest)(nil) + _ json.Marshaler = (*BurnedApplyRequest)(nil) + _ json.Unmarshaler = (*BurnedApplyRequest)(nil) +) + +// StableSize returns the size of x in protobuf format. +// +// Structures with the same field values have the same binary size. +func (x *BurnedApplyRequest) StableSize() (size int) { + if x == nil { + return 0 + } + size += proto.NestedStructureSize(1, x.Body) + size += proto.NestedStructureSize(2, x.Signature) + return size +} + +// ReadSignedData fills buf with signed data of x. +// If buffer length is less than x.SignedDataSize(), new buffer is allocated. +// +// Returns any error encountered which did not allow writing the data completely. +// Otherwise, returns the buffer in which the data is written. +// +// Structures with the same field values have the same signed data. +func (x *BurnedApplyRequest) SignedDataSize() int { + return x.GetBody().StableSize() +} + +// SignedDataSize returns size of the request signed data in bytes. +// +// Structures with the same field values have the same signed data size. +func (x *BurnedApplyRequest) ReadSignedData(buf []byte) ([]byte, error) { + return x.GetBody().MarshalProtobuf(buf), nil +} + +// MarshalProtobuf implements the encoding.ProtoMarshaler interface. +func (x *BurnedApplyRequest) MarshalProtobuf(dst []byte) []byte { + m := pool.MarshalerPool.Get() + defer pool.MarshalerPool.Put(m) + x.EmitProtobuf(m.MessageMarshaler()) + dst = m.Marshal(dst) + return dst +} + +func (x *BurnedApplyRequest) EmitProtobuf(mm *easyproto.MessageMarshaler) { + if x == nil { + return + } + if x.Body != nil { + x.Body.EmitProtobuf(mm.AppendMessage(1)) + } + if x.Signature != nil { + x.Signature.EmitProtobuf(mm.AppendMessage(2)) + } +} + +// UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface. +func (x *BurnedApplyRequest) UnmarshalProtobuf(src []byte) (err error) { + var fc easyproto.FieldContext + for len(src) > 0 { + src, err = fc.NextField(src) + if err != nil { + return fmt.Errorf("cannot read next field in %s", "BurnedApplyRequest") + } + switch fc.FieldNum { + case 1: // Body + data, ok := fc.MessageData() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Body") + } + x.Body = new(BurnedApplyRequest_Body) + if err := x.Body.UnmarshalProtobuf(data); err != nil { + return fmt.Errorf("unmarshal: %w", err) + } + case 2: // Signature + data, ok := fc.MessageData() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Signature") + } + x.Signature = new(Signature) + if err := x.Signature.UnmarshalProtobuf(data); err != nil { + return fmt.Errorf("unmarshal: %w", err) + } + } + } + return nil +} +func (x *BurnedApplyRequest) GetBody() *BurnedApplyRequest_Body { + if x != nil { + return x.Body + } + return nil +} +func (x *BurnedApplyRequest) SetBody(v *BurnedApplyRequest_Body) { + x.Body = v +} +func (x *BurnedApplyRequest) GetSignature() *Signature { + if x != nil { + return x.Signature + } + return nil +} +func (x *BurnedApplyRequest) SetSignature(v *Signature) { + x.Signature = v +} + +// MarshalJSON implements the json.Marshaler interface. +func (x *BurnedApplyRequest) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + x.MarshalEasyJSON(&w) + return w.Buffer.BuildBytes(), w.Error +} +func (x *BurnedApplyRequest) MarshalEasyJSON(out *jwriter.Writer) { + if x == nil { + out.RawString("null") + return + } + first := true + out.RawByte('{') + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" + out.RawString(prefix) + x.Signature.MarshalEasyJSON(out) + } + out.RawByte('}') +} + +// UnmarshalJSON implements the json.Unmarshaler interface. +func (x *BurnedApplyRequest) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + x.UnmarshalEasyJSON(&r) + return r.Error() +} +func (x *BurnedApplyRequest) UnmarshalEasyJSON(in *jlexer.Lexer) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "body": + { + var f *BurnedApplyRequest_Body + f = new(BurnedApplyRequest_Body) + f.UnmarshalEasyJSON(in) + x.Body = f + } + case "signature": + { + var f *Signature + f = new(Signature) + f.UnmarshalEasyJSON(in) + x.Signature = f + } + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} + +type BurnedApplyResponse_Body struct { +} + +var ( + _ encoding.ProtoMarshaler = (*BurnedApplyResponse_Body)(nil) + _ encoding.ProtoUnmarshaler = (*BurnedApplyResponse_Body)(nil) + _ json.Marshaler = (*BurnedApplyResponse_Body)(nil) + _ json.Unmarshaler = (*BurnedApplyResponse_Body)(nil) +) + +// StableSize returns the size of x in protobuf format. +// +// Structures with the same field values have the same binary size. +func (x *BurnedApplyResponse_Body) StableSize() (size int) { + if x == nil { + return 0 + } + return size +} + +// MarshalProtobuf implements the encoding.ProtoMarshaler interface. +func (x *BurnedApplyResponse_Body) MarshalProtobuf(dst []byte) []byte { + m := pool.MarshalerPool.Get() + defer pool.MarshalerPool.Put(m) + x.EmitProtobuf(m.MessageMarshaler()) + dst = m.Marshal(dst) + return dst +} + +func (x *BurnedApplyResponse_Body) EmitProtobuf(mm *easyproto.MessageMarshaler) { +} + +// UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface. +func (x *BurnedApplyResponse_Body) UnmarshalProtobuf(src []byte) (err error) { + var fc easyproto.FieldContext + for len(src) > 0 { + src, err = fc.NextField(src) + if err != nil { + return fmt.Errorf("cannot read next field in %s", "BurnedApplyResponse_Body") + } + switch fc.FieldNum { + } + } + return nil +} + +// MarshalJSON implements the json.Marshaler interface. +func (x *BurnedApplyResponse_Body) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + x.MarshalEasyJSON(&w) + return w.Buffer.BuildBytes(), w.Error +} +func (x *BurnedApplyResponse_Body) MarshalEasyJSON(out *jwriter.Writer) { + if x == nil { + out.RawString("null") + return + } + out.RawByte('{') + out.RawByte('}') +} + +// UnmarshalJSON implements the json.Unmarshaler interface. +func (x *BurnedApplyResponse_Body) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + x.UnmarshalEasyJSON(&r) + return r.Error() +} +func (x *BurnedApplyResponse_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} + +type BurnedApplyResponse struct { + Body *BurnedApplyResponse_Body `json:"body"` + Signature *Signature `json:"signature"` +} + +var ( + _ encoding.ProtoMarshaler = (*BurnedApplyResponse)(nil) + _ encoding.ProtoUnmarshaler = (*BurnedApplyResponse)(nil) + _ json.Marshaler = (*BurnedApplyResponse)(nil) + _ json.Unmarshaler = (*BurnedApplyResponse)(nil) +) + +// StableSize returns the size of x in protobuf format. +// +// Structures with the same field values have the same binary size. +func (x *BurnedApplyResponse) StableSize() (size int) { + if x == nil { + return 0 + } + size += proto.NestedStructureSize(1, x.Body) + size += proto.NestedStructureSize(2, x.Signature) + return size +} + +// ReadSignedData fills buf with signed data of x. +// If buffer length is less than x.SignedDataSize(), new buffer is allocated. +// +// Returns any error encountered which did not allow writing the data completely. +// Otherwise, returns the buffer in which the data is written. +// +// Structures with the same field values have the same signed data. +func (x *BurnedApplyResponse) SignedDataSize() int { + return x.GetBody().StableSize() +} + +// SignedDataSize returns size of the request signed data in bytes. +// +// Structures with the same field values have the same signed data size. +func (x *BurnedApplyResponse) ReadSignedData(buf []byte) ([]byte, error) { + return x.GetBody().MarshalProtobuf(buf), nil +} + +// MarshalProtobuf implements the encoding.ProtoMarshaler interface. +func (x *BurnedApplyResponse) MarshalProtobuf(dst []byte) []byte { + m := pool.MarshalerPool.Get() + defer pool.MarshalerPool.Put(m) + x.EmitProtobuf(m.MessageMarshaler()) + dst = m.Marshal(dst) + return dst +} + +func (x *BurnedApplyResponse) EmitProtobuf(mm *easyproto.MessageMarshaler) { + if x == nil { + return + } + if x.Body != nil { + x.Body.EmitProtobuf(mm.AppendMessage(1)) + } + if x.Signature != nil { + x.Signature.EmitProtobuf(mm.AppendMessage(2)) + } +} + +// UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface. +func (x *BurnedApplyResponse) UnmarshalProtobuf(src []byte) (err error) { + var fc easyproto.FieldContext + for len(src) > 0 { + src, err = fc.NextField(src) + if err != nil { + return fmt.Errorf("cannot read next field in %s", "BurnedApplyResponse") + } + switch fc.FieldNum { + case 1: // Body + data, ok := fc.MessageData() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Body") + } + x.Body = new(BurnedApplyResponse_Body) + if err := x.Body.UnmarshalProtobuf(data); err != nil { + return fmt.Errorf("unmarshal: %w", err) + } + case 2: // Signature + data, ok := fc.MessageData() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Signature") + } + x.Signature = new(Signature) + if err := x.Signature.UnmarshalProtobuf(data); err != nil { + return fmt.Errorf("unmarshal: %w", err) + } + } + } + return nil +} +func (x *BurnedApplyResponse) GetBody() *BurnedApplyResponse_Body { + if x != nil { + return x.Body + } + return nil +} +func (x *BurnedApplyResponse) SetBody(v *BurnedApplyResponse_Body) { + x.Body = v +} +func (x *BurnedApplyResponse) GetSignature() *Signature { + if x != nil { + return x.Signature + } + return nil +} +func (x *BurnedApplyResponse) SetSignature(v *Signature) { + x.Signature = v +} + +// MarshalJSON implements the json.Marshaler interface. +func (x *BurnedApplyResponse) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + x.MarshalEasyJSON(&w) + return w.Buffer.BuildBytes(), w.Error +} +func (x *BurnedApplyResponse) MarshalEasyJSON(out *jwriter.Writer) { + if x == nil { + out.RawString("null") + return + } + first := true + out.RawByte('{') + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" + out.RawString(prefix) + x.Signature.MarshalEasyJSON(out) + } + out.RawByte('}') +} + +// UnmarshalJSON implements the json.Unmarshaler interface. +func (x *BurnedApplyResponse) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + x.UnmarshalEasyJSON(&r) + return r.Error() +} +func (x *BurnedApplyResponse) UnmarshalEasyJSON(in *jlexer.Lexer) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "body": + { + var f *BurnedApplyResponse_Body + f = new(BurnedApplyResponse_Body) + f.UnmarshalEasyJSON(in) + x.Body = f + } + case "signature": + { + var f *Signature + f = new(Signature) + f.UnmarshalEasyJSON(in) + x.Signature = f + } + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} + +type BurnedGetRequest_Body struct { + ContainerId []byte `json:"containerId"` + TreeId string `json:"treeId"` + Key string `json:"key"` + BearerToken []byte `json:"bearerToken"` +} + +var ( + _ encoding.ProtoMarshaler = (*BurnedGetRequest_Body)(nil) + _ encoding.ProtoUnmarshaler = (*BurnedGetRequest_Body)(nil) + _ json.Marshaler = (*BurnedGetRequest_Body)(nil) + _ json.Unmarshaler = (*BurnedGetRequest_Body)(nil) +) + +// StableSize returns the size of x in protobuf format. +// +// Structures with the same field values have the same binary size. +func (x *BurnedGetRequest_Body) StableSize() (size int) { + if x == nil { + return 0 + } + size += proto.BytesSize(1, x.ContainerId) + size += proto.StringSize(2, x.TreeId) + size += proto.StringSize(3, x.Key) + size += proto.BytesSize(5, x.BearerToken) + return size +} + +// MarshalProtobuf implements the encoding.ProtoMarshaler interface. +func (x *BurnedGetRequest_Body) MarshalProtobuf(dst []byte) []byte { + m := pool.MarshalerPool.Get() + defer pool.MarshalerPool.Put(m) + x.EmitProtobuf(m.MessageMarshaler()) + dst = m.Marshal(dst) + return dst +} + +func (x *BurnedGetRequest_Body) EmitProtobuf(mm *easyproto.MessageMarshaler) { + if x == nil { + return + } + if len(x.ContainerId) != 0 { + mm.AppendBytes(1, x.ContainerId) + } + if len(x.TreeId) != 0 { + mm.AppendString(2, x.TreeId) + } + if len(x.Key) != 0 { + mm.AppendString(3, x.Key) + } + if len(x.BearerToken) != 0 { + mm.AppendBytes(5, x.BearerToken) + } +} + +// UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface. +func (x *BurnedGetRequest_Body) UnmarshalProtobuf(src []byte) (err error) { + var fc easyproto.FieldContext + for len(src) > 0 { + src, err = fc.NextField(src) + if err != nil { + return fmt.Errorf("cannot read next field in %s", "BurnedGetRequest_Body") + } + switch fc.FieldNum { + case 1: // ContainerId + data, ok := fc.Bytes() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "ContainerId") + } + x.ContainerId = data + case 2: // TreeId + data, ok := fc.String() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "TreeId") + } + x.TreeId = data + case 3: // Key + data, ok := fc.String() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Key") + } + x.Key = data + case 5: // BearerToken + data, ok := fc.Bytes() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "BearerToken") + } + x.BearerToken = data + } + } + return nil +} +func (x *BurnedGetRequest_Body) GetContainerId() []byte { + if x != nil { + return x.ContainerId + } + return nil +} +func (x *BurnedGetRequest_Body) SetContainerId(v []byte) { + x.ContainerId = v +} +func (x *BurnedGetRequest_Body) GetTreeId() string { + if x != nil { + return x.TreeId + } + return "" +} +func (x *BurnedGetRequest_Body) SetTreeId(v string) { + x.TreeId = v +} +func (x *BurnedGetRequest_Body) GetKey() string { + if x != nil { + return x.Key + } + return "" +} +func (x *BurnedGetRequest_Body) SetKey(v string) { + x.Key = v +} +func (x *BurnedGetRequest_Body) GetBearerToken() []byte { + if x != nil { + return x.BearerToken + } + return nil +} +func (x *BurnedGetRequest_Body) SetBearerToken(v []byte) { + x.BearerToken = v +} + +// MarshalJSON implements the json.Marshaler interface. +func (x *BurnedGetRequest_Body) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + x.MarshalEasyJSON(&w) + return w.Buffer.BuildBytes(), w.Error +} +func (x *BurnedGetRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { + if x == nil { + out.RawString("null") + return + } + first := true + out.RawByte('{') + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"containerId\":" + out.RawString(prefix) + if x.ContainerId != nil { + out.Base64Bytes(x.ContainerId) + } else { + out.String("") + } + } + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"treeId\":" + out.RawString(prefix) + out.String(x.TreeId) + } + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"key\":" + out.RawString(prefix) + out.String(x.Key) + } + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"bearerToken\":" + out.RawString(prefix) + if x.BearerToken != nil { + out.Base64Bytes(x.BearerToken) + } else { + out.String("") + } + } + out.RawByte('}') +} + +// UnmarshalJSON implements the json.Unmarshaler interface. +func (x *BurnedGetRequest_Body) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + x.UnmarshalEasyJSON(&r) + return r.Error() +} +func (x *BurnedGetRequest_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "containerId": + { + var f []byte + { + tmp := in.Bytes() + if len(tmp) == 0 { + tmp = nil + } + f = tmp + } + x.ContainerId = f + } + case "treeId": + { + var f string + f = in.String() + x.TreeId = f + } + case "key": + { + var f string + f = in.String() + x.Key = f + } + case "bearerToken": + { + var f []byte + { + tmp := in.Bytes() + if len(tmp) == 0 { + tmp = nil + } + f = tmp + } + x.BearerToken = f + } + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} + +type BurnedGetRequest struct { + Body *BurnedGetRequest_Body `json:"body"` + Signature *Signature `json:"signature"` +} + +var ( + _ encoding.ProtoMarshaler = (*BurnedGetRequest)(nil) + _ encoding.ProtoUnmarshaler = (*BurnedGetRequest)(nil) + _ json.Marshaler = (*BurnedGetRequest)(nil) + _ json.Unmarshaler = (*BurnedGetRequest)(nil) +) + +// StableSize returns the size of x in protobuf format. +// +// Structures with the same field values have the same binary size. +func (x *BurnedGetRequest) StableSize() (size int) { + if x == nil { + return 0 + } + size += proto.NestedStructureSize(1, x.Body) + size += proto.NestedStructureSize(2, x.Signature) + return size +} + +// ReadSignedData fills buf with signed data of x. +// If buffer length is less than x.SignedDataSize(), new buffer is allocated. +// +// Returns any error encountered which did not allow writing the data completely. +// Otherwise, returns the buffer in which the data is written. +// +// Structures with the same field values have the same signed data. +func (x *BurnedGetRequest) SignedDataSize() int { + return x.GetBody().StableSize() +} + +// SignedDataSize returns size of the request signed data in bytes. +// +// Structures with the same field values have the same signed data size. +func (x *BurnedGetRequest) ReadSignedData(buf []byte) ([]byte, error) { + return x.GetBody().MarshalProtobuf(buf), nil +} + +// MarshalProtobuf implements the encoding.ProtoMarshaler interface. +func (x *BurnedGetRequest) MarshalProtobuf(dst []byte) []byte { + m := pool.MarshalerPool.Get() + defer pool.MarshalerPool.Put(m) + x.EmitProtobuf(m.MessageMarshaler()) + dst = m.Marshal(dst) + return dst +} + +func (x *BurnedGetRequest) EmitProtobuf(mm *easyproto.MessageMarshaler) { + if x == nil { + return + } + if x.Body != nil { + x.Body.EmitProtobuf(mm.AppendMessage(1)) + } + if x.Signature != nil { + x.Signature.EmitProtobuf(mm.AppendMessage(2)) + } +} + +// UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface. +func (x *BurnedGetRequest) UnmarshalProtobuf(src []byte) (err error) { + var fc easyproto.FieldContext + for len(src) > 0 { + src, err = fc.NextField(src) + if err != nil { + return fmt.Errorf("cannot read next field in %s", "BurnedGetRequest") + } + switch fc.FieldNum { + case 1: // Body + data, ok := fc.MessageData() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Body") + } + x.Body = new(BurnedGetRequest_Body) + if err := x.Body.UnmarshalProtobuf(data); err != nil { + return fmt.Errorf("unmarshal: %w", err) + } + case 2: // Signature + data, ok := fc.MessageData() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Signature") + } + x.Signature = new(Signature) + if err := x.Signature.UnmarshalProtobuf(data); err != nil { + return fmt.Errorf("unmarshal: %w", err) + } + } + } + return nil +} +func (x *BurnedGetRequest) GetBody() *BurnedGetRequest_Body { + if x != nil { + return x.Body + } + return nil +} +func (x *BurnedGetRequest) SetBody(v *BurnedGetRequest_Body) { + x.Body = v +} +func (x *BurnedGetRequest) GetSignature() *Signature { + if x != nil { + return x.Signature + } + return nil +} +func (x *BurnedGetRequest) SetSignature(v *Signature) { + x.Signature = v +} + +// MarshalJSON implements the json.Marshaler interface. +func (x *BurnedGetRequest) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + x.MarshalEasyJSON(&w) + return w.Buffer.BuildBytes(), w.Error +} +func (x *BurnedGetRequest) MarshalEasyJSON(out *jwriter.Writer) { + if x == nil { + out.RawString("null") + return + } + first := true + out.RawByte('{') + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" + out.RawString(prefix) + x.Signature.MarshalEasyJSON(out) + } + out.RawByte('}') +} + +// UnmarshalJSON implements the json.Unmarshaler interface. +func (x *BurnedGetRequest) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + x.UnmarshalEasyJSON(&r) + return r.Error() +} +func (x *BurnedGetRequest) UnmarshalEasyJSON(in *jlexer.Lexer) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "body": + { + var f *BurnedGetRequest_Body + f = new(BurnedGetRequest_Body) + f.UnmarshalEasyJSON(in) + x.Body = f + } + case "signature": + { + var f *Signature + f = new(Signature) + f.UnmarshalEasyJSON(in) + x.Signature = f + } + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} + +type BurnedGetResponse_Body struct { + Timestamp uint64 `json:"timestamp"` + Meta []KeyValue `json:"meta"` +} + +var ( + _ encoding.ProtoMarshaler = (*BurnedGetResponse_Body)(nil) + _ encoding.ProtoUnmarshaler = (*BurnedGetResponse_Body)(nil) + _ json.Marshaler = (*BurnedGetResponse_Body)(nil) + _ json.Unmarshaler = (*BurnedGetResponse_Body)(nil) +) + +// StableSize returns the size of x in protobuf format. +// +// Structures with the same field values have the same binary size. +func (x *BurnedGetResponse_Body) StableSize() (size int) { + if x == nil { + return 0 + } + size += proto.UInt64Size(1, x.Timestamp) + for i := range x.Meta { + size += proto.NestedStructureSizeUnchecked(2, &x.Meta[i]) + } + return size +} + +// MarshalProtobuf implements the encoding.ProtoMarshaler interface. +func (x *BurnedGetResponse_Body) MarshalProtobuf(dst []byte) []byte { + m := pool.MarshalerPool.Get() + defer pool.MarshalerPool.Put(m) + x.EmitProtobuf(m.MessageMarshaler()) + dst = m.Marshal(dst) + return dst +} + +func (x *BurnedGetResponse_Body) EmitProtobuf(mm *easyproto.MessageMarshaler) { + if x == nil { + return + } + if x.Timestamp != 0 { + mm.AppendUint64(1, x.Timestamp) + } + for i := range x.Meta { + x.Meta[i].EmitProtobuf(mm.AppendMessage(2)) + } +} + +// UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface. +func (x *BurnedGetResponse_Body) UnmarshalProtobuf(src []byte) (err error) { + var fc easyproto.FieldContext + for len(src) > 0 { + src, err = fc.NextField(src) + if err != nil { + return fmt.Errorf("cannot read next field in %s", "BurnedGetResponse_Body") + } + switch fc.FieldNum { + case 1: // Timestamp + data, ok := fc.Uint64() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Timestamp") + } + x.Timestamp = data + case 2: // Meta + data, ok := fc.MessageData() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Meta") + } + x.Meta = append(x.Meta, KeyValue{}) + ff := &x.Meta[len(x.Meta)-1] + if err := ff.UnmarshalProtobuf(data); err != nil { + return fmt.Errorf("unmarshal: %w", err) + } + } + } + return nil +} +func (x *BurnedGetResponse_Body) GetTimestamp() uint64 { + if x != nil { + return x.Timestamp + } + return 0 +} +func (x *BurnedGetResponse_Body) SetTimestamp(v uint64) { + x.Timestamp = v +} +func (x *BurnedGetResponse_Body) GetMeta() []KeyValue { + if x != nil { + return x.Meta + } + return nil +} +func (x *BurnedGetResponse_Body) SetMeta(v []KeyValue) { + x.Meta = v +} + +// MarshalJSON implements the json.Marshaler interface. +func (x *BurnedGetResponse_Body) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + x.MarshalEasyJSON(&w) + return w.Buffer.BuildBytes(), w.Error +} +func (x *BurnedGetResponse_Body) MarshalEasyJSON(out *jwriter.Writer) { + if x == nil { + out.RawString("null") + return + } + first := true + out.RawByte('{') + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"timestamp\":" + out.RawString(prefix) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.Timestamp, 10) + out.RawByte('"') + } + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"meta\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.Meta { + if i != 0 { + out.RawByte(',') + } + x.Meta[i].MarshalEasyJSON(out) + } + out.RawByte(']') + } + out.RawByte('}') +} + +// UnmarshalJSON implements the json.Unmarshaler interface. +func (x *BurnedGetResponse_Body) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + x.UnmarshalEasyJSON(&r) + return r.Error() +} +func (x *BurnedGetResponse_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "timestamp": + { + var f uint64 + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv + x.Timestamp = f + } + case "meta": + { + var f KeyValue + var list []KeyValue + in.Delim('[') + for !in.IsDelim(']') { + f = KeyValue{} + f.UnmarshalEasyJSON(in) + list = append(list, f) + in.WantComma() + } + x.Meta = list + in.Delim(']') + } + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} + +type BurnedGetResponse struct { + Body *BurnedGetResponse_Body `json:"body"` + Signature *Signature `json:"signature"` +} + +var ( + _ encoding.ProtoMarshaler = (*BurnedGetResponse)(nil) + _ encoding.ProtoUnmarshaler = (*BurnedGetResponse)(nil) + _ json.Marshaler = (*BurnedGetResponse)(nil) + _ json.Unmarshaler = (*BurnedGetResponse)(nil) +) + +// StableSize returns the size of x in protobuf format. +// +// Structures with the same field values have the same binary size. +func (x *BurnedGetResponse) StableSize() (size int) { + if x == nil { + return 0 + } + size += proto.NestedStructureSize(1, x.Body) + size += proto.NestedStructureSize(2, x.Signature) + return size +} + +// ReadSignedData fills buf with signed data of x. +// If buffer length is less than x.SignedDataSize(), new buffer is allocated. +// +// Returns any error encountered which did not allow writing the data completely. +// Otherwise, returns the buffer in which the data is written. +// +// Structures with the same field values have the same signed data. +func (x *BurnedGetResponse) SignedDataSize() int { + return x.GetBody().StableSize() +} + +// SignedDataSize returns size of the request signed data in bytes. +// +// Structures with the same field values have the same signed data size. +func (x *BurnedGetResponse) ReadSignedData(buf []byte) ([]byte, error) { + return x.GetBody().MarshalProtobuf(buf), nil +} + +// MarshalProtobuf implements the encoding.ProtoMarshaler interface. +func (x *BurnedGetResponse) MarshalProtobuf(dst []byte) []byte { + m := pool.MarshalerPool.Get() + defer pool.MarshalerPool.Put(m) + x.EmitProtobuf(m.MessageMarshaler()) + dst = m.Marshal(dst) + return dst +} + +func (x *BurnedGetResponse) EmitProtobuf(mm *easyproto.MessageMarshaler) { + if x == nil { + return + } + if x.Body != nil { + x.Body.EmitProtobuf(mm.AppendMessage(1)) + } + if x.Signature != nil { + x.Signature.EmitProtobuf(mm.AppendMessage(2)) + } +} + +// UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface. +func (x *BurnedGetResponse) UnmarshalProtobuf(src []byte) (err error) { + var fc easyproto.FieldContext + for len(src) > 0 { + src, err = fc.NextField(src) + if err != nil { + return fmt.Errorf("cannot read next field in %s", "BurnedGetResponse") + } + switch fc.FieldNum { + case 1: // Body + data, ok := fc.MessageData() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Body") + } + x.Body = new(BurnedGetResponse_Body) + if err := x.Body.UnmarshalProtobuf(data); err != nil { + return fmt.Errorf("unmarshal: %w", err) + } + case 2: // Signature + data, ok := fc.MessageData() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Signature") + } + x.Signature = new(Signature) + if err := x.Signature.UnmarshalProtobuf(data); err != nil { + return fmt.Errorf("unmarshal: %w", err) + } + } + } + return nil +} +func (x *BurnedGetResponse) GetBody() *BurnedGetResponse_Body { + if x != nil { + return x.Body + } + return nil +} +func (x *BurnedGetResponse) SetBody(v *BurnedGetResponse_Body) { + x.Body = v +} +func (x *BurnedGetResponse) GetSignature() *Signature { + if x != nil { + return x.Signature + } + return nil +} +func (x *BurnedGetResponse) SetSignature(v *Signature) { + x.Signature = v +} + +// MarshalJSON implements the json.Marshaler interface. +func (x *BurnedGetResponse) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + x.MarshalEasyJSON(&w) + return w.Buffer.BuildBytes(), w.Error +} +func (x *BurnedGetResponse) MarshalEasyJSON(out *jwriter.Writer) { + if x == nil { + out.RawString("null") + return + } + first := true + out.RawByte('{') + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" + out.RawString(prefix) + x.Signature.MarshalEasyJSON(out) + } + out.RawByte('}') +} + +// UnmarshalJSON implements the json.Unmarshaler interface. +func (x *BurnedGetResponse) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + x.UnmarshalEasyJSON(&r) + return r.Error() +} +func (x *BurnedGetResponse) UnmarshalEasyJSON(in *jlexer.Lexer) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "body": + { + var f *BurnedGetResponse_Body + f = new(BurnedGetResponse_Body) + f.UnmarshalEasyJSON(in) + x.Body = f + } + case "signature": + { + var f *Signature + f = new(Signature) + f.UnmarshalEasyJSON(in) + x.Signature = f + } + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} + +type BurnedGetLatestByPrefixRequest_Body struct { + ContainerId []byte `json:"containerId"` + TreeId string `json:"treeId"` + Prefix string `json:"prefix"` + BearerToken []byte `json:"bearerToken"` +} + +var ( + _ encoding.ProtoMarshaler = (*BurnedGetLatestByPrefixRequest_Body)(nil) + _ encoding.ProtoUnmarshaler = (*BurnedGetLatestByPrefixRequest_Body)(nil) + _ json.Marshaler = (*BurnedGetLatestByPrefixRequest_Body)(nil) + _ json.Unmarshaler = (*BurnedGetLatestByPrefixRequest_Body)(nil) +) + +// StableSize returns the size of x in protobuf format. +// +// Structures with the same field values have the same binary size. +func (x *BurnedGetLatestByPrefixRequest_Body) StableSize() (size int) { + if x == nil { + return 0 + } + size += proto.BytesSize(1, x.ContainerId) + size += proto.StringSize(2, x.TreeId) + size += proto.StringSize(3, x.Prefix) + size += proto.BytesSize(5, x.BearerToken) + return size +} + +// MarshalProtobuf implements the encoding.ProtoMarshaler interface. +func (x *BurnedGetLatestByPrefixRequest_Body) MarshalProtobuf(dst []byte) []byte { + m := pool.MarshalerPool.Get() + defer pool.MarshalerPool.Put(m) + x.EmitProtobuf(m.MessageMarshaler()) + dst = m.Marshal(dst) + return dst +} + +func (x *BurnedGetLatestByPrefixRequest_Body) EmitProtobuf(mm *easyproto.MessageMarshaler) { + if x == nil { + return + } + if len(x.ContainerId) != 0 { + mm.AppendBytes(1, x.ContainerId) + } + if len(x.TreeId) != 0 { + mm.AppendString(2, x.TreeId) + } + if len(x.Prefix) != 0 { + mm.AppendString(3, x.Prefix) + } + if len(x.BearerToken) != 0 { + mm.AppendBytes(5, x.BearerToken) + } +} + +// UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface. +func (x *BurnedGetLatestByPrefixRequest_Body) UnmarshalProtobuf(src []byte) (err error) { + var fc easyproto.FieldContext + for len(src) > 0 { + src, err = fc.NextField(src) + if err != nil { + return fmt.Errorf("cannot read next field in %s", "BurnedGetLatestByPrefixRequest_Body") + } + switch fc.FieldNum { + case 1: // ContainerId + data, ok := fc.Bytes() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "ContainerId") + } + x.ContainerId = data + case 2: // TreeId + data, ok := fc.String() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "TreeId") + } + x.TreeId = data + case 3: // Prefix + data, ok := fc.String() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Prefix") + } + x.Prefix = data + case 5: // BearerToken + data, ok := fc.Bytes() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "BearerToken") + } + x.BearerToken = data + } + } + return nil +} +func (x *BurnedGetLatestByPrefixRequest_Body) GetContainerId() []byte { + if x != nil { + return x.ContainerId + } + return nil +} +func (x *BurnedGetLatestByPrefixRequest_Body) SetContainerId(v []byte) { + x.ContainerId = v +} +func (x *BurnedGetLatestByPrefixRequest_Body) GetTreeId() string { + if x != nil { + return x.TreeId + } + return "" +} +func (x *BurnedGetLatestByPrefixRequest_Body) SetTreeId(v string) { + x.TreeId = v +} +func (x *BurnedGetLatestByPrefixRequest_Body) GetPrefix() string { + if x != nil { + return x.Prefix + } + return "" +} +func (x *BurnedGetLatestByPrefixRequest_Body) SetPrefix(v string) { + x.Prefix = v +} +func (x *BurnedGetLatestByPrefixRequest_Body) GetBearerToken() []byte { + if x != nil { + return x.BearerToken + } + return nil +} +func (x *BurnedGetLatestByPrefixRequest_Body) SetBearerToken(v []byte) { + x.BearerToken = v +} + +// MarshalJSON implements the json.Marshaler interface. +func (x *BurnedGetLatestByPrefixRequest_Body) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + x.MarshalEasyJSON(&w) + return w.Buffer.BuildBytes(), w.Error +} +func (x *BurnedGetLatestByPrefixRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { + if x == nil { + out.RawString("null") + return + } + first := true + out.RawByte('{') + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"containerId\":" + out.RawString(prefix) + if x.ContainerId != nil { + out.Base64Bytes(x.ContainerId) + } else { + out.String("") + } + } + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"treeId\":" + out.RawString(prefix) + out.String(x.TreeId) + } + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"prefix\":" + out.RawString(prefix) + out.String(x.Prefix) + } + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"bearerToken\":" + out.RawString(prefix) + if x.BearerToken != nil { + out.Base64Bytes(x.BearerToken) + } else { + out.String("") + } + } + out.RawByte('}') +} + +// UnmarshalJSON implements the json.Unmarshaler interface. +func (x *BurnedGetLatestByPrefixRequest_Body) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + x.UnmarshalEasyJSON(&r) + return r.Error() +} +func (x *BurnedGetLatestByPrefixRequest_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "containerId": + { + var f []byte + { + tmp := in.Bytes() + if len(tmp) == 0 { + tmp = nil + } + f = tmp + } + x.ContainerId = f + } + case "treeId": + { + var f string + f = in.String() + x.TreeId = f + } + case "prefix": + { + var f string + f = in.String() + x.Prefix = f + } + case "bearerToken": + { + var f []byte + { + tmp := in.Bytes() + if len(tmp) == 0 { + tmp = nil + } + f = tmp + } + x.BearerToken = f + } + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} + +type BurnedGetLatestByPrefixRequest struct { + Body *BurnedGetLatestByPrefixRequest_Body `json:"body"` + Signature *Signature `json:"signature"` +} + +var ( + _ encoding.ProtoMarshaler = (*BurnedGetLatestByPrefixRequest)(nil) + _ encoding.ProtoUnmarshaler = (*BurnedGetLatestByPrefixRequest)(nil) + _ json.Marshaler = (*BurnedGetLatestByPrefixRequest)(nil) + _ json.Unmarshaler = (*BurnedGetLatestByPrefixRequest)(nil) +) + +// StableSize returns the size of x in protobuf format. +// +// Structures with the same field values have the same binary size. +func (x *BurnedGetLatestByPrefixRequest) StableSize() (size int) { + if x == nil { + return 0 + } + size += proto.NestedStructureSize(1, x.Body) + size += proto.NestedStructureSize(2, x.Signature) + return size +} + +// ReadSignedData fills buf with signed data of x. +// If buffer length is less than x.SignedDataSize(), new buffer is allocated. +// +// Returns any error encountered which did not allow writing the data completely. +// Otherwise, returns the buffer in which the data is written. +// +// Structures with the same field values have the same signed data. +func (x *BurnedGetLatestByPrefixRequest) SignedDataSize() int { + return x.GetBody().StableSize() +} + +// SignedDataSize returns size of the request signed data in bytes. +// +// Structures with the same field values have the same signed data size. +func (x *BurnedGetLatestByPrefixRequest) ReadSignedData(buf []byte) ([]byte, error) { + return x.GetBody().MarshalProtobuf(buf), nil +} + +// MarshalProtobuf implements the encoding.ProtoMarshaler interface. +func (x *BurnedGetLatestByPrefixRequest) MarshalProtobuf(dst []byte) []byte { + m := pool.MarshalerPool.Get() + defer pool.MarshalerPool.Put(m) + x.EmitProtobuf(m.MessageMarshaler()) + dst = m.Marshal(dst) + return dst +} + +func (x *BurnedGetLatestByPrefixRequest) EmitProtobuf(mm *easyproto.MessageMarshaler) { + if x == nil { + return + } + if x.Body != nil { + x.Body.EmitProtobuf(mm.AppendMessage(1)) + } + if x.Signature != nil { + x.Signature.EmitProtobuf(mm.AppendMessage(2)) + } +} + +// UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface. +func (x *BurnedGetLatestByPrefixRequest) UnmarshalProtobuf(src []byte) (err error) { + var fc easyproto.FieldContext + for len(src) > 0 { + src, err = fc.NextField(src) + if err != nil { + return fmt.Errorf("cannot read next field in %s", "BurnedGetLatestByPrefixRequest") + } + switch fc.FieldNum { + case 1: // Body + data, ok := fc.MessageData() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Body") + } + x.Body = new(BurnedGetLatestByPrefixRequest_Body) + if err := x.Body.UnmarshalProtobuf(data); err != nil { + return fmt.Errorf("unmarshal: %w", err) + } + case 2: // Signature + data, ok := fc.MessageData() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Signature") + } + x.Signature = new(Signature) + if err := x.Signature.UnmarshalProtobuf(data); err != nil { + return fmt.Errorf("unmarshal: %w", err) + } + } + } + return nil +} +func (x *BurnedGetLatestByPrefixRequest) GetBody() *BurnedGetLatestByPrefixRequest_Body { + if x != nil { + return x.Body + } + return nil +} +func (x *BurnedGetLatestByPrefixRequest) SetBody(v *BurnedGetLatestByPrefixRequest_Body) { + x.Body = v +} +func (x *BurnedGetLatestByPrefixRequest) GetSignature() *Signature { + if x != nil { + return x.Signature + } + return nil +} +func (x *BurnedGetLatestByPrefixRequest) SetSignature(v *Signature) { + x.Signature = v +} + +// MarshalJSON implements the json.Marshaler interface. +func (x *BurnedGetLatestByPrefixRequest) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + x.MarshalEasyJSON(&w) + return w.Buffer.BuildBytes(), w.Error +} +func (x *BurnedGetLatestByPrefixRequest) MarshalEasyJSON(out *jwriter.Writer) { + if x == nil { + out.RawString("null") + return + } + first := true + out.RawByte('{') + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" + out.RawString(prefix) + x.Signature.MarshalEasyJSON(out) + } + out.RawByte('}') +} + +// UnmarshalJSON implements the json.Unmarshaler interface. +func (x *BurnedGetLatestByPrefixRequest) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + x.UnmarshalEasyJSON(&r) + return r.Error() +} +func (x *BurnedGetLatestByPrefixRequest) UnmarshalEasyJSON(in *jlexer.Lexer) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "body": + { + var f *BurnedGetLatestByPrefixRequest_Body + f = new(BurnedGetLatestByPrefixRequest_Body) + f.UnmarshalEasyJSON(in) + x.Body = f + } + case "signature": + { + var f *Signature + f = new(Signature) + f.UnmarshalEasyJSON(in) + x.Signature = f + } + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} + +type BurnedGetLatestByPrefixResponse_Body struct { + Key string `json:"key"` + Timestamp uint64 `json:"timestamp"` + Meta []KeyValue `json:"meta"` +} + +var ( + _ encoding.ProtoMarshaler = (*BurnedGetLatestByPrefixResponse_Body)(nil) + _ encoding.ProtoUnmarshaler = (*BurnedGetLatestByPrefixResponse_Body)(nil) + _ json.Marshaler = (*BurnedGetLatestByPrefixResponse_Body)(nil) + _ json.Unmarshaler = (*BurnedGetLatestByPrefixResponse_Body)(nil) +) + +// StableSize returns the size of x in protobuf format. +// +// Structures with the same field values have the same binary size. +func (x *BurnedGetLatestByPrefixResponse_Body) StableSize() (size int) { + if x == nil { + return 0 + } + size += proto.StringSize(1, x.Key) + size += proto.UInt64Size(2, x.Timestamp) + for i := range x.Meta { + size += proto.NestedStructureSizeUnchecked(3, &x.Meta[i]) + } + return size +} + +// MarshalProtobuf implements the encoding.ProtoMarshaler interface. +func (x *BurnedGetLatestByPrefixResponse_Body) MarshalProtobuf(dst []byte) []byte { + m := pool.MarshalerPool.Get() + defer pool.MarshalerPool.Put(m) + x.EmitProtobuf(m.MessageMarshaler()) + dst = m.Marshal(dst) + return dst +} + +func (x *BurnedGetLatestByPrefixResponse_Body) EmitProtobuf(mm *easyproto.MessageMarshaler) { + if x == nil { + return + } + if len(x.Key) != 0 { + mm.AppendString(1, x.Key) + } + if x.Timestamp != 0 { + mm.AppendUint64(2, x.Timestamp) + } + for i := range x.Meta { + x.Meta[i].EmitProtobuf(mm.AppendMessage(3)) + } +} + +// UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface. +func (x *BurnedGetLatestByPrefixResponse_Body) UnmarshalProtobuf(src []byte) (err error) { + var fc easyproto.FieldContext + for len(src) > 0 { + src, err = fc.NextField(src) + if err != nil { + return fmt.Errorf("cannot read next field in %s", "BurnedGetLatestByPrefixResponse_Body") + } + switch fc.FieldNum { + case 1: // Key + data, ok := fc.String() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Key") + } + x.Key = data + case 2: // Timestamp + data, ok := fc.Uint64() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Timestamp") + } + x.Timestamp = data + case 3: // Meta + data, ok := fc.MessageData() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Meta") + } + x.Meta = append(x.Meta, KeyValue{}) + ff := &x.Meta[len(x.Meta)-1] + if err := ff.UnmarshalProtobuf(data); err != nil { + return fmt.Errorf("unmarshal: %w", err) + } + } + } + return nil +} +func (x *BurnedGetLatestByPrefixResponse_Body) GetKey() string { + if x != nil { + return x.Key + } + return "" +} +func (x *BurnedGetLatestByPrefixResponse_Body) SetKey(v string) { + x.Key = v +} +func (x *BurnedGetLatestByPrefixResponse_Body) GetTimestamp() uint64 { + if x != nil { + return x.Timestamp + } + return 0 +} +func (x *BurnedGetLatestByPrefixResponse_Body) SetTimestamp(v uint64) { + x.Timestamp = v +} +func (x *BurnedGetLatestByPrefixResponse_Body) GetMeta() []KeyValue { + if x != nil { + return x.Meta + } + return nil +} +func (x *BurnedGetLatestByPrefixResponse_Body) SetMeta(v []KeyValue) { + x.Meta = v +} + +// MarshalJSON implements the json.Marshaler interface. +func (x *BurnedGetLatestByPrefixResponse_Body) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + x.MarshalEasyJSON(&w) + return w.Buffer.BuildBytes(), w.Error +} +func (x *BurnedGetLatestByPrefixResponse_Body) MarshalEasyJSON(out *jwriter.Writer) { + if x == nil { + out.RawString("null") + return + } + first := true + out.RawByte('{') + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"key\":" + out.RawString(prefix) + out.String(x.Key) + } + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"timestamp\":" + out.RawString(prefix) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.Timestamp, 10) + out.RawByte('"') + } + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"meta\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.Meta { + if i != 0 { + out.RawByte(',') + } + x.Meta[i].MarshalEasyJSON(out) + } + out.RawByte(']') + } + out.RawByte('}') +} + +// UnmarshalJSON implements the json.Unmarshaler interface. +func (x *BurnedGetLatestByPrefixResponse_Body) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + x.UnmarshalEasyJSON(&r) + return r.Error() +} +func (x *BurnedGetLatestByPrefixResponse_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "key": + { + var f string + f = in.String() + x.Key = f + } + case "timestamp": + { + var f uint64 + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv + x.Timestamp = f + } + case "meta": + { + var f KeyValue + var list []KeyValue + in.Delim('[') + for !in.IsDelim(']') { + f = KeyValue{} + f.UnmarshalEasyJSON(in) + list = append(list, f) + in.WantComma() + } + x.Meta = list + in.Delim(']') + } + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} + +type BurnedGetLatestByPrefixResponse struct { + Body *BurnedGetLatestByPrefixResponse_Body `json:"body"` + Signature *Signature `json:"signature"` +} + +var ( + _ encoding.ProtoMarshaler = (*BurnedGetLatestByPrefixResponse)(nil) + _ encoding.ProtoUnmarshaler = (*BurnedGetLatestByPrefixResponse)(nil) + _ json.Marshaler = (*BurnedGetLatestByPrefixResponse)(nil) + _ json.Unmarshaler = (*BurnedGetLatestByPrefixResponse)(nil) +) + +// StableSize returns the size of x in protobuf format. +// +// Structures with the same field values have the same binary size. +func (x *BurnedGetLatestByPrefixResponse) StableSize() (size int) { + if x == nil { + return 0 + } + size += proto.NestedStructureSize(1, x.Body) + size += proto.NestedStructureSize(2, x.Signature) + return size +} + +// ReadSignedData fills buf with signed data of x. +// If buffer length is less than x.SignedDataSize(), new buffer is allocated. +// +// Returns any error encountered which did not allow writing the data completely. +// Otherwise, returns the buffer in which the data is written. +// +// Structures with the same field values have the same signed data. +func (x *BurnedGetLatestByPrefixResponse) SignedDataSize() int { + return x.GetBody().StableSize() +} + +// SignedDataSize returns size of the request signed data in bytes. +// +// Structures with the same field values have the same signed data size. +func (x *BurnedGetLatestByPrefixResponse) ReadSignedData(buf []byte) ([]byte, error) { + return x.GetBody().MarshalProtobuf(buf), nil +} + +// MarshalProtobuf implements the encoding.ProtoMarshaler interface. +func (x *BurnedGetLatestByPrefixResponse) MarshalProtobuf(dst []byte) []byte { + m := pool.MarshalerPool.Get() + defer pool.MarshalerPool.Put(m) + x.EmitProtobuf(m.MessageMarshaler()) + dst = m.Marshal(dst) + return dst +} + +func (x *BurnedGetLatestByPrefixResponse) EmitProtobuf(mm *easyproto.MessageMarshaler) { + if x == nil { + return + } + if x.Body != nil { + x.Body.EmitProtobuf(mm.AppendMessage(1)) + } + if x.Signature != nil { + x.Signature.EmitProtobuf(mm.AppendMessage(2)) + } +} + +// UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface. +func (x *BurnedGetLatestByPrefixResponse) UnmarshalProtobuf(src []byte) (err error) { + var fc easyproto.FieldContext + for len(src) > 0 { + src, err = fc.NextField(src) + if err != nil { + return fmt.Errorf("cannot read next field in %s", "BurnedGetLatestByPrefixResponse") + } + switch fc.FieldNum { + case 1: // Body + data, ok := fc.MessageData() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Body") + } + x.Body = new(BurnedGetLatestByPrefixResponse_Body) + if err := x.Body.UnmarshalProtobuf(data); err != nil { + return fmt.Errorf("unmarshal: %w", err) + } + case 2: // Signature + data, ok := fc.MessageData() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Signature") + } + x.Signature = new(Signature) + if err := x.Signature.UnmarshalProtobuf(data); err != nil { + return fmt.Errorf("unmarshal: %w", err) + } + } + } + return nil +} +func (x *BurnedGetLatestByPrefixResponse) GetBody() *BurnedGetLatestByPrefixResponse_Body { + if x != nil { + return x.Body + } + return nil +} +func (x *BurnedGetLatestByPrefixResponse) SetBody(v *BurnedGetLatestByPrefixResponse_Body) { + x.Body = v +} +func (x *BurnedGetLatestByPrefixResponse) GetSignature() *Signature { + if x != nil { + return x.Signature + } + return nil +} +func (x *BurnedGetLatestByPrefixResponse) SetSignature(v *Signature) { + x.Signature = v +} + +// MarshalJSON implements the json.Marshaler interface. +func (x *BurnedGetLatestByPrefixResponse) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + x.MarshalEasyJSON(&w) + return w.Buffer.BuildBytes(), w.Error +} +func (x *BurnedGetLatestByPrefixResponse) MarshalEasyJSON(out *jwriter.Writer) { + if x == nil { + out.RawString("null") + return + } + first := true + out.RawByte('{') + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" + out.RawString(prefix) + x.Signature.MarshalEasyJSON(out) + } + out.RawByte('}') +} + +// UnmarshalJSON implements the json.Unmarshaler interface. +func (x *BurnedGetLatestByPrefixResponse) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + x.UnmarshalEasyJSON(&r) + return r.Error() +} +func (x *BurnedGetLatestByPrefixResponse) UnmarshalEasyJSON(in *jlexer.Lexer) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "body": + { + var f *BurnedGetLatestByPrefixResponse_Body + f = new(BurnedGetLatestByPrefixResponse_Body) + f.UnmarshalEasyJSON(in) + x.Body = f + } + case "signature": + { + var f *Signature + f = new(Signature) + f.UnmarshalEasyJSON(in) + x.Signature = f + } + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} + +type BurnedListByPrefixRequest_Body struct { + ContainerId []byte `json:"containerId"` + TreeId string `json:"treeId"` + Key string `json:"key"` +} + +var ( + _ encoding.ProtoMarshaler = (*BurnedListByPrefixRequest_Body)(nil) + _ encoding.ProtoUnmarshaler = (*BurnedListByPrefixRequest_Body)(nil) + _ json.Marshaler = (*BurnedListByPrefixRequest_Body)(nil) + _ json.Unmarshaler = (*BurnedListByPrefixRequest_Body)(nil) +) + +// StableSize returns the size of x in protobuf format. +// +// Structures with the same field values have the same binary size. +func (x *BurnedListByPrefixRequest_Body) StableSize() (size int) { + if x == nil { + return 0 + } + size += proto.BytesSize(1, x.ContainerId) + size += proto.StringSize(2, x.TreeId) + size += proto.StringSize(3, x.Key) + return size +} + +// MarshalProtobuf implements the encoding.ProtoMarshaler interface. +func (x *BurnedListByPrefixRequest_Body) MarshalProtobuf(dst []byte) []byte { + m := pool.MarshalerPool.Get() + defer pool.MarshalerPool.Put(m) + x.EmitProtobuf(m.MessageMarshaler()) + dst = m.Marshal(dst) + return dst +} + +func (x *BurnedListByPrefixRequest_Body) EmitProtobuf(mm *easyproto.MessageMarshaler) { + if x == nil { + return + } + if len(x.ContainerId) != 0 { + mm.AppendBytes(1, x.ContainerId) + } + if len(x.TreeId) != 0 { + mm.AppendString(2, x.TreeId) + } + if len(x.Key) != 0 { + mm.AppendString(3, x.Key) + } +} + +// UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface. +func (x *BurnedListByPrefixRequest_Body) UnmarshalProtobuf(src []byte) (err error) { + var fc easyproto.FieldContext + for len(src) > 0 { + src, err = fc.NextField(src) + if err != nil { + return fmt.Errorf("cannot read next field in %s", "BurnedListByPrefixRequest_Body") + } + switch fc.FieldNum { + case 1: // ContainerId + data, ok := fc.Bytes() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "ContainerId") + } + x.ContainerId = data + case 2: // TreeId + data, ok := fc.String() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "TreeId") + } + x.TreeId = data + case 3: // Key + data, ok := fc.String() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Key") + } + x.Key = data + } + } + return nil +} +func (x *BurnedListByPrefixRequest_Body) GetContainerId() []byte { + if x != nil { + return x.ContainerId + } + return nil +} +func (x *BurnedListByPrefixRequest_Body) SetContainerId(v []byte) { + x.ContainerId = v +} +func (x *BurnedListByPrefixRequest_Body) GetTreeId() string { + if x != nil { + return x.TreeId + } + return "" +} +func (x *BurnedListByPrefixRequest_Body) SetTreeId(v string) { + x.TreeId = v +} +func (x *BurnedListByPrefixRequest_Body) GetKey() string { + if x != nil { + return x.Key + } + return "" +} +func (x *BurnedListByPrefixRequest_Body) SetKey(v string) { + x.Key = v +} + +// MarshalJSON implements the json.Marshaler interface. +func (x *BurnedListByPrefixRequest_Body) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + x.MarshalEasyJSON(&w) + return w.Buffer.BuildBytes(), w.Error +} +func (x *BurnedListByPrefixRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { + if x == nil { + out.RawString("null") + return + } + first := true + out.RawByte('{') + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"containerId\":" + out.RawString(prefix) + if x.ContainerId != nil { + out.Base64Bytes(x.ContainerId) + } else { + out.String("") + } + } + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"treeId\":" + out.RawString(prefix) + out.String(x.TreeId) + } + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"key\":" + out.RawString(prefix) + out.String(x.Key) + } + out.RawByte('}') +} + +// UnmarshalJSON implements the json.Unmarshaler interface. +func (x *BurnedListByPrefixRequest_Body) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + x.UnmarshalEasyJSON(&r) + return r.Error() +} +func (x *BurnedListByPrefixRequest_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "containerId": + { + var f []byte + { + tmp := in.Bytes() + if len(tmp) == 0 { + tmp = nil + } + f = tmp + } + x.ContainerId = f + } + case "treeId": + { + var f string + f = in.String() + x.TreeId = f + } + case "key": + { + var f string + f = in.String() + x.Key = f + } + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} + +type BurnedListByPrefixRequest struct { + Body *BurnedListByPrefixRequest_Body `json:"body"` + Signature *Signature `json:"signature"` +} + +var ( + _ encoding.ProtoMarshaler = (*BurnedListByPrefixRequest)(nil) + _ encoding.ProtoUnmarshaler = (*BurnedListByPrefixRequest)(nil) + _ json.Marshaler = (*BurnedListByPrefixRequest)(nil) + _ json.Unmarshaler = (*BurnedListByPrefixRequest)(nil) +) + +// StableSize returns the size of x in protobuf format. +// +// Structures with the same field values have the same binary size. +func (x *BurnedListByPrefixRequest) StableSize() (size int) { + if x == nil { + return 0 + } + size += proto.NestedStructureSize(1, x.Body) + size += proto.NestedStructureSize(2, x.Signature) + return size +} + +// ReadSignedData fills buf with signed data of x. +// If buffer length is less than x.SignedDataSize(), new buffer is allocated. +// +// Returns any error encountered which did not allow writing the data completely. +// Otherwise, returns the buffer in which the data is written. +// +// Structures with the same field values have the same signed data. +func (x *BurnedListByPrefixRequest) SignedDataSize() int { + return x.GetBody().StableSize() +} + +// SignedDataSize returns size of the request signed data in bytes. +// +// Structures with the same field values have the same signed data size. +func (x *BurnedListByPrefixRequest) ReadSignedData(buf []byte) ([]byte, error) { + return x.GetBody().MarshalProtobuf(buf), nil +} + +// MarshalProtobuf implements the encoding.ProtoMarshaler interface. +func (x *BurnedListByPrefixRequest) MarshalProtobuf(dst []byte) []byte { + m := pool.MarshalerPool.Get() + defer pool.MarshalerPool.Put(m) + x.EmitProtobuf(m.MessageMarshaler()) + dst = m.Marshal(dst) + return dst +} + +func (x *BurnedListByPrefixRequest) EmitProtobuf(mm *easyproto.MessageMarshaler) { + if x == nil { + return + } + if x.Body != nil { + x.Body.EmitProtobuf(mm.AppendMessage(1)) + } + if x.Signature != nil { + x.Signature.EmitProtobuf(mm.AppendMessage(2)) + } +} + +// UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface. +func (x *BurnedListByPrefixRequest) UnmarshalProtobuf(src []byte) (err error) { + var fc easyproto.FieldContext + for len(src) > 0 { + src, err = fc.NextField(src) + if err != nil { + return fmt.Errorf("cannot read next field in %s", "BurnedListByPrefixRequest") + } + switch fc.FieldNum { + case 1: // Body + data, ok := fc.MessageData() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Body") + } + x.Body = new(BurnedListByPrefixRequest_Body) + if err := x.Body.UnmarshalProtobuf(data); err != nil { + return fmt.Errorf("unmarshal: %w", err) + } + case 2: // Signature + data, ok := fc.MessageData() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Signature") + } + x.Signature = new(Signature) + if err := x.Signature.UnmarshalProtobuf(data); err != nil { + return fmt.Errorf("unmarshal: %w", err) + } + } + } + return nil +} +func (x *BurnedListByPrefixRequest) GetBody() *BurnedListByPrefixRequest_Body { + if x != nil { + return x.Body + } + return nil +} +func (x *BurnedListByPrefixRequest) SetBody(v *BurnedListByPrefixRequest_Body) { + x.Body = v +} +func (x *BurnedListByPrefixRequest) GetSignature() *Signature { + if x != nil { + return x.Signature + } + return nil +} +func (x *BurnedListByPrefixRequest) SetSignature(v *Signature) { + x.Signature = v +} + +// MarshalJSON implements the json.Marshaler interface. +func (x *BurnedListByPrefixRequest) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + x.MarshalEasyJSON(&w) + return w.Buffer.BuildBytes(), w.Error +} +func (x *BurnedListByPrefixRequest) MarshalEasyJSON(out *jwriter.Writer) { + if x == nil { + out.RawString("null") + return + } + first := true + out.RawByte('{') + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" + out.RawString(prefix) + x.Signature.MarshalEasyJSON(out) + } + out.RawByte('}') +} + +// UnmarshalJSON implements the json.Unmarshaler interface. +func (x *BurnedListByPrefixRequest) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + x.UnmarshalEasyJSON(&r) + return r.Error() +} +func (x *BurnedListByPrefixRequest) UnmarshalEasyJSON(in *jlexer.Lexer) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "body": + { + var f *BurnedListByPrefixRequest_Body + f = new(BurnedListByPrefixRequest_Body) + f.UnmarshalEasyJSON(in) + x.Body = f + } + case "signature": + { + var f *Signature + f = new(Signature) + f.UnmarshalEasyJSON(in) + x.Signature = f + } + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} + +type BurnedListByPrefixResponse_Body_Info struct { + Key string `json:"key"` + Timestamp uint64 `json:"timestamp"` + Meta []KeyValue `json:"meta"` +} + +var ( + _ encoding.ProtoMarshaler = (*BurnedListByPrefixResponse_Body_Info)(nil) + _ encoding.ProtoUnmarshaler = (*BurnedListByPrefixResponse_Body_Info)(nil) + _ json.Marshaler = (*BurnedListByPrefixResponse_Body_Info)(nil) + _ json.Unmarshaler = (*BurnedListByPrefixResponse_Body_Info)(nil) +) + +// StableSize returns the size of x in protobuf format. +// +// Structures with the same field values have the same binary size. +func (x *BurnedListByPrefixResponse_Body_Info) StableSize() (size int) { + if x == nil { + return 0 + } + size += proto.StringSize(1, x.Key) + size += proto.UInt64Size(2, x.Timestamp) + for i := range x.Meta { + size += proto.NestedStructureSizeUnchecked(3, &x.Meta[i]) + } + return size +} + +// MarshalProtobuf implements the encoding.ProtoMarshaler interface. +func (x *BurnedListByPrefixResponse_Body_Info) MarshalProtobuf(dst []byte) []byte { + m := pool.MarshalerPool.Get() + defer pool.MarshalerPool.Put(m) + x.EmitProtobuf(m.MessageMarshaler()) + dst = m.Marshal(dst) + return dst +} + +func (x *BurnedListByPrefixResponse_Body_Info) EmitProtobuf(mm *easyproto.MessageMarshaler) { + if x == nil { + return + } + if len(x.Key) != 0 { + mm.AppendString(1, x.Key) + } + if x.Timestamp != 0 { + mm.AppendUint64(2, x.Timestamp) + } + for i := range x.Meta { + x.Meta[i].EmitProtobuf(mm.AppendMessage(3)) + } +} + +// UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface. +func (x *BurnedListByPrefixResponse_Body_Info) UnmarshalProtobuf(src []byte) (err error) { + var fc easyproto.FieldContext + for len(src) > 0 { + src, err = fc.NextField(src) + if err != nil { + return fmt.Errorf("cannot read next field in %s", "BurnedListByPrefixResponse_Body_Info") + } + switch fc.FieldNum { + case 1: // Key + data, ok := fc.String() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Key") + } + x.Key = data + case 2: // Timestamp + data, ok := fc.Uint64() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Timestamp") + } + x.Timestamp = data + case 3: // Meta + data, ok := fc.MessageData() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Meta") + } + x.Meta = append(x.Meta, KeyValue{}) + ff := &x.Meta[len(x.Meta)-1] + if err := ff.UnmarshalProtobuf(data); err != nil { + return fmt.Errorf("unmarshal: %w", err) + } + } + } + return nil +} +func (x *BurnedListByPrefixResponse_Body_Info) GetKey() string { + if x != nil { + return x.Key + } + return "" +} +func (x *BurnedListByPrefixResponse_Body_Info) SetKey(v string) { + x.Key = v +} +func (x *BurnedListByPrefixResponse_Body_Info) GetTimestamp() uint64 { + if x != nil { + return x.Timestamp + } + return 0 +} +func (x *BurnedListByPrefixResponse_Body_Info) SetTimestamp(v uint64) { + x.Timestamp = v +} +func (x *BurnedListByPrefixResponse_Body_Info) GetMeta() []KeyValue { + if x != nil { + return x.Meta + } + return nil +} +func (x *BurnedListByPrefixResponse_Body_Info) SetMeta(v []KeyValue) { + x.Meta = v +} + +// MarshalJSON implements the json.Marshaler interface. +func (x *BurnedListByPrefixResponse_Body_Info) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + x.MarshalEasyJSON(&w) + return w.Buffer.BuildBytes(), w.Error +} +func (x *BurnedListByPrefixResponse_Body_Info) MarshalEasyJSON(out *jwriter.Writer) { + if x == nil { + out.RawString("null") + return + } + first := true + out.RawByte('{') + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"key\":" + out.RawString(prefix) + out.String(x.Key) + } + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"timestamp\":" + out.RawString(prefix) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.Timestamp, 10) + out.RawByte('"') + } + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"meta\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.Meta { + if i != 0 { + out.RawByte(',') + } + x.Meta[i].MarshalEasyJSON(out) + } + out.RawByte(']') + } + out.RawByte('}') +} + +// UnmarshalJSON implements the json.Unmarshaler interface. +func (x *BurnedListByPrefixResponse_Body_Info) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + x.UnmarshalEasyJSON(&r) + return r.Error() +} +func (x *BurnedListByPrefixResponse_Body_Info) UnmarshalEasyJSON(in *jlexer.Lexer) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "key": + { + var f string + f = in.String() + x.Key = f + } + case "timestamp": + { + var f uint64 + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv + x.Timestamp = f + } + case "meta": + { + var f KeyValue + var list []KeyValue + in.Delim('[') + for !in.IsDelim(']') { + f = KeyValue{} + f.UnmarshalEasyJSON(in) + list = append(list, f) + in.WantComma() + } + x.Meta = list + in.Delim(']') + } + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} + +type BurnedListByPrefixResponse_Body struct { + List []BurnedListByPrefixResponse_Body_Info `json:"list"` +} + +var ( + _ encoding.ProtoMarshaler = (*BurnedListByPrefixResponse_Body)(nil) + _ encoding.ProtoUnmarshaler = (*BurnedListByPrefixResponse_Body)(nil) + _ json.Marshaler = (*BurnedListByPrefixResponse_Body)(nil) + _ json.Unmarshaler = (*BurnedListByPrefixResponse_Body)(nil) +) + +// StableSize returns the size of x in protobuf format. +// +// Structures with the same field values have the same binary size. +func (x *BurnedListByPrefixResponse_Body) StableSize() (size int) { + if x == nil { + return 0 + } + for i := range x.List { + size += proto.NestedStructureSizeUnchecked(1, &x.List[i]) + } + return size +} + +// MarshalProtobuf implements the encoding.ProtoMarshaler interface. +func (x *BurnedListByPrefixResponse_Body) MarshalProtobuf(dst []byte) []byte { + m := pool.MarshalerPool.Get() + defer pool.MarshalerPool.Put(m) + x.EmitProtobuf(m.MessageMarshaler()) + dst = m.Marshal(dst) + return dst +} + +func (x *BurnedListByPrefixResponse_Body) EmitProtobuf(mm *easyproto.MessageMarshaler) { + if x == nil { + return + } + for i := range x.List { + x.List[i].EmitProtobuf(mm.AppendMessage(1)) + } +} + +// UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface. +func (x *BurnedListByPrefixResponse_Body) UnmarshalProtobuf(src []byte) (err error) { + var fc easyproto.FieldContext + for len(src) > 0 { + src, err = fc.NextField(src) + if err != nil { + return fmt.Errorf("cannot read next field in %s", "BurnedListByPrefixResponse_Body") + } + switch fc.FieldNum { + case 1: // List + data, ok := fc.MessageData() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "List") + } + x.List = append(x.List, BurnedListByPrefixResponse_Body_Info{}) + ff := &x.List[len(x.List)-1] + if err := ff.UnmarshalProtobuf(data); err != nil { + return fmt.Errorf("unmarshal: %w", err) + } + } + } + return nil +} +func (x *BurnedListByPrefixResponse_Body) GetList() []BurnedListByPrefixResponse_Body_Info { + if x != nil { + return x.List + } + return nil +} +func (x *BurnedListByPrefixResponse_Body) SetList(v []BurnedListByPrefixResponse_Body_Info) { + x.List = v +} + +// MarshalJSON implements the json.Marshaler interface. +func (x *BurnedListByPrefixResponse_Body) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + x.MarshalEasyJSON(&w) + return w.Buffer.BuildBytes(), w.Error +} +func (x *BurnedListByPrefixResponse_Body) MarshalEasyJSON(out *jwriter.Writer) { + if x == nil { + out.RawString("null") + return + } + first := true + out.RawByte('{') + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"list\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.List { + if i != 0 { + out.RawByte(',') + } + x.List[i].MarshalEasyJSON(out) + } + out.RawByte(']') + } + out.RawByte('}') +} + +// UnmarshalJSON implements the json.Unmarshaler interface. +func (x *BurnedListByPrefixResponse_Body) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + x.UnmarshalEasyJSON(&r) + return r.Error() +} +func (x *BurnedListByPrefixResponse_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "list": + { + var f BurnedListByPrefixResponse_Body_Info + var list []BurnedListByPrefixResponse_Body_Info + in.Delim('[') + for !in.IsDelim(']') { + f = BurnedListByPrefixResponse_Body_Info{} + f.UnmarshalEasyJSON(in) + list = append(list, f) + in.WantComma() + } + x.List = list + in.Delim(']') + } + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} + +type BurnedListByPrefixResponse struct { + Body *BurnedListByPrefixResponse_Body `json:"body"` + Signature *Signature `json:"signature"` +} + +var ( + _ encoding.ProtoMarshaler = (*BurnedListByPrefixResponse)(nil) + _ encoding.ProtoUnmarshaler = (*BurnedListByPrefixResponse)(nil) + _ json.Marshaler = (*BurnedListByPrefixResponse)(nil) + _ json.Unmarshaler = (*BurnedListByPrefixResponse)(nil) +) + +// StableSize returns the size of x in protobuf format. +// +// Structures with the same field values have the same binary size. +func (x *BurnedListByPrefixResponse) StableSize() (size int) { + if x == nil { + return 0 + } + size += proto.NestedStructureSize(1, x.Body) + size += proto.NestedStructureSize(2, x.Signature) + return size +} + +// ReadSignedData fills buf with signed data of x. +// If buffer length is less than x.SignedDataSize(), new buffer is allocated. +// +// Returns any error encountered which did not allow writing the data completely. +// Otherwise, returns the buffer in which the data is written. +// +// Structures with the same field values have the same signed data. +func (x *BurnedListByPrefixResponse) SignedDataSize() int { + return x.GetBody().StableSize() +} + +// SignedDataSize returns size of the request signed data in bytes. +// +// Structures with the same field values have the same signed data size. +func (x *BurnedListByPrefixResponse) ReadSignedData(buf []byte) ([]byte, error) { + return x.GetBody().MarshalProtobuf(buf), nil +} + +// MarshalProtobuf implements the encoding.ProtoMarshaler interface. +func (x *BurnedListByPrefixResponse) MarshalProtobuf(dst []byte) []byte { + m := pool.MarshalerPool.Get() + defer pool.MarshalerPool.Put(m) + x.EmitProtobuf(m.MessageMarshaler()) + dst = m.Marshal(dst) + return dst +} + +func (x *BurnedListByPrefixResponse) EmitProtobuf(mm *easyproto.MessageMarshaler) { + if x == nil { + return + } + if x.Body != nil { + x.Body.EmitProtobuf(mm.AppendMessage(1)) + } + if x.Signature != nil { + x.Signature.EmitProtobuf(mm.AppendMessage(2)) + } +} + +// UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface. +func (x *BurnedListByPrefixResponse) UnmarshalProtobuf(src []byte) (err error) { + var fc easyproto.FieldContext + for len(src) > 0 { + src, err = fc.NextField(src) + if err != nil { + return fmt.Errorf("cannot read next field in %s", "BurnedListByPrefixResponse") + } + switch fc.FieldNum { + case 1: // Body + data, ok := fc.MessageData() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Body") + } + x.Body = new(BurnedListByPrefixResponse_Body) + if err := x.Body.UnmarshalProtobuf(data); err != nil { + return fmt.Errorf("unmarshal: %w", err) + } + case 2: // Signature + data, ok := fc.MessageData() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Signature") + } + x.Signature = new(Signature) + if err := x.Signature.UnmarshalProtobuf(data); err != nil { + return fmt.Errorf("unmarshal: %w", err) + } + } + } + return nil +} +func (x *BurnedListByPrefixResponse) GetBody() *BurnedListByPrefixResponse_Body { + if x != nil { + return x.Body + } + return nil +} +func (x *BurnedListByPrefixResponse) SetBody(v *BurnedListByPrefixResponse_Body) { + x.Body = v +} +func (x *BurnedListByPrefixResponse) GetSignature() *Signature { + if x != nil { + return x.Signature + } + return nil +} +func (x *BurnedListByPrefixResponse) SetSignature(v *Signature) { + x.Signature = v +} + +// MarshalJSON implements the json.Marshaler interface. +func (x *BurnedListByPrefixResponse) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + x.MarshalEasyJSON(&w) + return w.Buffer.BuildBytes(), w.Error +} +func (x *BurnedListByPrefixResponse) MarshalEasyJSON(out *jwriter.Writer) { + if x == nil { + out.RawString("null") + return + } + first := true + out.RawByte('{') + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" + out.RawString(prefix) + x.Signature.MarshalEasyJSON(out) + } + out.RawByte('}') +} + +// UnmarshalJSON implements the json.Unmarshaler interface. +func (x *BurnedListByPrefixResponse) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + x.UnmarshalEasyJSON(&r) + return r.Error() +} +func (x *BurnedListByPrefixResponse) UnmarshalEasyJSON(in *jlexer.Lexer) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "body": + { + var f *BurnedListByPrefixResponse_Body + f = new(BurnedListByPrefixResponse_Body) + f.UnmarshalEasyJSON(in) + x.Body = f + } + case "signature": + { + var f *Signature + f = new(Signature) + f.UnmarshalEasyJSON(in) + x.Signature = f + } + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} + +type BurnedListRequest_Body struct { + ContainerId []byte `json:"containerId"` + TreeId string `json:"treeId"` + Start string `json:"start"` +} + +var ( + _ encoding.ProtoMarshaler = (*BurnedListRequest_Body)(nil) + _ encoding.ProtoUnmarshaler = (*BurnedListRequest_Body)(nil) + _ json.Marshaler = (*BurnedListRequest_Body)(nil) + _ json.Unmarshaler = (*BurnedListRequest_Body)(nil) +) + +// StableSize returns the size of x in protobuf format. +// +// Structures with the same field values have the same binary size. +func (x *BurnedListRequest_Body) StableSize() (size int) { + if x == nil { + return 0 + } + size += proto.BytesSize(1, x.ContainerId) + size += proto.StringSize(2, x.TreeId) + size += proto.StringSize(3, x.Start) + return size +} + +// MarshalProtobuf implements the encoding.ProtoMarshaler interface. +func (x *BurnedListRequest_Body) MarshalProtobuf(dst []byte) []byte { + m := pool.MarshalerPool.Get() + defer pool.MarshalerPool.Put(m) + x.EmitProtobuf(m.MessageMarshaler()) + dst = m.Marshal(dst) + return dst +} + +func (x *BurnedListRequest_Body) EmitProtobuf(mm *easyproto.MessageMarshaler) { + if x == nil { + return + } + if len(x.ContainerId) != 0 { + mm.AppendBytes(1, x.ContainerId) + } + if len(x.TreeId) != 0 { + mm.AppendString(2, x.TreeId) + } + if len(x.Start) != 0 { + mm.AppendString(3, x.Start) + } +} + +// UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface. +func (x *BurnedListRequest_Body) UnmarshalProtobuf(src []byte) (err error) { + var fc easyproto.FieldContext + for len(src) > 0 { + src, err = fc.NextField(src) + if err != nil { + return fmt.Errorf("cannot read next field in %s", "BurnedListRequest_Body") + } + switch fc.FieldNum { + case 1: // ContainerId + data, ok := fc.Bytes() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "ContainerId") + } + x.ContainerId = data + case 2: // TreeId + data, ok := fc.String() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "TreeId") + } + x.TreeId = data + case 3: // Start + data, ok := fc.String() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Start") + } + x.Start = data + } + } + return nil +} +func (x *BurnedListRequest_Body) GetContainerId() []byte { + if x != nil { + return x.ContainerId + } + return nil +} +func (x *BurnedListRequest_Body) SetContainerId(v []byte) { + x.ContainerId = v +} +func (x *BurnedListRequest_Body) GetTreeId() string { + if x != nil { + return x.TreeId + } + return "" +} +func (x *BurnedListRequest_Body) SetTreeId(v string) { + x.TreeId = v +} +func (x *BurnedListRequest_Body) GetStart() string { + if x != nil { + return x.Start + } + return "" +} +func (x *BurnedListRequest_Body) SetStart(v string) { + x.Start = v +} + +// MarshalJSON implements the json.Marshaler interface. +func (x *BurnedListRequest_Body) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + x.MarshalEasyJSON(&w) + return w.Buffer.BuildBytes(), w.Error +} +func (x *BurnedListRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { + if x == nil { + out.RawString("null") + return + } + first := true + out.RawByte('{') + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"containerId\":" + out.RawString(prefix) + if x.ContainerId != nil { + out.Base64Bytes(x.ContainerId) + } else { + out.String("") + } + } + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"treeId\":" + out.RawString(prefix) + out.String(x.TreeId) + } + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"start\":" + out.RawString(prefix) + out.String(x.Start) + } + out.RawByte('}') +} + +// UnmarshalJSON implements the json.Unmarshaler interface. +func (x *BurnedListRequest_Body) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + x.UnmarshalEasyJSON(&r) + return r.Error() +} +func (x *BurnedListRequest_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "containerId": + { + var f []byte + { + tmp := in.Bytes() + if len(tmp) == 0 { + tmp = nil + } + f = tmp + } + x.ContainerId = f + } + case "treeId": + { + var f string + f = in.String() + x.TreeId = f + } + case "start": + { + var f string + f = in.String() + x.Start = f + } + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} + +type BurnedListRequest struct { + Body *BurnedListRequest_Body `json:"body"` + Signature *Signature `json:"signature"` +} + +var ( + _ encoding.ProtoMarshaler = (*BurnedListRequest)(nil) + _ encoding.ProtoUnmarshaler = (*BurnedListRequest)(nil) + _ json.Marshaler = (*BurnedListRequest)(nil) + _ json.Unmarshaler = (*BurnedListRequest)(nil) +) + +// StableSize returns the size of x in protobuf format. +// +// Structures with the same field values have the same binary size. +func (x *BurnedListRequest) StableSize() (size int) { + if x == nil { + return 0 + } + size += proto.NestedStructureSize(1, x.Body) + size += proto.NestedStructureSize(2, x.Signature) + return size +} + +// ReadSignedData fills buf with signed data of x. +// If buffer length is less than x.SignedDataSize(), new buffer is allocated. +// +// Returns any error encountered which did not allow writing the data completely. +// Otherwise, returns the buffer in which the data is written. +// +// Structures with the same field values have the same signed data. +func (x *BurnedListRequest) SignedDataSize() int { + return x.GetBody().StableSize() +} + +// SignedDataSize returns size of the request signed data in bytes. +// +// Structures with the same field values have the same signed data size. +func (x *BurnedListRequest) ReadSignedData(buf []byte) ([]byte, error) { + return x.GetBody().MarshalProtobuf(buf), nil +} + +// MarshalProtobuf implements the encoding.ProtoMarshaler interface. +func (x *BurnedListRequest) MarshalProtobuf(dst []byte) []byte { + m := pool.MarshalerPool.Get() + defer pool.MarshalerPool.Put(m) + x.EmitProtobuf(m.MessageMarshaler()) + dst = m.Marshal(dst) + return dst +} + +func (x *BurnedListRequest) EmitProtobuf(mm *easyproto.MessageMarshaler) { + if x == nil { + return + } + if x.Body != nil { + x.Body.EmitProtobuf(mm.AppendMessage(1)) + } + if x.Signature != nil { + x.Signature.EmitProtobuf(mm.AppendMessage(2)) + } +} + +// UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface. +func (x *BurnedListRequest) UnmarshalProtobuf(src []byte) (err error) { + var fc easyproto.FieldContext + for len(src) > 0 { + src, err = fc.NextField(src) + if err != nil { + return fmt.Errorf("cannot read next field in %s", "BurnedListRequest") + } + switch fc.FieldNum { + case 1: // Body + data, ok := fc.MessageData() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Body") + } + x.Body = new(BurnedListRequest_Body) + if err := x.Body.UnmarshalProtobuf(data); err != nil { + return fmt.Errorf("unmarshal: %w", err) + } + case 2: // Signature + data, ok := fc.MessageData() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Signature") + } + x.Signature = new(Signature) + if err := x.Signature.UnmarshalProtobuf(data); err != nil { + return fmt.Errorf("unmarshal: %w", err) + } + } + } + return nil +} +func (x *BurnedListRequest) GetBody() *BurnedListRequest_Body { + if x != nil { + return x.Body + } + return nil +} +func (x *BurnedListRequest) SetBody(v *BurnedListRequest_Body) { + x.Body = v +} +func (x *BurnedListRequest) GetSignature() *Signature { + if x != nil { + return x.Signature + } + return nil +} +func (x *BurnedListRequest) SetSignature(v *Signature) { + x.Signature = v +} + +// MarshalJSON implements the json.Marshaler interface. +func (x *BurnedListRequest) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + x.MarshalEasyJSON(&w) + return w.Buffer.BuildBytes(), w.Error +} +func (x *BurnedListRequest) MarshalEasyJSON(out *jwriter.Writer) { + if x == nil { + out.RawString("null") + return + } + first := true + out.RawByte('{') + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" + out.RawString(prefix) + x.Signature.MarshalEasyJSON(out) + } + out.RawByte('}') +} + +// UnmarshalJSON implements the json.Unmarshaler interface. +func (x *BurnedListRequest) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + x.UnmarshalEasyJSON(&r) + return r.Error() +} +func (x *BurnedListRequest) UnmarshalEasyJSON(in *jlexer.Lexer) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "body": + { + var f *BurnedListRequest_Body + f = new(BurnedListRequest_Body) + f.UnmarshalEasyJSON(in) + x.Body = f + } + case "signature": + { + var f *Signature + f = new(Signature) + f.UnmarshalEasyJSON(in) + x.Signature = f + } + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} + +type BurnedListResponse_Body struct { + Key string `json:"key"` + Timestamp uint64 `json:"timestamp"` + Meta []KeyValue `json:"meta"` +} + +var ( + _ encoding.ProtoMarshaler = (*BurnedListResponse_Body)(nil) + _ encoding.ProtoUnmarshaler = (*BurnedListResponse_Body)(nil) + _ json.Marshaler = (*BurnedListResponse_Body)(nil) + _ json.Unmarshaler = (*BurnedListResponse_Body)(nil) +) + +// StableSize returns the size of x in protobuf format. +// +// Structures with the same field values have the same binary size. +func (x *BurnedListResponse_Body) StableSize() (size int) { + if x == nil { + return 0 + } + size += proto.StringSize(1, x.Key) + size += proto.UInt64Size(2, x.Timestamp) + for i := range x.Meta { + size += proto.NestedStructureSizeUnchecked(3, &x.Meta[i]) + } + return size +} + +// MarshalProtobuf implements the encoding.ProtoMarshaler interface. +func (x *BurnedListResponse_Body) MarshalProtobuf(dst []byte) []byte { + m := pool.MarshalerPool.Get() + defer pool.MarshalerPool.Put(m) + x.EmitProtobuf(m.MessageMarshaler()) + dst = m.Marshal(dst) + return dst +} + +func (x *BurnedListResponse_Body) EmitProtobuf(mm *easyproto.MessageMarshaler) { + if x == nil { + return + } + if len(x.Key) != 0 { + mm.AppendString(1, x.Key) + } + if x.Timestamp != 0 { + mm.AppendUint64(2, x.Timestamp) + } + for i := range x.Meta { + x.Meta[i].EmitProtobuf(mm.AppendMessage(3)) + } +} + +// UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface. +func (x *BurnedListResponse_Body) UnmarshalProtobuf(src []byte) (err error) { + var fc easyproto.FieldContext + for len(src) > 0 { + src, err = fc.NextField(src) + if err != nil { + return fmt.Errorf("cannot read next field in %s", "BurnedListResponse_Body") + } + switch fc.FieldNum { + case 1: // Key + data, ok := fc.String() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Key") + } + x.Key = data + case 2: // Timestamp + data, ok := fc.Uint64() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Timestamp") + } + x.Timestamp = data + case 3: // Meta + data, ok := fc.MessageData() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Meta") + } + x.Meta = append(x.Meta, KeyValue{}) + ff := &x.Meta[len(x.Meta)-1] + if err := ff.UnmarshalProtobuf(data); err != nil { + return fmt.Errorf("unmarshal: %w", err) + } + } + } + return nil +} +func (x *BurnedListResponse_Body) GetKey() string { + if x != nil { + return x.Key + } + return "" +} +func (x *BurnedListResponse_Body) SetKey(v string) { + x.Key = v +} +func (x *BurnedListResponse_Body) GetTimestamp() uint64 { + if x != nil { + return x.Timestamp + } + return 0 +} +func (x *BurnedListResponse_Body) SetTimestamp(v uint64) { + x.Timestamp = v +} +func (x *BurnedListResponse_Body) GetMeta() []KeyValue { + if x != nil { + return x.Meta + } + return nil +} +func (x *BurnedListResponse_Body) SetMeta(v []KeyValue) { + x.Meta = v +} + +// MarshalJSON implements the json.Marshaler interface. +func (x *BurnedListResponse_Body) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + x.MarshalEasyJSON(&w) + return w.Buffer.BuildBytes(), w.Error +} +func (x *BurnedListResponse_Body) MarshalEasyJSON(out *jwriter.Writer) { + if x == nil { + out.RawString("null") + return + } + first := true + out.RawByte('{') + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"key\":" + out.RawString(prefix) + out.String(x.Key) + } + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"timestamp\":" + out.RawString(prefix) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.Timestamp, 10) + out.RawByte('"') + } + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"meta\":" + out.RawString(prefix) + out.RawByte('[') + for i := range x.Meta { + if i != 0 { + out.RawByte(',') + } + x.Meta[i].MarshalEasyJSON(out) + } + out.RawByte(']') + } + out.RawByte('}') +} + +// UnmarshalJSON implements the json.Unmarshaler interface. +func (x *BurnedListResponse_Body) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + x.UnmarshalEasyJSON(&r) + return r.Error() +} +func (x *BurnedListResponse_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "key": + { + var f string + f = in.String() + x.Key = f + } + case "timestamp": + { + var f uint64 + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv + x.Timestamp = f + } + case "meta": + { + var f KeyValue + var list []KeyValue + in.Delim('[') + for !in.IsDelim(']') { + f = KeyValue{} + f.UnmarshalEasyJSON(in) + list = append(list, f) + in.WantComma() + } + x.Meta = list + in.Delim(']') + } + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} + +type BurnedListResponse struct { + Body *BurnedListResponse_Body `json:"body"` + Signature *Signature `json:"signature"` +} + +var ( + _ encoding.ProtoMarshaler = (*BurnedListResponse)(nil) + _ encoding.ProtoUnmarshaler = (*BurnedListResponse)(nil) + _ json.Marshaler = (*BurnedListResponse)(nil) + _ json.Unmarshaler = (*BurnedListResponse)(nil) +) + +// StableSize returns the size of x in protobuf format. +// +// Structures with the same field values have the same binary size. +func (x *BurnedListResponse) StableSize() (size int) { + if x == nil { + return 0 + } + size += proto.NestedStructureSize(1, x.Body) + size += proto.NestedStructureSize(2, x.Signature) + return size +} + +// ReadSignedData fills buf with signed data of x. +// If buffer length is less than x.SignedDataSize(), new buffer is allocated. +// +// Returns any error encountered which did not allow writing the data completely. +// Otherwise, returns the buffer in which the data is written. +// +// Structures with the same field values have the same signed data. +func (x *BurnedListResponse) SignedDataSize() int { + return x.GetBody().StableSize() +} + +// SignedDataSize returns size of the request signed data in bytes. +// +// Structures with the same field values have the same signed data size. +func (x *BurnedListResponse) ReadSignedData(buf []byte) ([]byte, error) { + return x.GetBody().MarshalProtobuf(buf), nil +} + +// MarshalProtobuf implements the encoding.ProtoMarshaler interface. +func (x *BurnedListResponse) MarshalProtobuf(dst []byte) []byte { + m := pool.MarshalerPool.Get() + defer pool.MarshalerPool.Put(m) + x.EmitProtobuf(m.MessageMarshaler()) + dst = m.Marshal(dst) + return dst +} + +func (x *BurnedListResponse) EmitProtobuf(mm *easyproto.MessageMarshaler) { + if x == nil { + return + } + if x.Body != nil { + x.Body.EmitProtobuf(mm.AppendMessage(1)) + } + if x.Signature != nil { + x.Signature.EmitProtobuf(mm.AppendMessage(2)) + } +} + +// UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface. +func (x *BurnedListResponse) UnmarshalProtobuf(src []byte) (err error) { + var fc easyproto.FieldContext + for len(src) > 0 { + src, err = fc.NextField(src) + if err != nil { + return fmt.Errorf("cannot read next field in %s", "BurnedListResponse") + } + switch fc.FieldNum { + case 1: // Body + data, ok := fc.MessageData() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Body") + } + x.Body = new(BurnedListResponse_Body) + if err := x.Body.UnmarshalProtobuf(data); err != nil { + return fmt.Errorf("unmarshal: %w", err) + } + case 2: // Signature + data, ok := fc.MessageData() + if !ok { + return fmt.Errorf("cannot unmarshal field %s", "Signature") + } + x.Signature = new(Signature) + if err := x.Signature.UnmarshalProtobuf(data); err != nil { + return fmt.Errorf("unmarshal: %w", err) + } + } + } + return nil +} +func (x *BurnedListResponse) GetBody() *BurnedListResponse_Body { + if x != nil { + return x.Body + } + return nil +} +func (x *BurnedListResponse) SetBody(v *BurnedListResponse_Body) { + x.Body = v +} +func (x *BurnedListResponse) GetSignature() *Signature { + if x != nil { + return x.Signature + } + return nil +} +func (x *BurnedListResponse) SetSignature(v *Signature) { + x.Signature = v +} + +// MarshalJSON implements the json.Marshaler interface. +func (x *BurnedListResponse) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + x.MarshalEasyJSON(&w) + return w.Buffer.BuildBytes(), w.Error +} +func (x *BurnedListResponse) MarshalEasyJSON(out *jwriter.Writer) { + if x == nil { + out.RawString("null") + return + } + first := true + out.RawByte('{') + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) + x.Body.MarshalEasyJSON(out) + } + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" + out.RawString(prefix) + x.Signature.MarshalEasyJSON(out) + } + out.RawByte('}') +} + +// UnmarshalJSON implements the json.Unmarshaler interface. +func (x *BurnedListResponse) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + x.UnmarshalEasyJSON(&r) + return r.Error() +} +func (x *BurnedListResponse) UnmarshalEasyJSON(in *jlexer.Lexer) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "body": + { + var f *BurnedListResponse_Body + f = new(BurnedListResponse_Body) + f.UnmarshalEasyJSON(in) + x.Body = f + } + case "signature": + { + var f *Signature + f = new(Signature) + f.UnmarshalEasyJSON(in) + x.Signature = f + } + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} + type AddRequest_Body struct { ContainerId []byte `json:"containerId"` TreeId string `json:"treeId"` @@ -181,24 +5974,51 @@ func (x *AddRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"containerId\":" - out.RawString(prefix[1:]) - out.Base64Bytes(x.ContainerId) + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"containerId\":" + out.RawString(prefix) + if x.ContainerId != nil { + out.Base64Bytes(x.ContainerId) + } else { + out.String("") + } } { - const prefix string = ",\"treeId\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"treeId\":" out.RawString(prefix) out.String(x.TreeId) } { - const prefix string = ",\"parentId\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"parentId\":" out.RawString(prefix) - out.Uint64(x.ParentId) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.ParentId, 10) + out.RawByte('"') } { - const prefix string = ",\"meta\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"meta\":" out.RawString(prefix) out.RawByte('[') for i := range x.Meta { @@ -210,9 +6030,18 @@ func (x *AddRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawByte(']') } { - const prefix string = ",\"bearerToken\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"bearerToken\":" out.RawString(prefix) - out.Base64Bytes(x.BearerToken) + if x.BearerToken != nil { + out.Base64Bytes(x.BearerToken) + } else { + out.String("") + } } out.RawByte('}') } @@ -245,7 +6074,13 @@ func (x *AddRequest_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { case "containerId": { var f []byte - f = in.Bytes() + { + tmp := in.Bytes() + if len(tmp) == 0 { + tmp = nil + } + f = tmp + } x.ContainerId = f } case "treeId": @@ -257,7 +6092,15 @@ func (x *AddRequest_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { case "parentId": { var f uint64 - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv x.ParentId = f } case "meta": @@ -277,7 +6120,13 @@ func (x *AddRequest_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { case "bearerToken": { var f []byte - f = in.Bytes() + { + tmp := in.Bytes() + if len(tmp) == 0 { + tmp = nil + } + f = tmp + } x.BearerToken = f } } @@ -413,14 +6262,25 @@ func (x *AddRequest) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) x.Body.MarshalEasyJSON(out) } { - const prefix string = ",\"signature\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" out.RawString(prefix) x.Signature.MarshalEasyJSON(out) } @@ -555,11 +6415,19 @@ func (x *AddResponse_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"nodeId\":" - out.RawString(prefix[1:]) - out.Uint64(x.NodeId) + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"nodeId\":" + out.RawString(prefix) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.NodeId, 10) + out.RawByte('"') } out.RawByte('}') } @@ -592,7 +6460,15 @@ func (x *AddResponse_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { case "nodeId": { var f uint64 - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv x.NodeId = f } } @@ -728,14 +6604,25 @@ func (x *AddResponse) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) x.Body.MarshalEasyJSON(out) } { - const prefix string = ",\"signature\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" out.RawString(prefix) x.Signature.MarshalEasyJSON(out) } @@ -976,24 +6863,49 @@ func (x *AddByPathRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"containerId\":" - out.RawString(prefix[1:]) - out.Base64Bytes(x.ContainerId) + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"containerId\":" + out.RawString(prefix) + if x.ContainerId != nil { + out.Base64Bytes(x.ContainerId) + } else { + out.String("") + } } { - const prefix string = ",\"treeId\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"treeId\":" out.RawString(prefix) out.String(x.TreeId) } { - const prefix string = ",\"pathAttribute\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"pathAttribute\":" out.RawString(prefix) out.String(x.PathAttribute) } { - const prefix string = ",\"path\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"path\":" out.RawString(prefix) out.RawByte('[') for i := range x.Path { @@ -1005,7 +6917,12 @@ func (x *AddByPathRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawByte(']') } { - const prefix string = ",\"meta\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"meta\":" out.RawString(prefix) out.RawByte('[') for i := range x.Meta { @@ -1017,9 +6934,18 @@ func (x *AddByPathRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawByte(']') } { - const prefix string = ",\"bearerToken\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"bearerToken\":" out.RawString(prefix) - out.Base64Bytes(x.BearerToken) + if x.BearerToken != nil { + out.Base64Bytes(x.BearerToken) + } else { + out.String("") + } } out.RawByte('}') } @@ -1052,7 +6978,13 @@ func (x *AddByPathRequest_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { case "containerId": { var f []byte - f = in.Bytes() + { + tmp := in.Bytes() + if len(tmp) == 0 { + tmp = nil + } + f = tmp + } x.ContainerId = f } case "treeId": @@ -1097,7 +7029,13 @@ func (x *AddByPathRequest_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { case "bearerToken": { var f []byte - f = in.Bytes() + { + tmp := in.Bytes() + if len(tmp) == 0 { + tmp = nil + } + f = tmp + } x.BearerToken = f } } @@ -1233,14 +7171,25 @@ func (x *AddByPathRequest) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) x.Body.MarshalEasyJSON(out) } { - const prefix string = ",\"signature\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" out.RawString(prefix) x.Signature.MarshalEasyJSON(out) } @@ -1397,23 +7346,38 @@ func (x *AddByPathResponse_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"nodes\":" - out.RawString(prefix[1:]) + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"nodes\":" + out.RawString(prefix) out.RawByte('[') for i := range x.Nodes { if i != 0 { out.RawByte(',') } - out.Uint64(x.Nodes[i]) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.Nodes[i], 10) + out.RawByte('"') } out.RawByte(']') } { - const prefix string = ",\"parentId\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"parentId\":" out.RawString(prefix) - out.Uint64(x.ParentId) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.ParentId, 10) + out.RawByte('"') } out.RawByte('}') } @@ -1449,7 +7413,15 @@ func (x *AddByPathResponse_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { var list []uint64 in.Delim('[') for !in.IsDelim(']') { - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv list = append(list, f) in.WantComma() } @@ -1459,7 +7431,15 @@ func (x *AddByPathResponse_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { case "parentId": { var f uint64 - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv x.ParentId = f } } @@ -1595,14 +7575,25 @@ func (x *AddByPathResponse) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) x.Body.MarshalEasyJSON(out) } { - const prefix string = ",\"signature\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" out.RawString(prefix) x.Signature.MarshalEasyJSON(out) } @@ -1797,26 +7788,57 @@ func (x *RemoveRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"containerId\":" - out.RawString(prefix[1:]) - out.Base64Bytes(x.ContainerId) + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"containerId\":" + out.RawString(prefix) + if x.ContainerId != nil { + out.Base64Bytes(x.ContainerId) + } else { + out.String("") + } } { - const prefix string = ",\"treeId\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"treeId\":" out.RawString(prefix) out.String(x.TreeId) } { - const prefix string = ",\"nodeId\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"nodeId\":" out.RawString(prefix) - out.Uint64(x.NodeId) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.NodeId, 10) + out.RawByte('"') } { - const prefix string = ",\"bearerToken\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"bearerToken\":" out.RawString(prefix) - out.Base64Bytes(x.BearerToken) + if x.BearerToken != nil { + out.Base64Bytes(x.BearerToken) + } else { + out.String("") + } } out.RawByte('}') } @@ -1849,7 +7871,13 @@ func (x *RemoveRequest_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { case "containerId": { var f []byte - f = in.Bytes() + { + tmp := in.Bytes() + if len(tmp) == 0 { + tmp = nil + } + f = tmp + } x.ContainerId = f } case "treeId": @@ -1861,13 +7889,27 @@ func (x *RemoveRequest_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { case "nodeId": { var f uint64 - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv x.NodeId = f } case "bearerToken": { var f []byte - f = in.Bytes() + { + tmp := in.Bytes() + if len(tmp) == 0 { + tmp = nil + } + f = tmp + } x.BearerToken = f } } @@ -2003,14 +8045,25 @@ func (x *RemoveRequest) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) x.Body.MarshalEasyJSON(out) } { - const prefix string = ",\"signature\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" out.RawString(prefix) x.Signature.MarshalEasyJSON(out) } @@ -2284,14 +8337,25 @@ func (x *RemoveResponse) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) x.Body.MarshalEasyJSON(out) } { - const prefix string = ",\"signature\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" out.RawString(prefix) x.Signature.MarshalEasyJSON(out) } @@ -2532,29 +8596,63 @@ func (x *MoveRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"containerId\":" - out.RawString(prefix[1:]) - out.Base64Bytes(x.ContainerId) + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"containerId\":" + out.RawString(prefix) + if x.ContainerId != nil { + out.Base64Bytes(x.ContainerId) + } else { + out.String("") + } } { - const prefix string = ",\"treeId\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"treeId\":" out.RawString(prefix) out.String(x.TreeId) } { - const prefix string = ",\"parentId\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"parentId\":" out.RawString(prefix) - out.Uint64(x.ParentId) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.ParentId, 10) + out.RawByte('"') } { - const prefix string = ",\"nodeId\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"nodeId\":" out.RawString(prefix) - out.Uint64(x.NodeId) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.NodeId, 10) + out.RawByte('"') } { - const prefix string = ",\"meta\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"meta\":" out.RawString(prefix) out.RawByte('[') for i := range x.Meta { @@ -2566,9 +8664,18 @@ func (x *MoveRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawByte(']') } { - const prefix string = ",\"bearerToken\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"bearerToken\":" out.RawString(prefix) - out.Base64Bytes(x.BearerToken) + if x.BearerToken != nil { + out.Base64Bytes(x.BearerToken) + } else { + out.String("") + } } out.RawByte('}') } @@ -2601,7 +8708,13 @@ func (x *MoveRequest_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { case "containerId": { var f []byte - f = in.Bytes() + { + tmp := in.Bytes() + if len(tmp) == 0 { + tmp = nil + } + f = tmp + } x.ContainerId = f } case "treeId": @@ -2613,13 +8726,29 @@ func (x *MoveRequest_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { case "parentId": { var f uint64 - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv x.ParentId = f } case "nodeId": { var f uint64 - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv x.NodeId = f } case "meta": @@ -2639,7 +8768,13 @@ func (x *MoveRequest_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { case "bearerToken": { var f []byte - f = in.Bytes() + { + tmp := in.Bytes() + if len(tmp) == 0 { + tmp = nil + } + f = tmp + } x.BearerToken = f } } @@ -2775,14 +8910,25 @@ func (x *MoveRequest) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) x.Body.MarshalEasyJSON(out) } { - const prefix string = ",\"signature\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" out.RawString(prefix) x.Signature.MarshalEasyJSON(out) } @@ -3056,14 +9202,25 @@ func (x *MoveResponse) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) x.Body.MarshalEasyJSON(out) } { - const prefix string = ",\"signature\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" out.RawString(prefix) x.Signature.MarshalEasyJSON(out) } @@ -3338,24 +9495,49 @@ func (x *GetNodeByPathRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"containerId\":" - out.RawString(prefix[1:]) - out.Base64Bytes(x.ContainerId) + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"containerId\":" + out.RawString(prefix) + if x.ContainerId != nil { + out.Base64Bytes(x.ContainerId) + } else { + out.String("") + } } { - const prefix string = ",\"treeId\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"treeId\":" out.RawString(prefix) out.String(x.TreeId) } { - const prefix string = ",\"pathAttribute\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"pathAttribute\":" out.RawString(prefix) out.String(x.PathAttribute) } { - const prefix string = ",\"path\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"path\":" out.RawString(prefix) out.RawByte('[') for i := range x.Path { @@ -3367,7 +9549,12 @@ func (x *GetNodeByPathRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawByte(']') } { - const prefix string = ",\"attributes\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"attributes\":" out.RawString(prefix) out.RawByte('[') for i := range x.Attributes { @@ -3379,19 +9566,38 @@ func (x *GetNodeByPathRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawByte(']') } { - const prefix string = ",\"latestOnly\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"latestOnly\":" out.RawString(prefix) out.Bool(x.LatestOnly) } { - const prefix string = ",\"allAttributes\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"allAttributes\":" out.RawString(prefix) out.Bool(x.AllAttributes) } { - const prefix string = ",\"bearerToken\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"bearerToken\":" out.RawString(prefix) - out.Base64Bytes(x.BearerToken) + if x.BearerToken != nil { + out.Base64Bytes(x.BearerToken) + } else { + out.String("") + } } out.RawByte('}') } @@ -3424,7 +9630,13 @@ func (x *GetNodeByPathRequest_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { case "containerId": { var f []byte - f = in.Bytes() + { + tmp := in.Bytes() + if len(tmp) == 0 { + tmp = nil + } + f = tmp + } x.ContainerId = f } case "treeId": @@ -3480,7 +9692,13 @@ func (x *GetNodeByPathRequest_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { case "bearerToken": { var f []byte - f = in.Bytes() + { + tmp := in.Bytes() + if len(tmp) == 0 { + tmp = nil + } + f = tmp + } x.BearerToken = f } } @@ -3616,14 +9834,25 @@ func (x *GetNodeByPathRequest) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) x.Body.MarshalEasyJSON(out) } { - const prefix string = ",\"signature\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" out.RawString(prefix) x.Signature.MarshalEasyJSON(out) } @@ -3824,19 +10053,39 @@ func (x *GetNodeByPathResponse_Info) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"nodeId\":" - out.RawString(prefix[1:]) - out.Uint64(x.NodeId) - } - { - const prefix string = ",\"timestamp\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"nodeId\":" out.RawString(prefix) - out.Uint64(x.Timestamp) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.NodeId, 10) + out.RawByte('"') } { - const prefix string = ",\"meta\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"timestamp\":" + out.RawString(prefix) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.Timestamp, 10) + out.RawByte('"') + } + { + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"meta\":" out.RawString(prefix) out.RawByte('[') for i := range x.Meta { @@ -3848,9 +10097,16 @@ func (x *GetNodeByPathResponse_Info) MarshalEasyJSON(out *jwriter.Writer) { out.RawByte(']') } { - const prefix string = ",\"parentId\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"parentId\":" out.RawString(prefix) - out.Uint64(x.ParentId) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.ParentId, 10) + out.RawByte('"') } out.RawByte('}') } @@ -3883,13 +10139,29 @@ func (x *GetNodeByPathResponse_Info) UnmarshalEasyJSON(in *jlexer.Lexer) { case "nodeId": { var f uint64 - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv x.NodeId = f } case "timestamp": { var f uint64 - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv x.Timestamp = f } case "meta": @@ -3909,7 +10181,15 @@ func (x *GetNodeByPathResponse_Info) UnmarshalEasyJSON(in *jlexer.Lexer) { case "parentId": { var f uint64 - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv x.ParentId = f } } @@ -4007,10 +10287,16 @@ func (x *GetNodeByPathResponse_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"nodes\":" - out.RawString(prefix[1:]) + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"nodes\":" + out.RawString(prefix) out.RawByte('[') for i := range x.Nodes { if i != 0 { @@ -4195,14 +10481,25 @@ func (x *GetNodeByPathResponse) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) x.Body.MarshalEasyJSON(out) } { - const prefix string = ",\"signature\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" out.RawString(prefix) x.Signature.MarshalEasyJSON(out) } @@ -4369,11 +10666,22 @@ func (x *GetSubTreeRequest_Body_Order) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"direction\":" - out.RawString(prefix[1:]) - out.Int32(int32(x.Direction)) + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"direction\":" + out.RawString(prefix) + v := int32(x.Direction) + if vv, ok := GetSubTreeRequest_Body_Order_Direction_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) + } } out.RawByte('}') } @@ -4619,41 +10927,82 @@ func (x *GetSubTreeRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"containerId\":" - out.RawString(prefix[1:]) - out.Base64Bytes(x.ContainerId) + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"containerId\":" + out.RawString(prefix) + if x.ContainerId != nil { + out.Base64Bytes(x.ContainerId) + } else { + out.String("") + } } { - const prefix string = ",\"treeId\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"treeId\":" out.RawString(prefix) out.String(x.TreeId) } { - const prefix string = ",\"rootId\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"rootId\":" out.RawString(prefix) out.RawByte('[') for i := range x.RootId { if i != 0 { out.RawByte(',') } - out.Uint64(x.RootId[i]) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.RootId[i], 10) + out.RawByte('"') } out.RawByte(']') } { - const prefix string = ",\"depth\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"depth\":" out.RawString(prefix) out.Uint32(x.Depth) } { - const prefix string = ",\"bearerToken\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"bearerToken\":" out.RawString(prefix) - out.Base64Bytes(x.BearerToken) + if x.BearerToken != nil { + out.Base64Bytes(x.BearerToken) + } else { + out.String("") + } } { - const prefix string = ",\"orderBy\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"orderBy\":" out.RawString(prefix) x.OrderBy.MarshalEasyJSON(out) } @@ -4688,7 +11037,13 @@ func (x *GetSubTreeRequest_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { case "containerId": { var f []byte - f = in.Bytes() + { + tmp := in.Bytes() + if len(tmp) == 0 { + tmp = nil + } + f = tmp + } x.ContainerId = f } case "treeId": @@ -4703,7 +11058,15 @@ func (x *GetSubTreeRequest_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { var list []uint64 in.Delim('[') for !in.IsDelim(']') { - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv list = append(list, f) in.WantComma() } @@ -4713,13 +11076,27 @@ func (x *GetSubTreeRequest_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { case "depth": { var f uint32 - f = in.Uint32() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 32) + if err != nil { + in.AddError(err) + return + } + pv := uint32(v) + f = pv x.Depth = f } case "bearerToken": { var f []byte - f = in.Bytes() + { + tmp := in.Bytes() + if len(tmp) == 0 { + tmp = nil + } + f = tmp + } x.BearerToken = f } case "orderBy": @@ -4862,14 +11239,25 @@ func (x *GetSubTreeRequest) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) x.Body.MarshalEasyJSON(out) } { - const prefix string = ",\"signature\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" out.RawString(prefix) x.Signature.MarshalEasyJSON(out) } @@ -5076,45 +11464,72 @@ func (x *GetSubTreeResponse_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"nodeId\":" - out.RawString(prefix[1:]) + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"nodeId\":" + out.RawString(prefix) out.RawByte('[') for i := range x.NodeId { if i != 0 { out.RawByte(',') } - out.Uint64(x.NodeId[i]) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.NodeId[i], 10) + out.RawByte('"') } out.RawByte(']') } { - const prefix string = ",\"parentId\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"parentId\":" out.RawString(prefix) out.RawByte('[') for i := range x.ParentId { if i != 0 { out.RawByte(',') } - out.Uint64(x.ParentId[i]) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.ParentId[i], 10) + out.RawByte('"') } out.RawByte(']') } { - const prefix string = ",\"timestamp\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"timestamp\":" out.RawString(prefix) out.RawByte('[') for i := range x.Timestamp { if i != 0 { out.RawByte(',') } - out.Uint64(x.Timestamp[i]) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.Timestamp[i], 10) + out.RawByte('"') } out.RawByte(']') } { - const prefix string = ",\"meta\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"meta\":" out.RawString(prefix) out.RawByte('[') for i := range x.Meta { @@ -5159,7 +11574,15 @@ func (x *GetSubTreeResponse_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { var list []uint64 in.Delim('[') for !in.IsDelim(']') { - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv list = append(list, f) in.WantComma() } @@ -5172,7 +11595,15 @@ func (x *GetSubTreeResponse_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { var list []uint64 in.Delim('[') for !in.IsDelim(']') { - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv list = append(list, f) in.WantComma() } @@ -5185,7 +11616,15 @@ func (x *GetSubTreeResponse_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { var list []uint64 in.Delim('[') for !in.IsDelim(']') { - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv list = append(list, f) in.WantComma() } @@ -5339,14 +11778,25 @@ func (x *GetSubTreeResponse) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) x.Body.MarshalEasyJSON(out) } { - const prefix string = ",\"signature\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" out.RawString(prefix) x.Signature.MarshalEasyJSON(out) } @@ -5481,11 +11931,21 @@ func (x *TreeListRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"containerId\":" - out.RawString(prefix[1:]) - out.Base64Bytes(x.ContainerId) + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"containerId\":" + out.RawString(prefix) + if x.ContainerId != nil { + out.Base64Bytes(x.ContainerId) + } else { + out.String("") + } } out.RawByte('}') } @@ -5518,7 +11978,13 @@ func (x *TreeListRequest_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { case "containerId": { var f []byte - f = in.Bytes() + { + tmp := in.Bytes() + if len(tmp) == 0 { + tmp = nil + } + f = tmp + } x.ContainerId = f } } @@ -5654,14 +12120,25 @@ func (x *TreeListRequest) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) x.Body.MarshalEasyJSON(out) } { - const prefix string = ",\"signature\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" out.RawString(prefix) x.Signature.MarshalEasyJSON(out) } @@ -5796,10 +12273,16 @@ func (x *TreeListResponse_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"ids\":" - out.RawString(prefix[1:]) + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"ids\":" + out.RawString(prefix) out.RawByte('[') for i := range x.Ids { if i != 0 { @@ -5983,14 +12466,25 @@ func (x *TreeListResponse) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) x.Body.MarshalEasyJSON(out) } { - const prefix string = ",\"signature\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" out.RawString(prefix) x.Signature.MarshalEasyJSON(out) } @@ -6168,19 +12662,39 @@ func (x *ApplyRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"containerId\":" - out.RawString(prefix[1:]) - out.Base64Bytes(x.ContainerId) + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"containerId\":" + out.RawString(prefix) + if x.ContainerId != nil { + out.Base64Bytes(x.ContainerId) + } else { + out.String("") + } } { - const prefix string = ",\"treeId\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"treeId\":" out.RawString(prefix) out.String(x.TreeId) } { - const prefix string = ",\"operation\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"operation\":" out.RawString(prefix) x.Operation.MarshalEasyJSON(out) } @@ -6215,7 +12729,13 @@ func (x *ApplyRequest_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { case "containerId": { var f []byte - f = in.Bytes() + { + tmp := in.Bytes() + if len(tmp) == 0 { + tmp = nil + } + f = tmp + } x.ContainerId = f } case "treeId": @@ -6364,14 +12884,25 @@ func (x *ApplyRequest) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) x.Body.MarshalEasyJSON(out) } { - const prefix string = ",\"signature\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" out.RawString(prefix) x.Signature.MarshalEasyJSON(out) } @@ -6645,14 +13176,25 @@ func (x *ApplyResponse) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) x.Body.MarshalEasyJSON(out) } { - const prefix string = ",\"signature\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" out.RawString(prefix) x.Signature.MarshalEasyJSON(out) } @@ -6847,26 +13389,55 @@ func (x *GetOpLogRequest_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"containerId\":" - out.RawString(prefix[1:]) - out.Base64Bytes(x.ContainerId) + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"containerId\":" + out.RawString(prefix) + if x.ContainerId != nil { + out.Base64Bytes(x.ContainerId) + } else { + out.String("") + } } { - const prefix string = ",\"treeId\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"treeId\":" out.RawString(prefix) out.String(x.TreeId) } { - const prefix string = ",\"height\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"height\":" out.RawString(prefix) - out.Uint64(x.Height) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.Height, 10) + out.RawByte('"') } { - const prefix string = ",\"count\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"count\":" out.RawString(prefix) - out.Uint64(x.Count) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.Count, 10) + out.RawByte('"') } out.RawByte('}') } @@ -6899,7 +13470,13 @@ func (x *GetOpLogRequest_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { case "containerId": { var f []byte - f = in.Bytes() + { + tmp := in.Bytes() + if len(tmp) == 0 { + tmp = nil + } + f = tmp + } x.ContainerId = f } case "treeId": @@ -6911,13 +13488,29 @@ func (x *GetOpLogRequest_Body) UnmarshalEasyJSON(in *jlexer.Lexer) { case "height": { var f uint64 - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv x.Height = f } case "count": { var f uint64 - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv x.Count = f } } @@ -7053,14 +13646,25 @@ func (x *GetOpLogRequest) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) x.Body.MarshalEasyJSON(out) } { - const prefix string = ",\"signature\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" out.RawString(prefix) x.Signature.MarshalEasyJSON(out) } @@ -7198,10 +13802,16 @@ func (x *GetOpLogResponse_Body) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"operation\":" - out.RawString(prefix[1:]) + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"operation\":" + out.RawString(prefix) x.Operation.MarshalEasyJSON(out) } out.RawByte('}') @@ -7372,14 +13982,25 @@ func (x *GetOpLogResponse) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) x.Body.MarshalEasyJSON(out) } { - const prefix string = ",\"signature\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" out.RawString(prefix) x.Signature.MarshalEasyJSON(out) } @@ -7653,14 +14274,25 @@ func (x *HealthcheckResponse) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) x.Body.MarshalEasyJSON(out) } { - const prefix string = ",\"signature\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" out.RawString(prefix) x.Signature.MarshalEasyJSON(out) } @@ -7934,14 +14566,25 @@ func (x *HealthcheckRequest) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"body\":" + out.RawString(prefix) x.Body.MarshalEasyJSON(out) } { - const prefix string = ",\"signature\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" out.RawString(prefix) x.Signature.MarshalEasyJSON(out) } diff --git a/pkg/services/tree/service_grpc.pb.go b/pkg/services/tree/service_grpc.pb.go index 63f96e11a..e04e43aea 100644 --- a/pkg/services/tree/service_grpc.pb.go +++ b/pkg/services/tree/service_grpc.pb.go @@ -22,16 +22,23 @@ import ( const _ = grpc.SupportPackageIsVersion7 const ( - TreeService_Add_FullMethodName = "/tree.TreeService/Add" - TreeService_AddByPath_FullMethodName = "/tree.TreeService/AddByPath" - TreeService_Remove_FullMethodName = "/tree.TreeService/Remove" - TreeService_Move_FullMethodName = "/tree.TreeService/Move" - TreeService_GetNodeByPath_FullMethodName = "/tree.TreeService/GetNodeByPath" - TreeService_GetSubTree_FullMethodName = "/tree.TreeService/GetSubTree" - TreeService_TreeList_FullMethodName = "/tree.TreeService/TreeList" - TreeService_Apply_FullMethodName = "/tree.TreeService/Apply" - TreeService_GetOpLog_FullMethodName = "/tree.TreeService/GetOpLog" - TreeService_Healthcheck_FullMethodName = "/tree.TreeService/Healthcheck" + TreeService_Add_FullMethodName = "/tree.TreeService/Add" + TreeService_AddByPath_FullMethodName = "/tree.TreeService/AddByPath" + TreeService_Remove_FullMethodName = "/tree.TreeService/Remove" + TreeService_Move_FullMethodName = "/tree.TreeService/Move" + TreeService_GetNodeByPath_FullMethodName = "/tree.TreeService/GetNodeByPath" + TreeService_GetSubTree_FullMethodName = "/tree.TreeService/GetSubTree" + TreeService_TreeList_FullMethodName = "/tree.TreeService/TreeList" + TreeService_Apply_FullMethodName = "/tree.TreeService/Apply" + TreeService_GetOpLog_FullMethodName = "/tree.TreeService/GetOpLog" + TreeService_Healthcheck_FullMethodName = "/tree.TreeService/Healthcheck" + TreeService_BurnedAdd_FullMethodName = "/tree.TreeService/BurnedAdd" + TreeService_BurnedRemove_FullMethodName = "/tree.TreeService/BurnedRemove" + TreeService_BurnedApply_FullMethodName = "/tree.TreeService/BurnedApply" + TreeService_BurnedGet_FullMethodName = "/tree.TreeService/BurnedGet" + TreeService_BurnedGetLatestByPrefix_FullMethodName = "/tree.TreeService/BurnedGetLatestByPrefix" + TreeService_BurnedListByPrefix_FullMethodName = "/tree.TreeService/BurnedListByPrefix" + TreeService_BurnedList_FullMethodName = "/tree.TreeService/BurnedList" ) // TreeServiceClient is the client API for TreeService service. @@ -59,6 +66,13 @@ type TreeServiceClient interface { GetOpLog(ctx context.Context, in *GetOpLogRequest, opts ...grpc.CallOption) (TreeService_GetOpLogClient, error) // Healthcheck is a dummy rpc to check service availability Healthcheck(ctx context.Context, in *HealthcheckRequest, opts ...grpc.CallOption) (*HealthcheckResponse, error) + BurnedAdd(ctx context.Context, in *BurnedAddRequest, opts ...grpc.CallOption) (*BurnedAddResponse, error) + BurnedRemove(ctx context.Context, in *BurnedRemoveRequest, opts ...grpc.CallOption) (*BurnedRemoveResponse, error) + BurnedApply(ctx context.Context, in *BurnedApplyRequest, opts ...grpc.CallOption) (*BurnedApplyResponse, error) + BurnedGet(ctx context.Context, in *BurnedGetRequest, opts ...grpc.CallOption) (*BurnedGetResponse, error) + BurnedGetLatestByPrefix(ctx context.Context, in *BurnedGetLatestByPrefixRequest, opts ...grpc.CallOption) (*BurnedGetLatestByPrefixResponse, error) + BurnedListByPrefix(ctx context.Context, in *BurnedListByPrefixRequest, opts ...grpc.CallOption) (*BurnedListByPrefixResponse, error) + BurnedList(ctx context.Context, in *BurnedListRequest, opts ...grpc.CallOption) (TreeService_BurnedListClient, error) } type treeServiceClient struct { @@ -205,6 +219,92 @@ func (c *treeServiceClient) Healthcheck(ctx context.Context, in *HealthcheckRequ return out, nil } +func (c *treeServiceClient) BurnedAdd(ctx context.Context, in *BurnedAddRequest, opts ...grpc.CallOption) (*BurnedAddResponse, error) { + out := new(BurnedAddResponse) + err := c.cc.Invoke(ctx, TreeService_BurnedAdd_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *treeServiceClient) BurnedRemove(ctx context.Context, in *BurnedRemoveRequest, opts ...grpc.CallOption) (*BurnedRemoveResponse, error) { + out := new(BurnedRemoveResponse) + err := c.cc.Invoke(ctx, TreeService_BurnedRemove_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *treeServiceClient) BurnedApply(ctx context.Context, in *BurnedApplyRequest, opts ...grpc.CallOption) (*BurnedApplyResponse, error) { + out := new(BurnedApplyResponse) + err := c.cc.Invoke(ctx, TreeService_BurnedApply_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *treeServiceClient) BurnedGet(ctx context.Context, in *BurnedGetRequest, opts ...grpc.CallOption) (*BurnedGetResponse, error) { + out := new(BurnedGetResponse) + err := c.cc.Invoke(ctx, TreeService_BurnedGet_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *treeServiceClient) BurnedGetLatestByPrefix(ctx context.Context, in *BurnedGetLatestByPrefixRequest, opts ...grpc.CallOption) (*BurnedGetLatestByPrefixResponse, error) { + out := new(BurnedGetLatestByPrefixResponse) + err := c.cc.Invoke(ctx, TreeService_BurnedGetLatestByPrefix_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *treeServiceClient) BurnedListByPrefix(ctx context.Context, in *BurnedListByPrefixRequest, opts ...grpc.CallOption) (*BurnedListByPrefixResponse, error) { + out := new(BurnedListByPrefixResponse) + err := c.cc.Invoke(ctx, TreeService_BurnedListByPrefix_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *treeServiceClient) BurnedList(ctx context.Context, in *BurnedListRequest, opts ...grpc.CallOption) (TreeService_BurnedListClient, error) { + stream, err := c.cc.NewStream(ctx, &TreeService_ServiceDesc.Streams[2], TreeService_BurnedList_FullMethodName, opts...) + if err != nil { + return nil, err + } + x := &treeServiceBurnedListClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type TreeService_BurnedListClient interface { + Recv() (*BurnedListResponse, error) + grpc.ClientStream +} + +type treeServiceBurnedListClient struct { + grpc.ClientStream +} + +func (x *treeServiceBurnedListClient) Recv() (*BurnedListResponse, error) { + m := new(BurnedListResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + // TreeServiceServer is the server API for TreeService service. // All implementations should embed UnimplementedTreeServiceServer // for forward compatibility @@ -230,6 +330,13 @@ type TreeServiceServer interface { GetOpLog(*GetOpLogRequest, TreeService_GetOpLogServer) error // Healthcheck is a dummy rpc to check service availability Healthcheck(context.Context, *HealthcheckRequest) (*HealthcheckResponse, error) + BurnedAdd(context.Context, *BurnedAddRequest) (*BurnedAddResponse, error) + BurnedRemove(context.Context, *BurnedRemoveRequest) (*BurnedRemoveResponse, error) + BurnedApply(context.Context, *BurnedApplyRequest) (*BurnedApplyResponse, error) + BurnedGet(context.Context, *BurnedGetRequest) (*BurnedGetResponse, error) + BurnedGetLatestByPrefix(context.Context, *BurnedGetLatestByPrefixRequest) (*BurnedGetLatestByPrefixResponse, error) + BurnedListByPrefix(context.Context, *BurnedListByPrefixRequest) (*BurnedListByPrefixResponse, error) + BurnedList(*BurnedListRequest, TreeService_BurnedListServer) error } // UnimplementedTreeServiceServer should be embedded to have forward compatible implementations. @@ -266,6 +373,27 @@ func (UnimplementedTreeServiceServer) GetOpLog(*GetOpLogRequest, TreeService_Get func (UnimplementedTreeServiceServer) Healthcheck(context.Context, *HealthcheckRequest) (*HealthcheckResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Healthcheck not implemented") } +func (UnimplementedTreeServiceServer) BurnedAdd(context.Context, *BurnedAddRequest) (*BurnedAddResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method BurnedAdd not implemented") +} +func (UnimplementedTreeServiceServer) BurnedRemove(context.Context, *BurnedRemoveRequest) (*BurnedRemoveResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method BurnedRemove not implemented") +} +func (UnimplementedTreeServiceServer) BurnedApply(context.Context, *BurnedApplyRequest) (*BurnedApplyResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method BurnedApply not implemented") +} +func (UnimplementedTreeServiceServer) BurnedGet(context.Context, *BurnedGetRequest) (*BurnedGetResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method BurnedGet not implemented") +} +func (UnimplementedTreeServiceServer) BurnedGetLatestByPrefix(context.Context, *BurnedGetLatestByPrefixRequest) (*BurnedGetLatestByPrefixResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method BurnedGetLatestByPrefix not implemented") +} +func (UnimplementedTreeServiceServer) BurnedListByPrefix(context.Context, *BurnedListByPrefixRequest) (*BurnedListByPrefixResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method BurnedListByPrefix not implemented") +} +func (UnimplementedTreeServiceServer) BurnedList(*BurnedListRequest, TreeService_BurnedListServer) error { + return status.Errorf(codes.Unimplemented, "method BurnedList not implemented") +} // UnsafeTreeServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to TreeServiceServer will @@ -464,6 +592,135 @@ func _TreeService_Healthcheck_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _TreeService_BurnedAdd_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(BurnedAddRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TreeServiceServer).BurnedAdd(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: TreeService_BurnedAdd_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TreeServiceServer).BurnedAdd(ctx, req.(*BurnedAddRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _TreeService_BurnedRemove_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(BurnedRemoveRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TreeServiceServer).BurnedRemove(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: TreeService_BurnedRemove_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TreeServiceServer).BurnedRemove(ctx, req.(*BurnedRemoveRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _TreeService_BurnedApply_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(BurnedApplyRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TreeServiceServer).BurnedApply(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: TreeService_BurnedApply_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TreeServiceServer).BurnedApply(ctx, req.(*BurnedApplyRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _TreeService_BurnedGet_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(BurnedGetRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TreeServiceServer).BurnedGet(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: TreeService_BurnedGet_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TreeServiceServer).BurnedGet(ctx, req.(*BurnedGetRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _TreeService_BurnedGetLatestByPrefix_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(BurnedGetLatestByPrefixRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TreeServiceServer).BurnedGetLatestByPrefix(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: TreeService_BurnedGetLatestByPrefix_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TreeServiceServer).BurnedGetLatestByPrefix(ctx, req.(*BurnedGetLatestByPrefixRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _TreeService_BurnedListByPrefix_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(BurnedListByPrefixRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TreeServiceServer).BurnedListByPrefix(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: TreeService_BurnedListByPrefix_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TreeServiceServer).BurnedListByPrefix(ctx, req.(*BurnedListByPrefixRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _TreeService_BurnedList_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(BurnedListRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(TreeServiceServer).BurnedList(m, &treeServiceBurnedListServer{stream}) +} + +type TreeService_BurnedListServer interface { + Send(*BurnedListResponse) error + grpc.ServerStream +} + +type treeServiceBurnedListServer struct { + grpc.ServerStream +} + +func (x *treeServiceBurnedListServer) Send(m *BurnedListResponse) error { + return x.ServerStream.SendMsg(m) +} + // TreeService_ServiceDesc is the grpc.ServiceDesc for TreeService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -503,6 +760,30 @@ var TreeService_ServiceDesc = grpc.ServiceDesc{ MethodName: "Healthcheck", Handler: _TreeService_Healthcheck_Handler, }, + { + MethodName: "BurnedAdd", + Handler: _TreeService_BurnedAdd_Handler, + }, + { + MethodName: "BurnedRemove", + Handler: _TreeService_BurnedRemove_Handler, + }, + { + MethodName: "BurnedApply", + Handler: _TreeService_BurnedApply_Handler, + }, + { + MethodName: "BurnedGet", + Handler: _TreeService_BurnedGet_Handler, + }, + { + MethodName: "BurnedGetLatestByPrefix", + Handler: _TreeService_BurnedGetLatestByPrefix_Handler, + }, + { + MethodName: "BurnedListByPrefix", + Handler: _TreeService_BurnedListByPrefix_Handler, + }, }, Streams: []grpc.StreamDesc{ { @@ -515,6 +796,11 @@ var TreeService_ServiceDesc = grpc.ServiceDesc{ Handler: _TreeService_GetOpLog_Handler, ServerStreams: true, }, + { + StreamName: "BurnedList", + Handler: _TreeService_BurnedList_Handler, + ServerStreams: true, + }, }, Metadata: "pkg/services/tree/service.proto", } diff --git a/pkg/services/tree/service_new.go b/pkg/services/tree/service_new.go new file mode 100644 index 000000000..deb0575e8 --- /dev/null +++ b/pkg/services/tree/service_new.go @@ -0,0 +1,229 @@ +package tree + +import ( + "context" + "errors" + + "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/pilorama" + cidSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id" +) + +func (s *Service) BurnedAdd(ctx context.Context, req *BurnedAddRequest) (*BurnedAddResponse, error) { + b := req.GetBody() + + var cid cidSDK.ID + if err := cid.Decode(b.GetContainerId()); err != nil { + return nil, err + } + + ns, pos, err := s.getContainerNodes(cid) + if err != nil { + return nil, err + } + if pos < 0 { + return nil, errors.New("the node is not in the container") + } + + d := pilorama.CIDDescriptor{CID: cid, Position: pos, Size: len(ns)} + meta := protoToMeta(b.GetMeta()) + key := b.GetKey() + if key == "" { + for i := range meta { + if meta[i].Key == pilorama.AttributeFilename { + key = string(meta[i].Value) + } + } + } + log, err := s.burned.Add(d, b.GetTreeId(), []byte(key), pilorama.Meta{ + Items: meta, + }) + if err != nil { + return nil, err + } + + _ = log + // s.pushToQueue(cid, b.GetTreeId(), log) + return &BurnedAddResponse{Body: &BurnedAddResponse_Body{}}, nil +} + +func (s *Service) BurnedRemove(ctx context.Context, req *BurnedRemoveRequest) (*BurnedRemoveResponse, error) { + b := req.GetBody() + + var cid cidSDK.ID + if err := cid.Decode(b.GetContainerId()); err != nil { + return nil, err + } + + ns, pos, err := s.getContainerNodes(cid) + if err != nil { + return nil, err + } + if pos < 0 { + return nil, errors.New("the node is not in the container") + } + + d := pilorama.CIDDescriptor{CID: cid, Position: pos, Size: len(ns)} + key := b.GetKey() + log, err := s.burned.Remove(d, b.GetTreeId(), []byte(key)) + if err != nil { + return nil, err + } + + _ = log + // s.pushToQueue(cid, b.GetTreeId(), log) + return &BurnedRemoveResponse{Body: &BurnedRemoveResponse_Body{}}, nil +} + +func (s *Service) BurnedApply(ctx context.Context, req *BurnedApplyRequest) (*BurnedApplyResponse, error) { + var cid cidSDK.ID + if err := cid.Decode(req.GetBody().GetContainerId()); err != nil { + return nil, err + } + + key := req.GetSignature().GetKey() + + _, pos, _, err := s.getContainerInfo(cid, key) + if err != nil { + return nil, err + } + if pos < 0 { + return nil, errors.New("`Apply` request must be signed by a container node") + } + + rawOp := req.GetBody().GetOp() + var op pilorama.Operation + if err := op.FromBytes(rawOp); err != nil { + return nil, err + } + + // select { + // case s.replicateLocalCh <- applyOp{ + // treeID: req.GetBody().GetTreeId(), + // cid: cid, + // Move: pilorama.Move{ + // Parent: op.GetParentId(), + // Child: op.GetChildId(), + // Meta: meta, + // }, + // }: + // default: + // } + return &BurnedApplyResponse{Body: &BurnedApplyResponse_Body{}, Signature: &Signature{}}, nil +} + +func (s *Service) BurnedGet(ctx context.Context, req *BurnedGetRequest) (*BurnedGetResponse, error) { + b := req.GetBody() + + var cid cidSDK.ID + if err := cid.Decode(req.GetBody().GetContainerId()); err != nil { + return nil, err + } + + meta, err := s.burned.GetLatest(cid, b.GetTreeId(), []byte(b.GetKey())) + if err != nil { + return nil, err + } + + res := metaToProto(meta.Items) + return &BurnedGetResponse{ + Body: &BurnedGetResponse_Body{ + Timestamp: meta.Time, + Meta: res, + }, + }, nil +} + +func (s *Service) BurnedGetLatestByPrefix(ctx context.Context, req *BurnedGetLatestByPrefixRequest) (*BurnedGetLatestByPrefixResponse, error) { + b := req.GetBody() + + var cid cidSDK.ID + if err := cid.Decode(req.GetBody().GetContainerId()); err != nil { + return nil, err + } + + meta, err := s.burned.GetLatestByPrefix(cid, b.GetTreeId(), []byte(b.GetPrefix())) + if err != nil { + return nil, err + } + + res := metaToProto(meta.Meta.Items) + return &BurnedGetLatestByPrefixResponse{ + Body: &BurnedGetLatestByPrefixResponse_Body{ + Timestamp: meta.Meta.Time, + Meta: res, + }, + }, nil +} + +func (s *Service) BurnedListByPrefix(ctx context.Context, req *BurnedListByPrefixRequest) (*BurnedListByPrefixResponse, error) { + b := req.GetBody() + + var cid cidSDK.ID + if err := cid.Decode(req.GetBody().GetContainerId()); err != nil { + return nil, err + } + + vs, err := s.burned.ListByPrefix(cid, b.GetTreeId(), []byte(b.GetKey())) + if err != nil { + return nil, err + } + + res := &BurnedListByPrefixResponse{Body: &BurnedListByPrefixResponse_Body{}} + for i := range vs { + res.Body.List = append(res.Body.List, BurnedListByPrefixResponse_Body_Info{ + Key: string(vs[i].Key), + Timestamp: vs[i].Meta.Time, + Meta: metaToProto(vs[i].Meta.Items), + }) + } + return res, nil +} + +func (s *Service) BurnedList(req *BurnedListRequest, srv TreeService_BurnedListServer) error { + b := req.GetBody() + + var cid cidSDK.ID + if err := cid.Decode(req.GetBody().GetContainerId()); err != nil { + return err + } + + const count = 100 + + var start []byte + var inclusive bool + if len(b.GetStart()) != 0 { + start = []byte(b.GetStart()) + inclusive = true + } + for { + res, err := s.burned.ListAll(cid, b.GetTreeId(), pilorama.ListParam{ + Inclusive: inclusive, + Start: start, + Count: count, + }) + if err != nil { + return err + } + for i := range res { + meta, err := s.burned.GetLatest(cid, b.GetTreeId(), res[i]) + if err != nil { + return err + } + err = srv.Send(&BurnedListResponse{ + Body: &BurnedListResponse_Body{ + Key: string(res[i]), + Timestamp: meta.Time, + Meta: metaToProto(meta.Items), + }, + }) + if err != nil { + return err + } + } + if len(res) < count { + return nil + } + inclusive = false + start = res[len(res)-1] + } +} diff --git a/pkg/services/tree/types_frostfs.pb.go b/pkg/services/tree/types_frostfs.pb.go index 4399f8a8b..82723f04c 100644 --- a/pkg/services/tree/types_frostfs.pb.go +++ b/pkg/services/tree/types_frostfs.pb.go @@ -11,6 +11,7 @@ import ( easyproto "github.com/VictoriaMetrics/easyproto" jlexer "github.com/mailru/easyjson/jlexer" jwriter "github.com/mailru/easyjson/jwriter" + strconv "strconv" ) type KeyValue struct { @@ -113,16 +114,31 @@ func (x *KeyValue) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"key\":" - out.RawString(prefix[1:]) + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"key\":" + out.RawString(prefix) out.String(x.Key) } { - const prefix string = ",\"value\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"value\":" out.RawString(prefix) - out.Base64Bytes(x.Value) + if x.Value != nil { + out.Base64Bytes(x.Value) + } else { + out.String("") + } } out.RawByte('}') } @@ -161,7 +177,13 @@ func (x *KeyValue) UnmarshalEasyJSON(in *jlexer.Lexer) { case "value": { var f []byte - f = in.Bytes() + { + tmp := in.Bytes() + if len(tmp) == 0 { + tmp = nil + } + f = tmp + } x.Value = f } } @@ -293,21 +315,45 @@ func (x *LogMove) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"parentID\":" - out.RawString(prefix[1:]) - out.Uint64(x.ParentId) + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"parentID\":" + out.RawString(prefix) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.ParentId, 10) + out.RawByte('"') } { - const prefix string = ",\"meta\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"meta\":" out.RawString(prefix) - out.Base64Bytes(x.Meta) + if x.Meta != nil { + out.Base64Bytes(x.Meta) + } else { + out.String("") + } } { - const prefix string = ",\"childID\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"childID\":" out.RawString(prefix) - out.Uint64(x.ChildId) + out.RawByte('"') + out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.ChildId, 10) + out.RawByte('"') } out.RawByte('}') } @@ -340,19 +386,41 @@ func (x *LogMove) UnmarshalEasyJSON(in *jlexer.Lexer) { case "parentID": { var f uint64 - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv x.ParentId = f } case "meta": { var f []byte - f = in.Bytes() + { + tmp := in.Bytes() + if len(tmp) == 0 { + tmp = nil + } + f = tmp + } x.Meta = f } case "childID": { var f uint64 - f = in.Uint64() + r := in.JsonNumber() + n := r.String() + v, err := strconv.ParseUint(n, 10, 64) + if err != nil { + in.AddError(err) + return + } + pv := uint64(v) + f = pv x.ChildId = f } } @@ -464,16 +532,35 @@ func (x *Signature) MarshalEasyJSON(out *jwriter.Writer) { out.RawString("null") return } + first := true out.RawByte('{') { - const prefix string = ",\"key\":" - out.RawString(prefix[1:]) - out.Base64Bytes(x.Key) + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"key\":" + out.RawString(prefix) + if x.Key != nil { + out.Base64Bytes(x.Key) + } else { + out.String("") + } } { - const prefix string = ",\"signature\":" + if !first { + out.RawByte(',') + } else { + first = false + } + const prefix string = "\"signature\":" out.RawString(prefix) - out.Base64Bytes(x.Sign) + if x.Sign != nil { + out.Base64Bytes(x.Sign) + } else { + out.String("") + } } out.RawByte('}') } @@ -506,13 +593,25 @@ func (x *Signature) UnmarshalEasyJSON(in *jlexer.Lexer) { case "key": { var f []byte - f = in.Bytes() + { + tmp := in.Bytes() + if len(tmp) == 0 { + tmp = nil + } + f = tmp + } x.Key = f } case "signature": { var f []byte - f = in.Bytes() + { + tmp := in.Bytes() + if len(tmp) == 0 { + tmp = nil + } + f = tmp + } x.Sign = f } }