Skip to content

Commit

Permalink
AddToNCounter()
Browse files Browse the repository at this point in the history
  • Loading branch information
gritzko committed Apr 19, 2024
1 parent 35f31a3 commit ec326c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ func (cho *Chotki) SetFieldTLV(fid rdx.ID, tlve []byte) (id rdx.ID, err error) {

var ErrWrongFieldType = errors.New("wrong field type")

func (cho *Chotki) IncNField(fid rdx.ID) (id rdx.ID, err error) {
func (cho *Chotki) AddToNField(fid rdx.ID, count uint64) (id rdx.ID, err error) {
rdt, tlv, err := cho.ObjectFieldTLV(fid)
if err != nil || rdt != rdx.Natural {
return rdx.BadId, ErrWrongFieldType
Expand All @@ -340,12 +340,16 @@ func (cho *Chotki) IncNField(fid rdx.ID) (id rdx.ID, err error) {
mine := rdx.Nmine(tlv, src)
tlvs := toyqueue.Records{
toytlv.Record('F', rdx.ZipUint64(fid.Off())),
toytlv.Record(rdx.Natural, toytlv.Record(rdx.Term, rdx.ZipUint64Pair(mine+1, src))),
toytlv.Record(rdx.Natural, toytlv.Record(rdx.Term, rdx.ZipUint64Pair(mine+count, src))),
}
id, err = cho.CommitPacket('E', fid.ZeroOff(), tlvs)
return
}

func (cho *Chotki) IncNField(fid rdx.ID) (id rdx.ID, err error) {
return cho.AddToNField(fid, 1)
}

func (cho *Chotki) ObjectFieldMapTermId(fid rdx.ID) (themap map[string]rdx.ID, err error) {
rdt, tlv, e := cho.ObjectFieldTLV(fid)
if e != nil {
Expand Down
2 changes: 1 addition & 1 deletion pebble
Submodule pebble updated 599 files

0 comments on commit ec326c9

Please sign in to comment.