Class: Solace::Serializers::MessageDeserializer
- Inherits:
-
BaseDeserializer
- Object
- BaseDeserializer
- Solace::Serializers::MessageDeserializer
- Defined in:
- lib/solace/serializers/message_deserializer.rb
Overview
Deserializes a binary message into a Solace::Message object.
Instance Attribute Summary
Attributes inherited from BaseDeserializer
Instance Method Summary collapse
-
#next_extract_accounts ⇒ Array<String>
Extract account keys from the message.
-
#next_extract_address_lookup_table ⇒ Array<Solace::AddressLookupTable>
Extract address lookup table from the message.
-
#next_extract_instructions ⇒ Array<Solace::Instruction>
Extract instructions from the message.
-
#next_extract_message_header ⇒ Array<Integer>
Extract message header from the message.
-
#next_extract_recent_blockhash ⇒ String
Extract recent blockhash from the message.
-
#next_extract_version ⇒ Integer
Extract version from the message.
Methods inherited from BaseDeserializer
Constructor Details
This class inherits a constructor from Solace::Serializers::BaseDeserializer
Instance Method Details
#next_extract_accounts ⇒ Array<String>
Extract account keys from the message
The BufferLayout is:
- [Number of accounts (compact u16)]
- [Accounts (variable length u8)]
66 67 68 69 70 71 |
# File 'lib/solace/serializers/message_deserializer.rb', line 66 def next_extract_accounts count, = Codecs.decode_compact_u16(io) record.accounts = count.times.map do Codecs.bytes_to_base58 io.read(32).bytes end end |
#next_extract_address_lookup_table ⇒ Array<Solace::AddressLookupTable>
Extract address lookup table from the message
The BufferLayout is:
- [Number of address lookup tables (compact u16)]
- [Address lookup tables (variable length)]
104 105 106 107 108 109 110 111 |
# File 'lib/solace/serializers/message_deserializer.rb', line 104 def next_extract_address_lookup_table return unless record.versioned? count, = Codecs.decode_compact_u16(io) record.address_lookup_tables = count.times.map do Solace::AddressLookupTable.deserialize(io) end end |
#next_extract_instructions ⇒ Array<Solace::Instruction>
Extract instructions from the message
The BufferLayout is:
- [Number of instructions (compact u16)]
- [Instructions (variable length)]
90 91 92 93 94 95 |
# File 'lib/solace/serializers/message_deserializer.rb', line 90 def next_extract_instructions count, = Codecs.decode_compact_u16(io) record.instructions = count.times.map do Solace::Instruction.deserialize(io) end end |
#next_extract_message_header ⇒ Array<Integer>
Extract message header from the message
The BufferLayout is:
- [Message header (3 bytes)]
55 56 57 |
# File 'lib/solace/serializers/message_deserializer.rb', line 55 def record.header = io.read(3).bytes end |
#next_extract_recent_blockhash ⇒ String
Extract recent blockhash from the message
The BufferLayout is:
- [Recent blockhash (32 bytes)]
79 80 81 |
# File 'lib/solace/serializers/message_deserializer.rb', line 79 def next_extract_recent_blockhash record.recent_blockhash = Codecs.bytes_to_base58 io.read(32).bytes end |
#next_extract_version ⇒ Integer
Extract version from the message
Checks for version prefix and extracts version. If the prefix is not found, it assumes a legacy message and sets no version.
The BufferLayout is:
- [Version prefix (1 byte)]
- [Version (variable length)]
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/solace/serializers/message_deserializer.rb', line 38 def next_extract_version next_byte = io.read(1).unpack1('C') if next_byte & 0x80 == 0x80 record.version = next_byte & 0x7F else io.seek(-1, IO::SEEK_CUR) record.version = nil end end |