Class: Solace::Serializers::InstructionSerializer
- Inherits:
-
BaseSerializer
- Object
- BaseSerializer
- Solace::Serializers::InstructionSerializer
- Defined in:
- lib/solace/serializers/instruction_serializer.rb
Overview
Serializes a Solana instruction to a binary format.
Instance Attribute Summary
Attributes inherited from BaseSerializer
Instance Method Summary collapse
-
#encode_accounts ⇒ Array<Integer>
Encodes the accounts of the instruction.
-
#encode_data ⇒ Array<Integer>
Encodes the data of the instruction.
-
#encode_program_index ⇒ Integer
Encodes the program index of the instruction.
Methods inherited from BaseSerializer
Constructor Details
This class inherits a constructor from Solace::Serializers::BaseSerializer
Instance Method Details
#encode_accounts ⇒ Array<Integer>
Encodes the accounts of the instruction
The BufferLayout is:
- [Number of accounts (compact u16)]
- [Accounts (variable length u8)]
36 37 38 |
# File 'lib/solace/serializers/instruction_serializer.rb', line 36 def encode_accounts Codecs.encode_compact_u16(record.accounts.size).bytes + record.accounts end |
#encode_data ⇒ Array<Integer>
Encodes the data of the instruction
The BufferLayout is:
- [Number of data bytes (compact u16)]
- [Data bytes (variable length u8)]
47 48 49 |
# File 'lib/solace/serializers/instruction_serializer.rb', line 47 def encode_data Codecs.encode_compact_u16(record.data.size).bytes + record.data end |
#encode_program_index ⇒ Integer
Encodes the program index of the instruction
The BufferLayout is:
- [Program index (u8)]
25 26 27 |
# File 'lib/solace/serializers/instruction_serializer.rb', line 25 def encode_program_index record.program_index end |