mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-08 05:57:03 +09:00
29 lines
832 B
Go
29 lines
832 B
Go
package synctree
|
|
|
|
import (
|
|
"github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto"
|
|
"github.com/anyproto/any-sync/commonspace/sync/objectsync"
|
|
)
|
|
|
|
type InnerRequest struct {
|
|
heads []string
|
|
snapshotPath []string
|
|
root *treechangeproto.RawTreeChangeWithId
|
|
}
|
|
|
|
func NewRequest(peerId, spaceId, objectId string, heads []string, snapshotPath []string, root *treechangeproto.RawTreeChangeWithId) *objectsync.Request {
|
|
return objectsync.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()
|
|
}
|