Open shryder opened 3 years ago
I think this is a really breaking change and unneeded right now but just wondering what you guys think about RPCs returning an empty string instead of an empty array/object.
Example RPC request: If the account was opened, the history field will be a populated array: https://node.shrynode.me/api?action=account_history&account=nano_1nk9zdf1otddxhxfqimjdkmbtq17yzf3z6giz1as7x1huyug8er1ukeqpqpe&count=20
history
If the account was not opened, the history field will be an empty string: https://node.shrynode.me/api?action=account_history&account=nano_3ikcyn5rn5erjyx53wa9ejmu3o7853rwbhbucrkp57xuzxurqj486aascn4x&count=20
Clients having to do weird checks & just better imo
I don't think so
My suggested solution would be to not use Boost's Property Tree entirely and instead move to something like nlohmann or Boost.JSON
With nlohmann, we can specify the type by simply using one of the standard types (int, bool, std::vector, std::map, std::string).
For example: This is how it roughly works currently:
boost::property_tree::ptree accounts; // Add item to array boost::property_tree::ptree entry; entry.put ("", nano::account (0).to_account ()); accounts.push_back (std::make_pair ("", entry));
With a special JSON library it would look like this:
std::vector<std::string> accounts; accounts.push_back (nano::account (0).to_account ());
Serializing with nlohmann will always return an array even when empty, unlike boost::property_tree::write_json.
boost::property_tree::write_json
I am willing to collaborate
No response
Just found an old issue, this is apparently planned as part of RPC 2.0: https://github.com/nanocurrency/nano-node/issues/1871
Summary
I think this is a really breaking change and unneeded right now but just wondering what you guys think about RPCs returning an empty string instead of an empty array/object.
Example RPC request: If the account was opened, the
history
field will be a populated array: https://node.shrynode.me/api?action=account_history&account=nano_1nk9zdf1otddxhxfqimjdkmbtq17yzf3z6giz1as7x1huyug8er1ukeqpqpe&count=20If the account was not opened, the
history
field will be an empty string: https://node.shrynode.me/api?action=account_history&account=nano_3ikcyn5rn5erjyx53wa9ejmu3o7853rwbhbucrkp57xuzxurqj486aascn4x&count=20What problem would be solved by this feature?
Clients having to do weird checks & just better imo
Are there any previous requests for this feature?
I don't think so
Do you have a suggested solution?
My suggested solution would be to not use Boost's Property Tree entirely and instead move to something like nlohmann or Boost.JSON
With nlohmann, we can specify the type by simply using one of the standard types (int, bool, std::vector, std::map, std::string).
For example: This is how it roughly works currently:
With a special JSON library it would look like this:
Serializing with nlohmann will always return an array even when empty, unlike
boost::property_tree::write_json
.If this feature is approved, would you be willing to submit a pull request with the solution?
I am willing to collaborate
Possible solution
No response
Supporting files
No response