MCPcopy Create free account
hub / github.com/daodst/chat / FetchKeys

Method FetchKeys

federationapi/storage/cache/keydb.go:37–57  ·  view source on GitHub ↗

FetchKeys implements gomatrixserverlib.KeyDatabase

(
	ctx context.Context,
	requests map[gomatrixserverlib.PublicKeyLookupRequest]gomatrixserverlib.Timestamp,
)

Source from the content-addressed store, hash-verified

35
36// FetchKeys implements gomatrixserverlib.KeyDatabase
37func (d *KeyDatabase) FetchKeys(
38 ctx context.Context,
39 requests map[gomatrixserverlib.PublicKeyLookupRequest]gomatrixserverlib.Timestamp,
40) (map[gomatrixserverlib.PublicKeyLookupRequest]gomatrixserverlib.PublicKeyLookupResult, error) {
41 results := make(map[gomatrixserverlib.PublicKeyLookupRequest]gomatrixserverlib.PublicKeyLookupResult)
42 for req, ts := range requests {
43 if res, cached := d.cache.GetServerKey(req, ts); cached {
44 results[req] = res
45 delete(requests, req)
46 }
47 }
48 fromDB, err := d.inner.FetchKeys(ctx, requests)
49 if err != nil {
50 return results, err
51 }
52 for req, res := range fromDB {
53 results[req] = res
54 d.cache.StoreServerKey(req, res)
55 }
56 return results, nil
57}
58
59// StoreKeys implements gomatrixserverlib.KeyDatabase
60func (d *KeyDatabase) StoreKeys(

Callers 2

TestRenewalBehaviourFunction · 0.45

Calls 2

GetServerKeyMethod · 0.65
StoreServerKeyMethod · 0.65

Tested by 2

TestRenewalBehaviourFunction · 0.36