[#2193] pilorama: Use do in TreeMove

It should be similar to a `TreeAddByPath`. `applyOperation` is used for
`Apply` when the operation can be inserted in the middle of a log.

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2022-12-30 16:29:11 +03:00 committed by fyrchik
parent ba393e3e91
commit b0ad1b9ed2

View file

@ -139,18 +139,18 @@ func (t *boltForest) TreeMove(d CIDDescriptor, treeID string, m *Move) (*LogMove
}
var lm LogMove
lm.Move = *m
return &lm, t.db.Batch(func(tx *bbolt.Tx) error {
bLog, bTree, err := t.getTreeBuckets(tx, d.CID, treeID)
if err != nil {
return err
}
m.Time = t.getLatestTimestamp(bLog, d.Position, d.Size)
if m.Child == RootID {
m.Child = t.findSpareID(bTree)
lm.Time = t.getLatestTimestamp(bLog, d.Position, d.Size)
if lm.Child == RootID {
lm.Child = t.findSpareID(bTree)
}
lm.Move = *m
return t.applyOperation(bLog, bTree, &lm)
return t.do(bLog, bTree, make([]byte, 17), &lm)
})
}