fix(bootstrap): restore Bootstrap:: linkage for trusted-publisher API

PR #26 introduced an anonymous namespace at src/bootstrap.cpp:763 to hold
file-private helpers, but it never closed before the four public functions
declared in bootstrap.h:

  - GetActiveTrustedSnapshotPublisher
  - LoadTrustedSnapshotPublisher
  - SetTrustedSnapshotPublisher
  - UnsetTrustedSnapshotPublisher

With these inside the anonymous namespace, the compiler mangles them as
Bootstrap::(anonymous_namespace)::*, while the header declares them as
plain Bootstrap::*. Result: any caller (rpcblockchain.cpp, init.cpp)
fails to link with 'undefined reference to
Bootstrap::GetActiveTrustedSnapshotPublisher'. PR #27 inherited a
master that didn't build and CI was red across all jobs.

Fix: close the anonymous namespace immediately before the public
functions, then re-open it afterwards for the remaining file-private
helpers (IsTrustedSnapshotSigner / VerifySignedMessage /
ExtractJsonString).

Verified:
  - nm confirms Bootstrap::GetActiveTrustedSnapshotPublisher is now T
    (external linkage) on bootstrap.cpp.o
  - ninja builds trianglesd and test_snapshotnet cleanly
  - rpcblockchain.cpp.o compiles (the consumer that was failing)
  - ctest: 4/4 suites pass (triangles_unit_tests,
    chaindb_equivalence_tests, snapshotnet_tests, chaindb_runtime_tests)
  - existing anonymous namespace at lines 455-470 unchanged

This should unblock PR #27 (feat/script-fuzz-and-stress-tests) CI.
This commit is contained in:
Sami Ahmed
2026-07-11 01:06:26 -07:00
parent 8598cfa781
commit 898292ff2b
+14
View File
@@ -793,6 +793,14 @@ static std::string g_activeTrustedSnapshotPublisher;
static std::mutex g_trustedPublisherMutex;
static const char* SNAPSHOT_PUBLISHER_FILE = "snapshot-publisher.json";
} // anonymous namespace (helpers above are file-private)
// PUBLIC API — declared in bootstrap.h inside namespace Bootstrap.
// These MUST NOT be inside an anonymous namespace or the linker can't
// resolve Bootstrap::GetActiveTrustedSnapshotPublisher calls from
// rpcblockchain.cpp / init.cpp. (PR #26 bug: left the anon-namespace
// open across these definitions.)
std::string GetActiveTrustedSnapshotPublisher()
{
std::lock_guard<std::mutex> lock(g_trustedPublisherMutex);
@@ -885,6 +893,12 @@ bool UnsetTrustedSnapshotPublisher(std::string& strError)
return true;
}
// Re-enter anonymous namespace for the remaining file-private helpers.
// (IsTrustedSnapshotSigner / VerifySignedMessage / ExtractJsonString are
// not declared in bootstrap.h, so they don't need Bootstrap:: linkage.)
namespace {
bool IsTrustedSnapshotSigner(const std::string& addr)
{
// 1. Runtime override (set via RPC).