-
Notifications
You must be signed in to change notification settings - Fork 59
Second phase of network refactoring #1853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
# Conflicts: # app/src/main/java/org/session/libsession/network/SnodeClientErrorManager.kt # app/src/main/java/org/session/libsession/network/onion/PathManager.kt # app/src/test/java/org/thoughtcrime/securesms/network/PathManagerTest.kt # app/src/test/java/org/thoughtcrime/securesms/network/SnodeClientErrorManagerTest.kt
# Conflicts: # app/src/main/java/org/session/libsession/network/snode/SnodeDirectory.kt # app/src/main/java/org/session/libsignal/utilities/Snode.kt
| @@ -0,0 +1,3 @@ | |||
| package org.thoughtcrime.securesms.api.error | |||
|
|
|||
| class ClockOutOfSyncException : RuntimeException("Clock is out of sync is reported by a server") No newline at end of file | |||
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.
I don't think we need this level of abstraction for the COS
| * | ||
| * Normally this is up to the caller to handle. | ||
| */ | ||
| class UnknownStatusCodeException( |
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.
Unhandled instead of unknown?
| ) | ||
| return parseSnodePoolFromJsonBytes(responseBytes) | ||
| private suspend fun fetchSnodePoolFromSnode(snode: Snode): List<Snode> { | ||
| //TODO: Onion should request over onion |
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 remove this todo now
| val parsed = parseSnodePoolFromJsonBytes(localBytes) | ||
| @Suppress("OPT_IN_USAGE") | ||
| val parsed: ListSnodeApi.Response = appContext.assets.open(LOCAL_SNODE_POOL_ASSET) | ||
| .use(json::decodeFromStream) |
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.
deserialise will fail - missing result
| @@ -20,13 +19,4 @@ data class BatchResponse(val results: List<Item>, ) { | |||
| val isSnodeNoLongerPartOfSwarm: Boolean | |||
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 not be needed anymore now
| .execute( | ||
| req = SnodeApiRequest( | ||
| snode = snodePoolStorage.getSnodePool().first { it !in pathCandidate }, | ||
| api = getNetworkTimeApi.get() |
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.
should getNetworkTime be renamed to info?
| item to result.map { response -> | ||
| when { | ||
| response.isSuccess() -> Unit | ||
| response.error == 403 -> throw NonRetryableException("Request failed: code = ${response.error}, message = ${response.message}") |
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.
Are we missing some of these error handling cases?
This PR reorganises code around and makes use of the concept of
ApiExecutor: different executors operate on different levels, and they normally just pass data down to another level for handling.