@@ -24,7 +24,6 @@ import (
24
24
"strconv"
25
25
"time"
26
26
27
- "github.com/transparency-dev/trillian-tessera/api/layout"
28
27
"github.com/transparency-dev/trillian-tessera/client"
29
28
"k8s.io/klog/v2"
30
29
)
@@ -50,24 +49,24 @@ type LocalBEDedupStorage interface {
50
49
type ParseBundleFunc func ([]byte , uint64 ) ([]LeafIdx , error )
51
50
52
51
// UpdateFromLog synchronises a local best effort deduplication storage with a log.
53
- func UpdateFromLog (ctx context.Context , lds LocalBEDedupStorage , t time.Duration , f client.Fetcher , pb ParseBundleFunc ) {
52
+ func UpdateFromLog (ctx context.Context , lds LocalBEDedupStorage , t time.Duration , fcp client.CheckpointFetcherFunc , fb client. EntryBundleFetcherFunc , pb ParseBundleFunc ) {
54
53
tck := time .NewTicker (t )
55
54
defer tck .Stop ()
56
55
for {
57
56
select {
58
57
case <- ctx .Done ():
59
58
return
60
59
case <- tck .C :
61
- if err := sync (ctx , lds , pb , f ); err != nil {
60
+ if err := sync (ctx , lds , pb , fcp , fb ); err != nil {
62
61
klog .Warningf ("error updating deduplication data: %v" , err )
63
62
}
64
63
}
65
64
}
66
65
}
67
66
68
67
// sync synchronises a deduplication storage with the corresponding log content.
69
- func sync (ctx context.Context , lds LocalBEDedupStorage , pb ParseBundleFunc , f client.Fetcher ) error {
70
- cpRaw , err := f (ctx , layout . CheckpointPath )
68
+ func sync (ctx context.Context , lds LocalBEDedupStorage , pb ParseBundleFunc , fcp client.CheckpointFetcherFunc , fb client. EntryBundleFetcherFunc ) error {
69
+ cpRaw , err := fcp (ctx )
71
70
if err != nil {
72
71
return fmt .Errorf ("error fetching checkpoint: %v" , err )
73
72
}
@@ -91,8 +90,7 @@ func sync(ctx context.Context, lds LocalBEDedupStorage, pb ParseBundleFunc, f cl
91
90
if ckptSize > oldSize {
92
91
klog .V (2 ).Infof ("LocalBEDEdup.sync(): log at size %d, dedup database at size %d, startig to sync" , ckptSize , oldSize )
93
92
for i := oldSize / 256 ; i <= ckptSize / 256 ; i ++ {
94
- p := fmt .Sprintf ("tile/data/%s" , layout .NWithSuffix (0 , i , ckptSize ))
95
- eRaw , err := f (ctx , p )
93
+ eRaw , err := fb (ctx , ckptSize , i )
96
94
if err != nil {
97
95
if errors .Is (err , os .ErrNotExist ) {
98
96
return fmt .Errorf ("leaf bundle at index %d not found: %v" , i , err )
0 commit comments