-
Notifications
You must be signed in to change notification settings - Fork 151
Conversation
Codecov Report
@@ Coverage Diff @@
## master #915 +/- ##
==========================================
- Coverage 55.65% 55.29% -0.37%
==========================================
Files 33 33
Lines 2280 2295 +15
==========================================
Hits 1269 1269
- Misses 788 803 +15
Partials 223 223
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly suggestions. It's your repo so they may not all be appropriate.
core/keyserver/epochs.go
Outdated
}) | ||
if err != nil { | ||
glog.Warningf("GetSignedMapRootByRevision(%v, %v): %v", domain.MapID, in.Epoch, err) | ||
glog.Warningf("GetSignedMapRootByRevision(%v, %v): %v", d.MapID, revision, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This style of error message might make it hard to track down where they occurred. Might want to prefix the text with the rpc method name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea.
core/keyserver/epochs.go
Outdated
LogId: logID, | ||
}) | ||
// logProofs returns the proofs for a given epoch. | ||
func (s *Server) logProofs(ctx context.Context, d *domain.Domain, firstTreeSize int64, epoch int64) (*tpb.SignedLogRoot, *tpb.Proof, *tpb.Proof, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonder if the proofs for an epoch could be wrapped into a single object for a cleaner signature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a bit better.
core/keyserver/keyserver.go
Outdated
// - LogRoot | ||
// - LogConsistency | ||
func (s *Server) getEntryByRevision(ctx context.Context, sth *tpb.SignedLogRoot, d *domain.Domain, userID, appID string, revision int64) (*pb.GetEntryResponse, error) { | ||
if revision < int64(0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that cast required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope. Removed.
core/keyserver/keyserver.go
Outdated
logInclusion, err := s.tlog.GetInclusionProof(ctx, | ||
&tpb.GetInclusionProofRequest{ | ||
LogId: domain.LogID, | ||
LogId: d.LogID, | ||
// SignedMapRoot must be placed in the log at MapRevision. | ||
// MapRevisions start at 1. Log leaves start at 1. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you clarify meaning of "log leaves start at 1" here as leaf indices are 0 based.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment is incorrect. Updated:
MapRevisions start at 0. Log leaves start at 0.
core/keyserver/keyserver.go
Outdated
} | ||
|
||
// latestRevision returns the latest map revision, given the latest sth. | ||
// The log is the authoritative source of the latest revision. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming seems a bit odd given it takes a log STH and returns a map revision. mapRevisionFor() maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool
core/keyserver/keyserver.go
Outdated
}, nil | ||
} | ||
|
||
// ListEntryHistory returns a list of EntryProofs covering a period of time. | ||
func (s *Server) ListEntryHistory(ctx context.Context, in *pb.ListEntryHistoryRequest) (*pb.ListEntryHistoryResponse, error) { | ||
// Lookup log and map info. | ||
domain, err := s.domains.Read(ctx, in.DomainId, false) | ||
domainID := in.GetDomainId() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GetDomainId() - should be GetDomainID().
Also looks like you often get the id then do domains.Read() on it, which might be a helper perhaps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GetDomainId
is a function generated from protobuf. The protobuf people decided to not follow Go's standard for initialisms unfortunately: golang/protobuf#156.
The emerging pattern is that all user facing functions accept domain_id
and the first thing they do is domains.Read
. Not sure what the best way to pull out a helper. It feels more like an interceptor that puts something in ctx
, but that feels a little heavy handed and makes the code path harder to follow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, well it was just a suggestion.
@Martin2112 thank you for the review! |
ee38f27
to
94a2fa2
Compare
Refactor a few internal methods around for less copy-pasta.
94a2fa2
to
59bbc31
Compare
Now that #916 is in, this PR is a whole lot simpler! |
core/keyserver/epochs.go
Outdated
// Lookup log and map info. | ||
d, err := s.domains.Read(ctx, in.DomainId, false) | ||
if err != nil { | ||
glog.Errorf("adminstorage.Read(%v): %v", in.DomainId, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might want to prefix the errors with the method. Up to you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
core/keyserver/epochs.go
Outdated
return s.getEpochByRevision(ctx, d, in.GetFirstTreeSize(), currentEpoch) | ||
} | ||
|
||
// GetEpoch returns a the requested epoch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
The latest epoch is of interest in two use cases:
By offering this API, clients will be able to efficiently poll just the Log Root until it changes before requesting a full proof for an updated entry. This is more much more efficient and would remove the need for a client to needlessly resubmit their
UpdateEntry
requests before a new epoch has been created.