1
0
Fork 0
mirror of https://github.com/anyproto/any-sync.git synced 2025-06-08 14:07:02 +09:00

Work on reduce

This commit is contained in:
mcrakhman 2024-11-17 18:42:21 +01:00
parent 0665e386ea
commit 046006d006
No known key found for this signature in database
GPG key ID: DED12CFEF5B8396B
5 changed files with 83 additions and 52 deletions

View file

@ -83,7 +83,7 @@ func (tb *treeBuilder) build(opts treeBuilderOpts) (tr *Tree, err error) {
} else {
snapshot = tb.treeStorage.Id()
}
snapshotCh, err := tb.storage.GetOne(tb.ctx, snapshot)
snapshotCh, err := tb.storage.Get(tb.ctx, snapshot)
if err != nil {
return nil, err
}
@ -149,9 +149,10 @@ func (tb *treeBuilder) commonSnapshot(snapshots []string) (snapshot string, err
current []StorageChange
lowestCounter = intsets.MaxInt
)
// TODO: we should actually check for all changes if they have valid snapshots
// getting actual snapshots
for _, id := range snapshots {
ch, err := tb.storage.GetOne(tb.ctx, id)
ch, err := tb.storage.Get(tb.ctx, id)
if err != nil {
log.Error("failed to get snapshot", zap.String("id", id), zap.Error(err))
continue
@ -164,7 +165,7 @@ func (tb *treeBuilder) commonSnapshot(snapshots []string) (snapshot string, err
// equalizing counters for each snapshot branch
for i, ch := range current {
for ch.SnapshotCounter > lowestCounter {
ch, err = tb.storage.GetOne(tb.ctx, ch.SnapshotId)
ch, err = tb.storage.Get(tb.ctx, ch.SnapshotId)
if err != nil {
return "", err
}
@ -196,7 +197,7 @@ func (tb *treeBuilder) commonSnapshot(snapshots []string) (snapshot string, err
}
// go down one counter
for i, ch := range current {
ch, err = tb.storage.GetOne(tb.ctx, ch.SnapshotId)
ch, err = tb.storage.Get(tb.ctx, ch.SnapshotId)
if err != nil {
return "", err
}