Sha256: cdb3ad2a82dff26acd94ef19836831ffb423cc5e8948590839d182e3afab9c54

Contents?: true

Size: 547 Bytes

Versions: 9

Compression:

Stored size: 547 Bytes

Contents

module Tapyrus
  module Message

    # Common message parser which only handle multiple inventory as payload.
    module InventoriesParser

      def parse_from_payload(payload)
        size, payload = Tapyrus.unpack_var_int(payload)
        buf = StringIO.new(payload)
        i = new
        size.times do
          i.inventories << Inventory.parse_from_payload(buf.read(36))
        end
        i
      end

      def to_payload
        Tapyrus.pack_var_int(inventories.length) << inventories.map(&:to_payload).join
      end

    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
tapyrus-0.2.7 lib/tapyrus/message/inventories_parser.rb
tapyrus-0.2.6 lib/tapyrus/message/inventories_parser.rb
tapyrus-0.2.5 lib/tapyrus/message/inventories_parser.rb
tapyrus-0.2.4 lib/tapyrus/message/inventories_parser.rb
tapyrus-0.2.3 lib/tapyrus/message/inventories_parser.rb
tapyrus-0.2.2 lib/tapyrus/message/inventories_parser.rb
tapyrus-0.2.1 lib/tapyrus/message/inventories_parser.rb
tapyrus-0.2.0 lib/tapyrus/message/inventories_parser.rb
tapyrus-0.1.0 lib/tapyrus/message/inventories_parser.rb