Skip to content

Conversation

@ThomasSession
Copy link
Collaborator

WIP
Early stages of the first networking refactor

)

val json = runCatching {
JsonUtil.fromJson(responseBytes, Map::class.java)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it makes sense to migrate to use kotlinx serialization here, since we are rebuilding this now

Comment on lines +26 to +27
fun getForkInfo(): ForkInfo
fun setForkInfo(forkInfo: ForkInfo)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are these used for?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for some work that was performed in the OnionRequest handleResponse before:

                            if (body.containsKey("hf")) {
                                @Suppress("UNCHECKED_CAST")
                                val currentHf = body["hf"] as List<Int>
                                if (currentHf.size < 2) {
                                    Log.e("Loki", "Response contains fork information but doesn't have a hard and soft number")
                                } else {
                                    val hf = currentHf[0]
                                    val sf = currentHf[1]
                                    val newForkInfo = ForkInfo(hf, sf)
                                    if (newForkInfo > SnodeAPI.forkInfo) {
                                        SnodeAPI.forkInfo = ForkInfo(hf,sf)
                                    } else if (newForkInfo < SnodeAPI.forkInfo) {
                                        Log.w("Loki", "Got a new snode info fork version that was $newForkInfo, less than current known ${SnodeAPI.forkInfo}")
                                    }
                                }
                            }
                            ```
                            
                            Moved it to a different place for separation of concerns

if (body == null || body.isEmpty()) return false

val json: Map<*, *> = try {
JsonUtil.fromJson(body, Map::class.java) as Map<*, *>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same re: json serialization

*
*/
suspend fun send(
path: List<Snode>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since there's a Path type defined, should we use it here too?

@ThomasSession ThomasSession marked this pull request as ready for review January 6, 2026 04:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants