Introduce Info and separate info/debug strings#328
Conversation
59317e1 to
f013f7d
Compare
f013f7d to
a0c3f0c
Compare
a0c3f0c to
31b35dd
Compare
| }; | ||
| } | ||
|
|
||
| macro_rules! info { |
There was a problem hiding this comment.
Given the structure and relatively exhaustive things sent over the info channel, should it just be detached from the LogLevel setting entirely? I might be missing a benefit, but decoupling it would simplify this code (could drop this macro?) and some conditionals.
There was a problem hiding this comment.
Reviewing the 4 channels for the user interface at this point, I get where this change is coming from, but does feel a little pre-optimized. Does it make sense to combine the Info and Event channels to try and keep things simple?
There was a problem hiding this comment.
There's an argument to be made for that, although I kind of envision the applications in 3 tiers:
- desktop or terminal app that writes to a debug log
- mobile or desktop application that adjusts UI components based on info/warnings
- a sort of "headless" node that just runs in the background unless it dies, like in
ldk-nodethere's really not much of a use in having info messages because it would be so deeply nested in the syncing process
Maybe it's over kill, but the Progress variant of Info in particular might be a little wasted if emitted for all types of apps. The nice thing about the LogLevel construct is you get exactly the memory/CPU cycles you sign up for, so I'd like to leave these coupled for now
There was a problem hiding this comment.
Does it make sense to combine the Info and Event channels to try and keep things simple?
The original type of message was simply NodeMessage, and this caused havoc trying to match between things that were mostly unimportant and events like blocks. Doesn't feel so great to look at all these channels but the alternative is the inability to separate your program into "this part handles blocks" and "this part handles logs" type of thing
There was a problem hiding this comment.
Hm ok, I guess the "single receiver" constraint of channels kind of forces this opinionated separation of events.
There was a problem hiding this comment.
For a real-world use of constraining channels to specific messages, check out what we do it bdk_kyoto to build updates for the wallet. If the Event included other things, it might be difficult to pass those on to the user. In that struct we really only care about blocks and reorgs anyway
There was a problem hiding this comment.
Yea, if you stick to one channel you force the caller to make there own little downstream channels on their side. If the split is obvious enough that each caller would create the same 3 internal channels, probably makes sense to define them on the Kyoto side
Description
While it might be painful to have 4 different ways to handle messages, I think this design is worth the performance improvements if one would like to completely remove string allocations by omitting the debug messages. Informational messages can be useful but are far less chatty, and may potentially be expanded into the future (like positive matches for filters).
For a desktop application I don't see much harm in using the debug strings and writing to a log, but mobile users can't use the strings for much at all so they should have a way to omit them, but still get updates on the changes in state and such.
Implementation
info!macro similar tolog!, so informational messages aren't allocated withLogLevel::Warningset.Logenum toInfo. The debug messages are emitted as strings andInfois an enum with the rest of the events