Skip to content

Commit

Permalink
Update callers
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCutter committed Jan 9, 2025
1 parent 88f6ad5 commit 0675db5
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
6 changes: 5 additions & 1 deletion storage/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,11 @@ func (s *Storage) integrate(ctx context.Context, fromSeq uint64, entries []stora
})

errG.Go(func() error {
newSize, root, tiles, err := storage.Integrate(ctx, getTiles, fromSeq, entries)
lh := make([][]byte, len(entries))
for i, e := range entries {
lh[i] = e.LeafHash
}
newSize, root, tiles, err := storage.Integrate(ctx, getTiles, fromSeq, lh)
if err != nil {
return fmt.Errorf("Integrate: %v", err)
}
Expand Down
6 changes: 5 additions & 1 deletion storage/gcp/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,11 @@ func (s *Storage) integrate(ctx context.Context, fromSeq uint64, entries []stora
return n, nil
}

newSize, root, tiles, err := storage.Integrate(ctx, getTiles, fromSeq, entries)
lh := make([][]byte, len(entries))
for i, e := range entries {
lh[i] = e.LeafHash
}
newSize, root, tiles, err := storage.Integrate(ctx, getTiles, fromSeq, lh)
if err != nil {
return fmt.Errorf("Integrate: %v", err)
}
Expand Down
6 changes: 5 additions & 1 deletion storage/mysql/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,11 @@ func (s *Storage) integrate(ctx context.Context, tx *sql.Tx, fromSeq uint64, ent
}
}

newSize, newRoot, tiles, err := storage.Integrate(ctx, getTiles, fromSeq, sequencedEntries)
lh := make([][]byte, len(sequencedEntries))
for i, e := range sequencedEntries {
lh[i] = e.LeafHash
}
newSize, newRoot, tiles, err := storage.Integrate(ctx, getTiles, fromSeq, lh)
if err != nil {
return fmt.Errorf("tb.Integrate: %v", err)
}
Expand Down
14 changes: 9 additions & 5 deletions storage/posix/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"github.com/transparency-dev/trillian-tessera/api"
"github.com/transparency-dev/trillian-tessera/api/layout"
"github.com/transparency-dev/trillian-tessera/internal/options"
"github.com/transparency-dev/trillian-tessera/storage/internal"
storage "github.com/transparency-dev/trillian-tessera/storage/internal"
"k8s.io/klog/v2"
)

Expand Down Expand Up @@ -258,15 +258,19 @@ func (s *Storage) sequenceBatch(ctx context.Context, entries []*tessera.Entry) e
}

// For simplicity, in-line the integration of these new entries into the Merkle structure too.
if err := s.doIntegrate(ctx, seq, seqEntries); err != nil {
lh := make([][]byte, len(entries))
for i, e := range entries {
lh[i] = e.LeafHash()
}
if err := s.doIntegrate(ctx, seq, lh); err != nil {
klog.Errorf("Integrate failed: %v", err)
return err
}
return nil
}

// doIntegrate handles integrating new entries into the log, and updating the tree state.
func (s *Storage) doIntegrate(ctx context.Context, fromSeq uint64, entries []storage.SequencedEntry) error {
// doIntegrate handles integrating new leaf hashes into the log, and updating the tree state.
func (s *Storage) doIntegrate(ctx context.Context, fromSeq uint64, leafHashes [][]byte) error {
getTiles := func(ctx context.Context, tileIDs []storage.TileID, treeSize uint64) ([]*api.HashTile, error) {
n, err := s.readTiles(ctx, tileIDs, treeSize)
if err != nil {
Expand All @@ -275,7 +279,7 @@ func (s *Storage) doIntegrate(ctx context.Context, fromSeq uint64, entries []sto
return n, nil
}

newSize, newRoot, tiles, err := storage.Integrate(ctx, getTiles, fromSeq, entries)
newSize, newRoot, tiles, err := storage.Integrate(ctx, getTiles, fromSeq, leafHashes)
if err != nil {
klog.Errorf("Integrate: %v", err)
return fmt.Errorf("Integrate: %v", err)
Expand Down

0 comments on commit 0675db5

Please sign in to comment.