Skip to content

Commit

Permalink
fixup: modify in-place for removeSequencedLeaves
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddrysdale committed Feb 27, 2017
1 parent e5ecf95 commit 2483f92
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions storage/mysql/log_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,21 +528,20 @@ func (t *logTreeTX) UpdateSequencedLeaves(leaves []*trillian.LogLeaf) error {
return nil
}

// removeSequencedLeaves removes the passed in leaves slice (which may be
// modified as part of the operation).
func (t *logTreeTX) removeSequencedLeaves(leaves []*trillian.LogLeaf) error {

// Delete in order of the hash values in the leaves.
orderedLeaves := make([]*trillian.LogLeaf, len(leaves))
copy(orderedLeaves, leaves)
sort.Sort(byLeafIdentityHash(orderedLeaves))
sort.Sort(byLeafIdentityHash(leaves))

tmpl, err := t.ls.getDeleteUnsequencedStmt(len(orderedLeaves))
tmpl, err := t.ls.getDeleteUnsequencedStmt(len(leaves))
if err != nil {
glog.Warningf("Failed to get delete statement for sequenced work: %s", err)
return err
}
stx := t.tx.Stmt(tmpl)
var args []interface{}
for _, leaf := range orderedLeaves {
for _, leaf := range leaves {
args = append(args, interface{}(leaf.LeafIdentityHash))
}
args = append(args, interface{}(t.treeID))
Expand All @@ -555,7 +554,7 @@ func (t *logTreeTX) removeSequencedLeaves(leaves []*trillian.LogLeaf) error {
glog.Warningf("Failed to delete sequenced work: %s", err)
}

err = checkResultOkAndRowCountIs(result, err, int64(len(orderedLeaves)))
err = checkResultOkAndRowCountIs(result, err, int64(len(leaves)))

if err != nil {
return err
Expand Down

0 comments on commit 2483f92

Please sign in to comment.