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/tree/synctree/request.go
2024-06-17 13:47:42 +02:00

29 lines
855 B
Go

package synctree
import (
"github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto"
"github.com/anyproto/any-sync/commonspace/sync/objectsync/objectmessages"
)
type InnerRequest struct {
heads []string
snapshotPath []string
root *treechangeproto.RawTreeChangeWithId
}
func NewRequest(peerId, spaceId, objectId string, heads []string, snapshotPath []string, root *treechangeproto.RawTreeChangeWithId) *objectmessages.Request {
return objectmessages.NewRequest(peerId, spaceId, objectId, &InnerRequest{
heads: heads,
snapshotPath: snapshotPath,
root: root,
})
}
func (r *InnerRequest) Marshall() ([]byte, error) {
msg := &treechangeproto.TreeFullSyncRequest{
Heads: r.heads,
SnapshotPath: r.snapshotPath,
}
req := treechangeproto.WrapFullRequest(msg, r.root)
return req.Marshal()
}