Base Module¶
This module contains common functions and classes used throughout the rest of the library
- 
static std::string get_user_salt()¶
- This generates a uuid4 for use in this library 
- 
static const std::string user_salt¶
- A generated uuid4 for use in this library 
- 
unsigned long long unpack_value(std::string str)¶
- Unpacks a big-endian binary value into an unsigned long long - Parameters: - str – The value you’d like to unpack - Returns: - The value this string contained - Warning - Integer overflow will not be accounted for 
- 
std::string pack_value(size_t len, unsigned long long i)¶
- Packs an unsigned long long into a big-endian binary string of length len - Parameters: - len – The length of the string you’d like to produce
- i – The value you’d like to pack
 - Returns: - A - std::stringpacked with the equivalent big-endian data- Warning - Integer overflow will not be accounted for 
- 
std::string sanitize_string(std::string str, bool sizeless)¶
- This function takes in a string and removes metadata that the - pathfinding_messagedeserializer can’t handle- Parameters: - str – The string you would like to sanitize
- sizeless – A bool indicating if this string has a size header attached
 - Returns: - A - std::stringwhich has the safe version of- str
- 
std::string decompress_string(std::string str, std::vector<std::string> compressions)¶
- This function is currently an identity function which returns - str. In the future this function will decompress strings for the- pathfinding_messageparser to deal with.- Parameters: - str – The string you would like to decompress
- compressions – A std::vector<std::string>which contains the list of possible compression methods
 - Returns: - A - std::stringwhich has the decompressed version of- str
- 
std::vector<std::string> process_string(std::string str)¶
- This deserializes a - pathfinding_messagestring into a- std::vector<std::string>of packets- Parameters: - str – The :cpp:class`std::string` you would like to parse - Returns: - A - std::vector<std::string>which contains the packets serialized in this string
- 
class protocol¶
- This class is used as a subnet object. Its role is to reject undesired connections. If you connect to someone who has a different protocol object than you, this descrepency is detected, and you are silently disconnected. - 
protocol::protocol(std::string, std::string encryption)¶
- Parameters: - subnet – The subnet you’d like to use
- encryption – The encryption method you’d like to use
 
 - 
protocol::~protocol()¶
- An empty deconstructor 
 - 
std::string protocol::id()¶
- Returns: - A - std::stringwhich contains the base_58 encoded, SHA256 based ID of this protocol object
 - 
std::string protocol::subnet()¶
 - 
std::string protocol::encryption()¶
 
- 
- 
class pathfinding_message¶
- This is the message serialization/deserialization class. - Note - This is just a wrapper for - InternalMessageStruct. Use that if you prefer efficiency over pleasant APIs.- 
pathfinding_message::pathfinding_message(std::string msg_type, std::string sender, std::vector<std::string> payload)¶
 - 
pathfinding_message::pathfinding_message(std::string msg_type, std::string sender, std::vector<std::string> payload, std::vector<std::string> compressions)¶
- Parameters: - msg_type – This is the main flag checked by nodes, used for routing information
- sender – The ID of the person sending the message
- payload – A std::vector<std::string>of “packets” that you want your peers to receive
- compression – A std::vector<std::string>of compression methods that the receiver supports
 
 - 
static pathfinding_message *pathfinding_message::feed_string(std::string msg)¶
 - 
static pathfinding_message *pathfinding_message::feed_string(std::string msg, bool sizeless)¶
 - 
static pathfinding_message *pathfinding_message::feed_string(std::string msg, std::vector<std::string> compressions)¶
 - 
static pathfinding_message *pathfinding_message::feed_string(std::string msg, bool sizeless, std::vector<std::string> compressions)¶
- Parameters: - msg – A std::stringwhich contains the serialized message
- sizeless – A boolwhich indicates if the message has a size header attached (default: it does)
- compressions – A std::vector<std::string>which contains the possible compression methods this message may be using
 - Returns: - A pointer to the deserialized message 
- msg – A 
 - 
pathfinding_message::~pathfinding_message()¶
 - 
std::string pathfinding_message::msg_type()¶
 - 
std::string pathfinding_message::sender()¶
 - 
unsigned long long pathfinding_message::timestamp()¶
 - 
std::vector<std::string> pathfinding_message::payload()¶
 - 
std::vector<std::string> pathfinding_message::compression()¶
 - 
std::string pathfinding_message::compression_used()¶
- Returns: - The compression method this message was sent under 
 - 
std::string pathfinding_message::time_58()¶
- Returns: - pathfinding_message::timestampencoded in base_58
 - 
std::string pathfinding_message::id()¶
- Returns: - A SHA384 hash of this message encoded in base_58 
 - 
std::vector<std::string> pathfinding_message::packets()¶
- A copy of - pathfinding_message::payloadwith some additional metadata appended to the front. Specifically:- pathfinding_message::msg_type
- pathfinding_message::sender
- pathfinding_message::id()
- pathfinding_message::time_58()
- pathfinding_message::payloadfrom here on out
 - Returns: - A - std::vector<std::string>in the above format
 - 
std::string pathfinding_message::str()¶
- Returns: - the serialized message, including the four byte size header at the beginning 
 - 
unsigned long long pathfinding_message::length()¶
- Returns: - the length of the serialized message, excepting the four byte size header at the beginning 
 - 
std::string pathfinding_message::header()¶
- Returns: - the four byte size header at the beginning of the serialized message 
 
-