Update comments from review

This commit is contained in:
Neil Alexander 2020-06-16 13:06:21 +01:00
parent 5a7e332d1f
commit 740db77e5b
2 changed files with 14 additions and 8 deletions

View file

@ -157,11 +157,17 @@ func (s *ServerKeyAPI) handleDatabaseKeys(
// We successfully got some keys. Add them to the results.
for req, res := range dbResults {
// The key we've retrieved from the database/cache might
// have passed its validity period, but right now, it's
// the best thing we've got, and it might be sufficient to
// verify a past event.
results[req] = res
// If the key is valid right now then we can also remove it
// from the request list as we don't need to fetch it again
// in that case.
// in that case. If the key isn't valid right now, then by
// leaving it in the 'requests' map, we'll try to update the
// key using the fetchers in handleFetcherKeys.
if res.WasValidAt(now, true) {
delete(requests, req)
}
@ -169,7 +175,7 @@ func (s *ServerKeyAPI) handleDatabaseKeys(
return nil
}
// handleDatabaseKeys handles cases where a fetcher can satisfy
// handleFetcherKeys handles cases where a fetcher can satisfy
// the remaining requests.
func (s *ServerKeyAPI) handleFetcherKeys(
ctx context.Context,

View file

@ -21,12 +21,12 @@ import (
)
type server struct {
name gomatrixserverlib.ServerName
validity time.Duration
config *config.Dendrite
fedclient *gomatrixserverlib.FederationClient
cache *caching.Caches
api api.ServerKeyInternalAPI
name gomatrixserverlib.ServerName // server name
validity time.Duration // key validity duration from now
config *config.Dendrite // skeleton config, from TestMain
fedclient *gomatrixserverlib.FederationClient // uses MockRoundTripper
cache *caching.Caches // server-specific cache
api api.ServerKeyInternalAPI // server-specific server key API
}
func (s *server) renew() {