MCPcopy Create free account
hub / github.com/Drakkar-Software/OctoBot / get_data

Function get_data

packages/sync/octobot_sync/server.py:203–292  ·  view source on GitHub ↗
(key: str, context: StoreContext | None = None)

Source from the content-addressed store, hash-verified

201
202
203async def get_data(key: str, context: StoreContext | None = None) -> str | None:
204 # called when client pulls
205 with journal_recording_context.sync_read_operation(
206 resolve_collection=lambda: _sync_read_failure_collection(context),
207 resolve_failure_reason=_sync_read_failure_reason,
208 ):
209 collection = _get_collection(context)
210 plaintext = None
211 already_encrypted_payload = None
212 match collection:
213 case enums.Collections.USER_DATA.value:
214 user_data_state = await user_data_protocol.get_user_data_state(
215 _get_identity(context)
216 )
217 plaintext = user_data_state.to_json()
218 case enums.Collections.USER_ACCOUNTS.value:
219 encrypted_blob = accounts_protocol.get_accounts_state_encrypted(
220 _get_identity(context)
221 )
222 already_encrypted_payload = json.dumps(encrypted_blob)
223 case enums.Collections.USER_ACCOUNTS_AUTH.value:
224 encrypted_blob = accounts_auth_protocol.get_accounts_authentication_state_encrypted(
225 _get_identity(context)
226 )
227 already_encrypted_payload = json.dumps(encrypted_blob)
228 case enums.Collections.USER_ACCOUNTS_TRADING.value:
229 encrypted_blob = accounts_trading_protocol.get_account_trading_state_encrypted(
230 _get_identity(context),
231 _get_account_id(context),
232 )
233 already_encrypted_payload = json.dumps(encrypted_blob)
234 case enums.Collections.USER_ACCOUNTS_HISTORY.value:
235 history_state = await accounts_history_protocol.compute_portfolio_historical_values_from_latest_portfolio_trades_and_transactions(
236 _get_identity(context),
237 _get_account_id(context),
238 )
239 plaintext = history_state.to_json()
240 case enums.Collections.USER_ACCOUNTS_HISTORY_AGGREGATED_REAL.value:
241 history_state = await accounts_history_protocol.compute_aggregated_portfolio_historical_values_from_latest_portfolio_trades_and_transactions(
242 _get_identity(context),
243 is_simulated=False,
244 )
245 plaintext = history_state.to_json()
246 case enums.Collections.USER_ACCOUNTS_HISTORY_AGGREGATED_SIMULATED.value:
247 history_state = await accounts_history_protocol.compute_aggregated_portfolio_historical_values_from_latest_portfolio_trades_and_transactions(
248 _get_identity(context),
249 is_simulated=True,
250 )
251 plaintext = history_state.to_json()
252 case enums.TemporaryCollections.TEMP_USER_STRATEGIES.value:
253 encrypted_blob = strategies_protocol.get_strategies_state_encrypted(
254 _get_identity(context)
255 )
256 already_encrypted_payload = json.dumps(encrypted_blob)
257 case enums.Collections.USER_ACTIONS.value:
258 # reading user actions should always return an empty list
259 actions_state = protocol_models.UserActionsState(
260 version=sync_constants.USER_ACTIONS_STATE_VERSION,

Callers

nothing calls this directly

Calls 11

to_jsonMethod · 0.95
_get_collectionFunction · 0.85
_get_identityFunction · 0.85
_get_account_idFunction · 0.85
_get_opaque_storeFunction · 0.85
_wrap_as_stored_documentFunction · 0.85
_encryptFunction · 0.85
dumpsMethod · 0.80
to_jsonMethod · 0.45
get_stringMethod · 0.45

Tested by

no test coverage detected