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-1.7.0 lib/bitcoin/message/inventories_parser.rb
bitcoinrb-1.6.0 lib/bitcoin/message/inventories_parser.rb
bitcoinrb-1.5.0 lib/bitcoin/message/inventories_parser.rb
bitcoinrb-1.4.0 lib/bitcoin/message/inventories_parser.rb
bitcoinrb-1.3.0 lib/bitcoin/message/inventories_parser.rb
bitcoinrb-1.2.1 lib/bitcoin/message/inventories_parser.rb
bitcoinrb-1.2.0 lib/bitcoin/message/inventories_parser.rb
bitcoinrb-1.1.1 lib/bitcoin/message/inventories_parser.rb
bitcoinrb-1.1.0 lib/bitcoin/message/inventories_parser.rb
bitcoinrb-1.0.0 lib/bitcoin/message/inventories_parser.rb
bitcoinrb-0.9.0 lib/bitcoin/message/inventories_parser.rb
bitcoinrb-0.8.0 lib/bitcoin/message/inventories_parser.rb
bitcoinrb-0.7.0 lib/bitcoin/message/inventories_parser.rb
bitcoinrb-0.6.0 lib/bitcoin/message/inventories_parser.rb
bitcoinrb-0.5.0 lib/bitcoin/message/inventories_parser.rb
bitcoinrb-0.4.0 lib/bitcoin/message/inventories_parser.rb
bitcoinrb-0.3.2 lib/bitcoin/message/inventories_parser.rb
bitcoinrb-0.3.1 lib/bitcoin/message/inventories_parser.rb
bitcoinrb-0.3.0 lib/bitcoin/message/inventories_parser.rb
bitcoinrb-0.2.9 lib/bitcoin/message/inventories_parser.rb