1
0
Fork 0
mirror of https://github.com/anyproto/any-sync.git synced 2025-06-08 05:57:03 +09:00
any-sync/commonspace/object/acl/syncacl/request.go
2024-06-24 21:29:16 +02:00

33 lines
830 B
Go

package syncacl
import (
"github.com/anyproto/any-sync/commonspace/sync/objectsync/objectmessages"
"github.com/anyproto/any-sync/consensus/consensusproto"
)
type InnerRequest struct {
head string
root *consensusproto.RawRecordWithId
}
func (r *InnerRequest) MsgSize() uint64 {
size := uint64(len(r.head))
size += uint64(len(r.root.Id))
size += uint64(len(r.root.Payload))
return size
}
func NewRequest(peerId, objectId, spaceId, head string, root *consensusproto.RawRecordWithId) *objectmessages.Request {
return objectmessages.NewRequest(peerId, spaceId, objectId, &InnerRequest{
head: head,
root: root,
})
}
func (r *InnerRequest) Marshall() ([]byte, error) {
req := &consensusproto.LogFullSyncRequest{
Head: r.head,
}
fullSync := consensusproto.WrapFullRequest(req, r.root)
return fullSync.Marshal()
}