Skip to content

Add the streamrNode* full-node API (phase D3b) on shared library 3.0.0#1

Open
ptesavol wants to merge 1 commit into
mainfrom
streamr-node-api
Open

Add the streamrNode* full-node API (phase D3b) on shared library 3.0.0#1
ptesavol wants to merge 1 commit into
mainfrom
streamr-node-api

Conversation

@ptesavol

Copy link
Copy Markdown
Collaborator

Extends the Go wrapper with the full-node API, completing its part of native-sdk phase D3b (see streamr-dev/native-sdk#95, which renames the shared C API infrastructure and bundles the C++/Python wrapper extensions).

  • StreamrNode Go API: NewStreamrNode/Close, Start/Stop, JoinStreamPart/LeaveStreamPart, Publish, Subscribe (Go closure callback) / Unsubscribe, NeighborCount, SetProxies — following the existing wrapper conventions.
  • Shim: dlsym-resolved streamrNode* functions; C trampoline → cgo-exported callback with a registry key; accessor for the StreamrError peer/proxy anonymous-union member (cgo can't address those).
  • cgo correctness: peer arrays embedded in C structs are C-allocated; callback registrations live until Close (the C API may still dispatch a message whose delivery already started at Unsubscribe).
  • Library loading is now once-per-process, never dlclosed: a node that has run leaves service threads pinning the library, so dlclose + fresh dlopen loaded a second copy and aborted on duplicate gflags registration. Cleanup/re-init now uses the C API's in-process lifecycle (supported since 3.0.0).
  • Vendored 3.0.0 headers; the proxy shim keeps binding the old symbol names, which 3.0.0 exports as deprecated aliases — existing proxy consumers are unaffected.
  • Embedded arm64-osx dylib refreshed to 3.0.0. The linux-amd64/linux-arm64/darwin-amd64 embedded libraries still need their 3.0.0 builds from the native-sdk release pipeline before release.

Tests: new two-node round-trip (topology forms, signed + unsigned message exchange, error mapping) plus the existing proxy suite — all green in one process (go test -skip=TestPublishToServer, 3.1 s on arm64-osx).

🤖 Generated with Claude Code

- Vendor the 3.0.0 headers: streamrcommon.h (the renamed shared
  infrastructure), streamrproxyclient.h (proxy API + deprecated pre-3.0
  aliases) and streamrnode.h. The proxy shim keeps resolving the old C
  symbol names, which 3.0.0 still exports as deprecated aliases.
- shim: dlsym the streamrNode* functions; a C trampoline bridges the
  message callback to the cgo-exported goStreamrNodeMessage with a
  Go-side registry key in userData; a small accessor reads the
  StreamrError peer/proxy union member (cgo cannot address anonymous
  union members).
- streamrnode.go: StreamrNode API (New/Close, Start/Stop,
  Join/LeaveStreamPart, Publish, Subscribe/Unsubscribe, NeighborCount,
  SetProxies) following the existing wrapper conventions. Peer arrays
  passed inside C structs are C-allocated (cgo forbids Go pointers in
  structs passed to C). Callback registrations live until Close: the C
  API may still dispatch a message whose delivery already started when
  Unsubscribe returns.
- Library loading is now once-per-process and never dlclosed: a node
  that has run leaves service threads pinning the library, so a fresh
  dlopen after dlclose loaded a SECOND copy and aborted on duplicate
  gflags registration. In-process cleanup/re-init uses the C API's own
  lifecycle on the single loaded copy (supported since 3.0.0).
- dist: refresh the embedded arm64-osx dylib to 3.0.0. The other
  platforms' embedded libraries still need their 3.0.0 builds from the
  native-sdk release pipeline before this branch is released.
- streamrnode_test.go: two wrapper-created nodes form a stream-part
  topology and exchange a signed and an unsigned message, plus error
  mapping; full suite (proxy + node) passes in one process.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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