Skip to content
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

Fix Trustchain failing from command line #57

Closed
wants to merge 6 commits into from
Closed

Fix Trustchain failing from command line #57

wants to merge 6 commits into from

Conversation

KoningR
Copy link

@KoningR KoningR commented Nov 22, 2021

A (quite naive) solution to fix #56 . At the moment, I am unsure if this is the best way of fixing this, but I am hoping the project maintainer can comment.

…so that we need not have a UI dispatcher when running on command line.
@KoningR
Copy link
Author

KoningR commented Jan 18, 2022

Would anyone please be so kind as to consider reviewing and merging this PR or stating what should be changed about it? The functionality in this PR is critical for my project (at least, to me it currently appears that way) and I would like to work from the master branch if that is possible.

@InvictusRMC
Copy link
Member

@KoningR I will merge this today, can you fix the conflicts first?

Copy link
Member

@InvictusRMC InvictusRMC left a comment

Choose a reason for hiding this comment

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

We're changing the used Dispatcher for the demo application now. Probably not something we want to be doing. Please look into it.

@@ -64,7 +61,7 @@ abstract class Community : Overlay {
network.blacklist.addAll(DEFAULT_ADDRESSES)

job = SupervisorJob()
scope = CoroutineScope(Dispatchers.Main + job)
scope = CoroutineScope(dispatcher + job)
Copy link
Member

Choose a reason for hiding this comment

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

(4/4) This will now be Dispatchers.Default as opposed to being Dispatchers.Main in the demo application.

Copy link
Author

Choose a reason for hiding this comment

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

This is precisely what we want to be doing. The reason this issue exists is because a command line application does not (necessarily) have a Main dispatcher. The Main dispatcher is "confined to the Main thread operating with UI objects.". Please refer to issue #57, where I've described the issue more explicitly. By making the dispatcher an optional argument, existing applications should not break. But future console applications should refrain from using a Main dispatcher.

@@ -78,7 +79,7 @@ class Application {
), walkerInterval = 1.0)

val ipv8 = IPv8(endpoint, config, myPeer)
ipv8.start()
ipv8.start(dispatcher)
Copy link
Member

Choose a reason for hiding this comment

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

(1/4) Now we're passing Dispatchers.Default.

@@ -31,7 +31,7 @@ class IPv8(
return overlays[T::class.java] as? T
}

fun start() {
fun start(dispatcher: CoroutineDispatcher = Dispatchers.Main) {
Copy link
Member

Choose a reason for hiding this comment

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

(2/4) Resulting in this not being Dispatchers.Main

@@ -51,7 +51,7 @@ class IPv8(
overlay.endpoint = endpoint
overlay.network = network
overlay.maxPeers = overlayConfiguration.maxPeers
overlay.load()
overlay.load(dispatcher)
Copy link
Member

Choose a reason for hiding this comment

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

(3/4) We're now passing Dispatchers.Default.

…fix-trustchain-coroutines-jvm

� Conflicts:
�	ipv8/src/main/java/nl/tudelft/ipv8/Community.kt
@InvictusRMC
Copy link
Member

InvictusRMC commented Jan 18, 2022

The rewrite of the load function clash with overrides performed in the superapp project. So I cannot merge this yet. Either rewrite those
overrides or allow for a second definition of the load function if that is possible in Kotlin.

@InvictusRMC
Copy link
Member

InvictusRMC commented Jan 18, 2022

@KoningR your changes appear to break all EVA tests.

Master:
image

This branch:
image

@KoningR
Copy link
Author

KoningR commented Mar 29, 2022

I am now using ipv8 directly instead of trustchain (for unrelated reasons). Thus, this problem is not relevant to my project anymore, nor am I involved with the super app for the time being. Time constraints disallow me to spend further time on this. I am leaving the issue and branch open but am closing this PR.

@KoningR KoningR closed this Mar 29, 2022
@KoningR KoningR deleted the fix-trustchain-coroutines-jvm branch April 20, 2022 14:54
@KoningR KoningR restored the fix-trustchain-coroutines-jvm branch April 20, 2022 14:58
@KoningR KoningR deleted the fix-trustchain-coroutines-jvm branch June 16, 2022 12:45
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.

Trustchain fails when executed from CLI.
2 participants