Skip to content

refactor: add CValidationInterface/CMainSignals validation-signal layer#3078

Open
PrestackI wants to merge 1 commit into
gridcoin-community:developmentfrom
PrestackI:validationinterface/signal-layer
Open

refactor: add CValidationInterface/CMainSignals validation-signal layer#3078
PrestackI wants to merge 1 commit into
gridcoin-community:developmentfrom
PrestackI:validationinterface/signal-layer

Conversation

@PrestackI

Copy link
Copy Markdown
Contributor

What

Adds a Bitcoin-Core-style validation-signal layer in new src/validationinterface.{h,cpp}:

  • CValidationInterface — abstract subscriber with the trimmed callback set
    UpdatedBlockTip, TransactionAddedToMempool, TransactionRemovedFromMempool,
    BlockConnected, BlockDisconnected (UpperCamelCase per doc/developer-notes.md).
  • CMainSignals + GetMainSignals(), with RegisterValidationInterface /
    UnregisterValidationInterface, register/unregister of a background CScheduler,
    and FlushBackgroundCallbacks. Subscribers tracked via boost::signals2 scoped
    connections (mirroring the existing ui_interface).

Signals are emitted synchronously for now (on the thread that triggered the event,
under cs_main), preserving the canonical cs_main → signals → cs_wallet order. 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.

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.cpp in gridcoin_util.

Testing

Full CI matrix green on the source branch (Quality Gate incl. Clang thread-safety,
Functional Tests, Compatibility, Production, Distribution Native).

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.
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.

1 participant