Skip to content

Commit

Permalink
code: ensure function comments for all new public methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin Bryce committed Aug 21, 2024
1 parent 70e2c67 commit 8c137f1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion massifs/enumeratepaths_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestEnumerateTenants(t *testing.T) {
seed := int64((1698342521) * 1000)
g := mmrtesting.NewTestGenerator(t, seed, mmrtesting.TestGeneratorConfig{
StartTimeMS: seed, EventRate: 500,
TestLabelPrefix: "TestEnumerateTenants"}, MMRTestingMMRTestingMMRTestingMMRTestingGenerateNumberedLeaf)
TestLabelPrefix: "TestEnumerateTenants"}, MMRTestingGenerateNumberedLeaf)

type args struct {
batches []tenantBatch
Expand Down
13 changes: 13 additions & 0 deletions massifs/localmassifreader.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,27 @@ func NewLocalReader(
return r, nil
}

// InReplicaMode returns true if the reader is in replica mode
func (r *LocalReader) InReplicaMode() bool {
return r.cache.Options().replicaDir == ""
}

// GetReplicaDir returns the replica directory
func (r *LocalReader) GetReplicaDir() string {
return r.cache.Options().replicaDir
}

// GetDirEntry returns the directory entry for the given tenant identity or local path
func (r *LocalReader) GetDirEntry(tenantIdentityOrLocalPath string) (*LogDirCacheEntry, bool) {
return r.cache.GetEntry(tenantIdentityOrLocalPath)
}

// ResolveDirectory resolves the tenant identity or local path to a directory
func (r *LocalReader) ResolveDirectory(tenantIdentityOrLocalPath string) (string, error) {
return r.cache.ResolveDirectory(tenantIdentityOrLocalPath)
}

// ReadMassifStart reads the massif start from the given log file
func (r *LocalReader) ReadMassifStart(logfile string) (MassifStart, string, error) {
return r.cache.ReadMassifStart(logfile)
}
Expand Down Expand Up @@ -119,6 +124,7 @@ func (r *LocalReader) GetHeadVerifiedContext(
return mc.verifyContext(ctx, options)
}

// VerifyContext verifies an arbitrary context and returns a verified context if this succeeds.
func (r *LocalReader) VerifyContext(
ctx context.Context, mc MassifContext,
opts ...ReaderOption,
Expand All @@ -130,6 +136,8 @@ func (r *LocalReader) VerifyContext(
return mc.verifyContext(ctx, options)
}

// ReplaceVerifiedContext replaces the verified context with an updated on, it
// is the callers responsibility to ensure the context was verified.
func (r *LocalReader) ReplaceVerifiedContext(
ctx context.Context, vc *VerifiedContext,
) error {
Expand All @@ -155,6 +163,7 @@ func (r *LocalReader) ReplaceVerifiedContext(
})
}

// GetMassif reads the massif identified by the tenant identity and massif index
func (r *LocalReader) GetMassif(
ctx context.Context, tenantIdentityOrLocalPath string, massifIndex uint64,
opts ...ReaderOption,
Expand All @@ -174,6 +183,7 @@ func (r *LocalReader) GetMassif(
return copyCachedMassifOrErr(r.cache.ReadMassif(directory, massifIndex))
}

// GetSeal reads the seal identified by the tenant identity and massif index
func (r *LocalReader) GetSeal(
ctx context.Context, tenantIdentityOrLocalPath string, massifIndex uint64,
opts ...ReaderOption,
Expand All @@ -193,6 +203,7 @@ func (r *LocalReader) GetSeal(
return copyCachedSealOrErr(r.cache.ReadSeal(directory, massifIndex))
}

// GetHeadMassif reads the most recent massif in the log identified by the tenant identity
func (r *LocalReader) GetHeadMassif(
ctx context.Context, tenantIdentityOrLocalPath string,
opts ...ReaderOption,
Expand Down Expand Up @@ -244,10 +255,12 @@ func (r *LocalReader) GetFirstMassif(
return copyCachedMassifOrErr(dirEntry.ReadMassif(r.cache, uint64(dirEntry.FirstMassifIndex)))
}

// GetMassifLocalPath returns the local path for the massif identified by the tenant identity and massif index
func (r *LocalReader) GetMassifLocalPath(tenantIdentity string, massifIndex uint32) string {
return filepath.Join(r.GetReplicaDir(), TenantRelativeMassifPath(tenantIdentity, massifIndex))
}

// GetSealLocalPath returns the local path for the seal identified by the tenant identity and massif index
func (r *LocalReader) GetSealLocalPath(tenantIdentity string, massifIndex uint32) string {
return filepath.Join(r.GetReplicaDir(), TenantRelativeSealPath(tenantIdentity, massifIndex))
}
Expand Down
4 changes: 4 additions & 0 deletions massifs/massifcontextverified.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type VerifiedContext struct {
ConsistentRoots []byte
}

// checkedVerifiedContextOptions checks the options provided satisfy the common requirements of the reader methods
func checkedVerifiedContextOptions(baseOpts ReaderOptions, opts ...ReaderOption) (ReaderOptions, error) {
options := ReaderOptionsCopy(baseOpts)
for _, o := range opts {
Expand Down Expand Up @@ -114,6 +115,8 @@ func (mr *MassifReader) GetVerifiedContext(
return mc.verifyContext(ctx, options)
}

// VerifyContext verifies an arbitrary context and returns a verified context if this succeeds.
// This performs the same checks as GetVerifiedContext
func (mr *MassifReader) VerifyContext(
ctx context.Context, mc MassifContext,
opts ...ReaderOption,
Expand All @@ -125,6 +128,7 @@ func (mr *MassifReader) VerifyContext(
return mc.verifyContext(ctx, options)
}

// VerifyContext verifies the context and returns a verified context if this succeeds.
func (mc *MassifContext) VerifyContext(
ctx context.Context,
opts ...ReaderOption,
Expand Down

0 comments on commit 8c137f1

Please sign in to comment.