1
0
Fork 0
mirror of https://github.com/anyproto/any-sync.git synced 2025-06-07 21:47:02 +09:00
any-sync/commonspace/sync/synctest/counterrequest.go
2024-08-02 11:14:12 +02:00

42 lines
831 B
Go

package synctest
import (
"github.com/anyproto/protobuf/proto"
"github.com/anyproto/any-sync/commonspace/sync/synctestproto"
)
type CounterRequest struct {
peerId string
*synctestproto.CounterRequest
}
func (c CounterRequest) MsgSize() uint64 {
if c.CounterRequest != nil {
return uint64(proto.Size(c.CounterRequest))
} else {
return 0
}
}
func (c CounterRequest) Proto() (proto.Message, error) {
return c.CounterRequest, nil
}
func NewCounterRequest(peerId, objectId string, counters []int32) CounterRequest {
return CounterRequest{
peerId: peerId,
CounterRequest: &synctestproto.CounterRequest{
ExistingValues: counters,
ObjectId: objectId,
},
}
}
func (c CounterRequest) PeerId() string {
return c.peerId
}
func (c CounterRequest) ObjectId() string {
return c.CounterRequest.ObjectId
}