Class: Solace::Serializers::TransactionSerializer

Inherits:
BaseSerializer show all
Defined in:
lib/solace/serializers/transaction_serializer.rb

Constant Summary collapse

SIGNATURE_PLACEHOLDER =
([0] * 64).pack('C*')

Instance Attribute Summary

Attributes inherited from BaseSerializer

#record

Instance Method Summary collapse

Methods inherited from BaseSerializer

#call, #initialize

Methods inherited from Base

call, #call

Constructor Details

This class inherits a constructor from Solace::Serializers::BaseSerializer

Instance Method Details

#encode_messageArray<Integer>

Encodes the message from the transaction

Returns:

  • (Array<Integer>)

    The bytes of the encoded message



42
43
44
# File 'lib/solace/serializers/transaction_serializer.rb', line 42

def encode_message
  record.message.to_bytes
end

#encode_signaturesArray<Integer>

Encodes the signatures of the transaction

Iterates over the number sum number of signatures and either encodes or sets the placeholder for each expected index in the signatures array.

The BufferLayout is:

- [Number of signatures (compact u16)]
- [Signatures (variable length)]

Returns:

  • (Array<Integer>)

    The bytes of the encoded signatures



34
35
36
37
# File 'lib/solace/serializers/transaction_serializer.rb', line 34

def encode_signatures
  Codecs.encode_compact_u16(record.signatures.size).bytes +
    index_signatures(record.message.num_required_signatures)
end