Sha256: 54f1470a33d5012d9976d0769e1773d8f6bcab84fe4f0ccfaefd516db3830d62

Contents?: true

Size: 547 Bytes

Versions: 38

Compression:

Stored size: 547 Bytes

Contents

module Bitcoin
  module Message

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

      def parse_from_payload(payload)
        size, payload = Bitcoin.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
        Bitcoin.pack_var_int(inventories.length) << inventories.map(&:to_payload).join
      end

    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
bitcoinrb-0.2.8 lib/bitcoin/message/inventories_parser.rb
bitcoinrb-0.2.7 lib/bitcoin/message/inventories_parser.rb
bitcoinrb-0.2.6 lib/bitcoin/message/inventories_parser.rb
bitcoinrb-0.2.5 lib/bitcoin/message/inventories_parser.rb
bitcoinrb-0.2.4 lib/bitcoin/message/inventories_parser.rb
bitcoinrb-0.2.2 lib/bitcoin/message/inventories_parser.rb
bitcoinrb-0.2.1 lib/bitcoin/message/inventories_parser.rb
bitcoinrb-0.2.0 lib/bitcoin/message/inventories_parser.rb
bitcoinrb-0.1.9 lib/bitcoin/message/inventories_parser.rb
bitcoinrb-0.1.8 lib/bitcoin/message/inventories_parser.rb
bitcoinrb-0.1.7 lib/bitcoin/message/inventories_parser.rb
bitcoinrb-0.1.6 lib/bitcoin/message/inventories_parser.rb
bitcoinrb-0.1.5 lib/bitcoin/message/inventories_parser.rb
bitcoinrb-0.1.4 lib/bitcoin/message/inventories_parser.rb
bitcoinrb-0.1.3 lib/bitcoin/message/inventories_parser.rb
bitcoinrb-0.1.2 lib/bitcoin/message/inventories_parser.rb
bitcoinrb-0.1.1 lib/bitcoin/message/inventories_parser.rb
bitcoinrb-0.0.1 lib/bitcoin/message/inventories_parser.rb