Skip to content

Add to_json() and serialize_json() to block_sideband - #5089

Open
gabparrot wants to merge 2 commits into
nanocurrency:developfrom
gabparrot:fix/4390-block-sideband-to-json
Open

Add to_json() and serialize_json() to block_sideband#5089
gabparrot wants to merge 2 commits into
nanocurrency:developfrom
gabparrot:fix/4390-block-sideband-to-json

Conversation

@gabparrot

Copy link
Copy Markdown

Summary

Implements the to_json() inspection method requested in #4390 for nano::block_sideband. Useful for debugging and consistent with the existing nano::vote::to_json() pattern.

Changes

  • nano/lib/block_sideband.hpp — declare to_json() and serialize_json() alongside the existing logging operator().
  • nano/lib/block_sideband.cpp — implement both, writing all 7 sideband fields: account, balance, height, timestamp, topo_height, source_epoch, details (via state_subtype).
  • nano/core_test/block.cpp — add TEST (block_sideband, to_json) covering all fields, mirroring the existing block_store, sideband_serialization test style.

Notes

  • Pattern mirrors nano::vote::to_json() (vote.cpp:164) and nano::vote::serialize_json() (vote.cpp:147).
  • source_epoch is serialized as the underlying integer value (matching how it's persisted) rather than the enum name; a future change to enum names would be a no-op for persisted data.
  • Local build not verified due to slow submodule fetch in the dev environment; relying on CI for core_test verification.

Fixes #4390

Implements the JSON inspection method requested in nanocurrency#4390, mirroring
the existing nano::vote::to_json() pattern. Also adds a unit test
covering all 7 sideband fields.

Refs nanocurrency#4390
@gabparrot
gabparrot marked this pull request as draft June 27, 2026 19:54
Replace tautological assertions (expected values derived from the same
conversions the SUT calls) with literal expected JSON values so the test
independently verifies serialize_json output. Add a second test
covering the send/epoch/change branches of state_subtype that were
previously unexercised.

Refs nanocurrency#4390
@gabparrot
gabparrot marked this pull request as ready for review June 27, 2026 20:07
@gr0vity-dev-bot

gr0vity-dev-bot commented Jun 27, 2026

Copy link
Copy Markdown

Test Results for Commit 5acf321

Pull Request 5089: Results
Overall Status:

Test Case Results

  • 5n4pr_conf_10k_bintree: PASS (Duration: 110s)
  • 5n4pr_conf_10k_change: PASS (Duration: 159s)
  • 5n4pr_conf_change_dependant: PASS (Duration: 113s)
  • 5n4pr_conf_change_independant: PASS (Duration: 109s)
  • 5n4pr_conf_send_dependant: PASS (Duration: 109s)
  • 5n4pr_conf_send_independant: PASS (Duration: 112s)
  • 5n4pr_rocks_10k_bintree: PASS (Duration: 113s)
  • 5n4pr_rocks_10k_change: PASS (Duration: 224s)

Last updated: 2026-06-27 22:40:56 UTC

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.

Wanted: to_json() function for nano::block_sideband

2 participants