-
Notifications
You must be signed in to change notification settings - Fork 28
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
Changes from all commits
752d8a2
c382a35
3c0ebd5
d9e7d63
fa7de7e
4f564d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,8 +55,8 @@ abstract class Community : Overlay { | |
messageHandlers[MessageId.EVA_ERROR] = ::onEVAErrorPacket | ||
} | ||
|
||
override fun load() { | ||
super.load() | ||
override fun load(dispatcher: CoroutineDispatcher) { | ||
super.load(dispatcher) | ||
|
||
logger.info { "Loading " + javaClass.simpleName + " for peer " + myPeer.mid } | ||
|
||
|
@@ -69,7 +69,7 @@ abstract class Community : Overlay { | |
network.blacklist.addAll(DEFAULT_ADDRESSES) | ||
|
||
job = SupervisorJob() | ||
scope = CoroutineScope(Dispatchers.Main + job) | ||
scope = CoroutineScope(dispatcher + job) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (4/4) This will now be There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
||
if (evaProtocolEnabled) | ||
evaProtocol = EVAProtocol(this, scope) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ class IPv8( | |
return overlays[T::class.java] as? T | ||
} | ||
|
||
fun start() { | ||
fun start(dispatcher: CoroutineDispatcher = Dispatchers.Main) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (2/4) Resulting in this not being |
||
if (isStarted()) throw IllegalStateException("IPv8 has already started") | ||
|
||
isStarted = true | ||
|
@@ -51,7 +51,7 @@ class IPv8( | |
overlay.endpoint = endpoint | ||
overlay.network = network | ||
overlay.maxPeers = overlayConfiguration.maxPeers | ||
overlay.load() | ||
overlay.load(dispatcher) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (3/4) We're now passing |
||
|
||
overlays[overlayClass] = overlay | ||
|
||
|
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.
(1/4) Now we're passing
Dispatchers.Default
.