lib/bitcoin/protocol/parser.rb in bitcoin-ruby-0.0.6 vs lib/bitcoin/protocol/parser.rb in bitcoin-ruby-0.0.7

- old
+ new

@@ -21,21 +21,25 @@ # handles inv/getdata packets # def parse_inv(payload, type=:put) count, payload = Protocol.unpack_var_int(payload) - payload.each_byte.each_slice(36){|i| + payload.each_byte.each_slice(36).with_index{|i, idx| hash = i[4..-1].reverse.pack("C32") case i[0] when 1 if type == :put @h.on_inv_transaction(hash) else @h.on_get_transaction(hash) end when 2 if type == :put - @h.on_inv_block(hash) + if @h.respond_to?(:on_inv_block_v2) + @h.on_inv_block_v2(hash, idx, count) + else + @h.on_inv_block(hash) + end else @h.on_get_block(hash) end else p ['parse_inv error', i]