re: #28048 (review)
I’m not too concerned about blockTip
notification shutting down during an invalidateblock
call, because it seems like a corner case to worry about someone using -stopafterheight
and invalidblock
at the same time. If someone is doing this, I think there is only a small change of behavior not worth documenting where the -stopatheight
option might take effect a little earlier and the node would shut down a little sooner.
If distinguishing invalidateblock
tip changes from other tip changes is a concern for other reaons in the future, it could be addressed by adding an enum parameter to the blockTip
function that indicates the source or the tip change.
The point of the “this could be changed to bubble up kernel::Interrupted” comment is not to worry about the stopatheight+invalidateblock corner case, but just suggest in general it should probably become a pattern to do something like if (IsInterrupted(result)) return std::get<Interrrupted>(result)
and bubble up interrupted values to callers.
On logging, I think it is usually better to log from kernel code rather than from node hooks, because if the log statements are actually useful for our code there is a good chance they will be useful for other code as well.
On InvalidateBlock staying in the kernel, declaring blocks invalid seems like a useful feature to offer to kernel applications, so I don’t think there would be much benefit to removing it.