Skip to content

Commit

Permalink
Fix nanocurrency#4390: Wanted: to_json() function for nano::block_sid…
Browse files Browse the repository at this point in the history
…eband
  • Loading branch information
Napetrou committed Jan 26, 2024
1 parent 7e58c50 commit 3e8c5ad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions nano/lib/blocks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1864,3 +1864,8 @@ bool nano::block_sideband::deserialize (nano::stream & stream_a, nano::block_typ

return result;
}

std::string nano::block_sideband::to_json () const
{
return ("{\"successor\":\"" + successor.to_string () + "\", \"account\":" + account.to_account () + ", \"balance\":" + balance.to_string () + ", \"height\":" + nano::to_string_hex (height) + ", \"timestamp\": " + nano::to_string_hex (timestamp) + ", \"details\":" + std::to_string (static_cast<int> (details.epoch)) + ", \"" + (details.is_send) ? "true" : "false" + "\", \"" + (details.is_receive) ? "true" : "false" + "\", \"" + (details.is_epoch) ? "true" : "false" + "\", \"source_epoch\":" + std::to_string (static_cast<int> (source_epoch)) + "}");
}
1 change: 1 addition & 0 deletions nano/lib/blocks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class block_sideband final
uint64_t timestamp{ 0 };
nano::block_details details;
nano::epoch source_epoch{ nano::epoch::epoch_0 };
string to_json () const;
};
class block
{
Expand Down

0 comments on commit 3e8c5ad

Please sign in to comment.