refactor: add CValidationInterface/CMainSignals validation-signal layer#3078
Open
PrestackI wants to merge 1 commit into
Open
refactor: add CValidationInterface/CMainSignals validation-signal layer#3078PrestackI wants to merge 1 commit into
PrestackI wants to merge 1 commit into
Conversation
First step of issue gridcoin-community#3030 workstream B. Introduces a Bitcoin-Core-style validation-signal layer so that subscribers (the wallet in B2, the GUI and a future PeerManager later) can decouple from core block/tx processing. New src/validationinterface.{h,cpp}: - CValidationInterface, an abstract subscriber with the trimmed callback set UpdatedBlockTip / TransactionAddedToMempool / TransactionRemovedFromMempool / BlockConnected / BlockDisconnected. Method names follow the repo's modern convention (UpperCamelCase per doc/developer-notes.md); the parameter types match the wallet's existing callbacks so B2 can subscribe with minimal churn. - CMainSignals + GetMainSignals(), with RegisterValidationInterface / UnregisterValidationInterface, register/unregister of a background CScheduler, and FlushBackgroundCallbacks. Subscribers are tracked with boost::signals2 scoped connections (mirroring the existing ui_interface). Emission is SYNCHRONOUS for now: signals fire on the thread that triggered the event, preserving the canonical cs_main -> signals -> cs_wallet lock order and the EXCLUSIVE_LOCKS_REQUIRED(cs_main) contract of the wallet callbacks. The g_scheduler-backed SingleThreadedSchedulerClient is wired for CallFunctionInValidationInterfaceQueue and a future async migration. init.cpp: resolves the long-standing TODO by calling GetMainSignals().RegisterBackgroundSignalScheduler(*g_scheduler) once the scheduler thread is up, and flushes + unregisters it at shutdown after the scheduler thread is joined. Registered validationinterface.cpp in src/CMakeLists.txt (gridcoin_util). Pure additive scaffolding -- nothing emits or subscribes yet (that is B2), so there is no behavior change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a Bitcoin-Core-style validation-signal layer in new
src/validationinterface.{h,cpp}:CValidationInterface— abstract subscriber with the trimmed callback setUpdatedBlockTip,TransactionAddedToMempool,TransactionRemovedFromMempool,BlockConnected,BlockDisconnected(UpperCamelCase perdoc/developer-notes.md).CMainSignals+GetMainSignals(), withRegisterValidationInterface/UnregisterValidationInterface, register/unregister of a backgroundCScheduler,and
FlushBackgroundCallbacks. Subscribers tracked viaboost::signals2scopedconnections (mirroring the existing
ui_interface).Signals are emitted synchronously for now (on the thread that triggered the event,
under
cs_main), preserving the canonicalcs_main → signals → cs_walletorder. Theg_scheduler-backedSingleThreadedSchedulerClientis wired forCallFunctionInValidationInterfaceQueueand a future async migration.init.cppresolves the long-standing TODO by callingGetMainSignals().RegisterBackgroundSignalScheduler(*g_scheduler)once the schedulerthread is up, and flushes + unregisters it at shutdown.
Why
First step of issue #3030 workstream B — a signal layer so subscribers (the wallet in the
follow-up, the GUI, and a future
PeerManager) decouple from core block/tx processing.Depends on
g_scheduler(#3025, merged). Independent of the A1–A3 stack.Notes
Pure additive scaffolding — nothing emits or subscribes yet (that is the next PR), so
there is no behavior change. Registered
validationinterface.cppingridcoin_util.Testing
Full CI matrix green on the source branch (Quality Gate incl. Clang thread-safety,
Functional Tests, Compatibility, Production, Distribution Native).