
from synapse.storage import DataStore
from synapse.storage.keys import KeyStore

from ._base import BaseSlavedStore, __func__


class SlavedKeyStore(BaseSlavedStore):
    _get_server_verify_key = KeyStore.__dict__[
        "_get_server_verify_key"
    ]

    get_server_verify_keys = __func__(DataStore.get_server_verify_keys)
    store_server_verify_key = __func__(DataStore.store_server_verify_key)

    get_server_keys_json = __func__(DataStore.get_server_keys_json)
    store_server_keys_json = __func__(DataStore.store_server_keys_json)


from synapse.storage import KeyStore

# KeyStore isn't really safe to use from a worker, but for now we do so and hope that
# the races it creates aren't too bad.

SlavedKeyStore = KeyStore

Replace SlavedKeyStore with a shim
Replace SlavedKeyStore with a shim

since we're pulling everything out of KeyStore anyway, we may as well simplify
it.

  
- from synapse.storage import DataStore
- from synapse.storage.keys import KeyStore
+ from synapse.storage import KeyStore
  
- from ._base import BaseSlavedStore, __func__
+ # KeyStore isn't really safe to use from a worker, but for now we do so and hope that
+ # the races it creates aren't too bad.
  
+ SlavedKeyStore = KeyStore
  
- class SlavedKeyStore(BaseSlavedStore):
-     _get_server_verify_key = KeyStore.__dict__[
-         "_get_server_verify_key"
-     ]
- 
-     get_server_verify_keys = __func__(DataStore.get_server_verify_keys)
-     store_server_verify_key = __func__(DataStore.store_server_verify_key)
- 
-     get_server_keys_json = __func__(DataStore.get_server_keys_json)
-     store_server_keys_json = __func__(DataStore.store_server_keys_json)
- 
Replace SlavedKeyStore with a shim
## Code Before:

from synapse.storage import DataStore
from synapse.storage.keys import KeyStore

from ._base import BaseSlavedStore, __func__


class SlavedKeyStore(BaseSlavedStore):
    _get_server_verify_key = KeyStore.__dict__[
        "_get_server_verify_key"
    ]

    get_server_verify_keys = __func__(DataStore.get_server_verify_keys)
    store_server_verify_key = __func__(DataStore.store_server_verify_key)

    get_server_keys_json = __func__(DataStore.get_server_keys_json)
    store_server_keys_json = __func__(DataStore.store_server_keys_json)

## Instruction:
Replace SlavedKeyStore with a shim
## Code After:

from synapse.storage import KeyStore

# KeyStore isn't really safe to use from a worker, but for now we do so and hope that
# the races it creates aren't too bad.

SlavedKeyStore = KeyStore
