mirror of
https://github.com/EvernodeXRPL/hpcore.git
synced 2026-04-29 15:37:59 +00:00
Unl change announcement to connected users. (#224)
Introduced json and bson messages for unl list announcement. When the unl set is modified send a json or bson unl list message (according to the user protocol) to all the connected users.
This commit is contained in:
@@ -133,6 +133,31 @@ namespace msg::usrmsg::bson
|
||||
encoder.flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs unl list container message.
|
||||
* @param msg String reference to copy the generated bson message string into.
|
||||
* Message format:
|
||||
* {
|
||||
* "type": "unl_change",
|
||||
* "unl": ["<pubkey1>{[1byte(11101101) prefix][32byte]}", ...], // Binary pubkey list of unl nodes.
|
||||
* }
|
||||
* @param unl_list The unl node pubkey list to be put in the message.
|
||||
*/
|
||||
void create_unl_list_container(std::vector<uint8_t> &msg, const ::std::set<std::string> &unl_list)
|
||||
{
|
||||
jsoncons::bson::bson_bytes_encoder encoder(msg);
|
||||
encoder.begin_object();
|
||||
encoder.key(msg::usrmsg::FLD_TYPE);
|
||||
encoder.string_value(msg::usrmsg::MSGTYPE_UNL_CHANGE);
|
||||
encoder.key(msg::usrmsg::FLD_UNL);
|
||||
encoder.begin_array();
|
||||
for (std::string_view unl : unl_list)
|
||||
encoder.byte_string_value(unl);
|
||||
encoder.end_array();
|
||||
encoder.end_object();
|
||||
encoder.flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a bson message sent by a user.
|
||||
* @param d BSON document to which the parsed bson should be loaded.
|
||||
|
||||
Reference in New Issue
Block a user