| 
    rippled
    
   | 
 
#include <Message.h>


Public Member Functions | |
| Message (::google::protobuf::Message const &message, protocol::MessageType type, std::optional< PublicKey > const &validator={}) | |
| Constructor.   | |
| std::size_t | getBufferSize () | 
| Retrieve the size of the packed but uncompressed message data.   | |
| std::vector< uint8_t > const & | getBuffer (Compressed tryCompressed) | 
| Retrieve the packed message data.   | |
| std::size_t | getCategory () const | 
| Get the traffic category.   | |
| std::optional< PublicKey > const & | getValidatorKey () const | 
| Get the validator's key.   | |
| T | shared_from_this (T... args) | 
| T | weak_from_this (T... args) | 
Static Public Member Functions | |
| static std::size_t | messageSize (::google::protobuf::Message const &message) | 
| static std::size_t | totalSize (::google::protobuf::Message const &message) | 
Private Types | |
| using | Compressed = compression::Compressed | 
| using | Algorithm = compression::Algorithm | 
Private Member Functions | |
| void | setHeader (std::uint8_t *in, std::uint32_t payloadBytes, int type, Algorithm compression, std::uint32_t uncompressedBytes) | 
| Set the payload header.   | |
| void | compress () | 
| Try to compress the payload.   | |
| int | getType (std::uint8_t const *in) const | 
| Get the message type from the payload header.   | |
Private Attributes | |
| std::vector< uint8_t > | buffer_ | 
| std::vector< uint8_t > | bufferCompressed_ | 
| std::size_t | category_ | 
| std::once_flag | once_flag_ | 
| std::optional< PublicKey > | validatorKey_ | 
      
  | 
  private | 
      
  | 
  private | 
| ripple::Message::Message | ( | ::google::protobuf::Message const & | message, | 
| protocol::MessageType | type, | ||
| std::optional< PublicKey > const & | validator = {}  | 
        ||
| ) | 
Constructor.
| message | Protocol message to serialize | 
| type | Protocol message type | 
| validator | Public Key of the source validator for Validation or Proposal message. Used to check if the message should be squelched. | 
Definition at line 27 of file Message.cpp.
| std::size_t ripple::Message::getBufferSize | ( | ) | 
Retrieve the size of the packed but uncompressed message data.
Definition at line 204 of file Message.cpp.
      
  | 
  static | 
Definition at line 55 of file Message.cpp.
      
  | 
  static | 
Definition at line 66 of file Message.cpp.
| std::vector< uint8_t > const & ripple::Message::getBuffer | ( | Compressed | tryCompressed | ) | 
Retrieve the packed message data.
If compressed message is requested but the message is not compressible then the uncompressed buffer is returned.
| compressed | Request compressed (Compress::On) or uncompressed (Compress::Off) payload buffer | 
Definition at line 210 of file Message.cpp.
| std::size_t ripple::Message::getCategory | ( | ) | const | 
| std::optional< PublicKey > const & ripple::Message::getValidatorKey | ( | ) | const | 
      
  | 
  private | 
Set the payload header.
Set payload header.
| in | Pointer to the payload | 
| payloadBytes | Size of the payload excluding the header size | 
| type | Protocol message type | 
| compression | Compression algorithm used in compression, currently LZ4 only. If None then the message is uncompressed. | 
| uncompressedBytes | Size of the uncompressed message | 
The header is a variable-sized structure that contains information about the type of the message and the length and encoding of the payload.
The first bit determines whether a message is compressed or uncompressed; for compressed messages, the next three bits identify the compression algorithm.
All multi-byte values are represented in big endian.
For uncompressed messages (6 bytes), numbering bits from left to right:
- The first 6 bits are set to 0. - The next 26 bits represent the payload size. - The remaining 16 bits represent the message type.
For compressed messages (10 bytes), numbering bits from left to right:
- The first 32 bits, together, represent the compression algorithm
  and payload size:
    - The first bit is set to 1 to indicate the message is compressed.
    - The next 3 bits indicate the compression algorithm.
    - The next 2 bits are reserved at this time and set to 0.
    - The remaining 26 bits represent the payload size.
- The next 16 bits represent the message type.
- The remaining 32 bits are the uncompressed message size.
The maximum size of a message at this time is 64 MB. Messages larger than this will be dropped and the recipient may, at its option, sever the link.
Definition at line 174 of file Message.cpp.
      
  | 
  private | 
Try to compress the payload.
Can be called concurrently by multiple peers but is compressed once. If the message is not compressible then the serialized buffer_ is used.
Definition at line 72 of file Message.cpp.
      
  | 
  private | 
Get the message type from the payload header.
First four bytes are the compression/algorithm flag and the payload size. Next two bytes are the message type
| in | Payload header pointer | 
Definition at line 224 of file Message.cpp.
      
  | 
  private | 
      
  | 
  private | 
      
  | 
  private | 
      
  | 
  private | 
      
  | 
  private |