lib/bitcoin/protocol/parser.rb in bitcoin-ruby-0.0.10 vs lib/bitcoin/protocol/parser.rb in bitcoin-ruby-0.0.11
- old
+ new
@@ -54,10 +54,17 @@
b = Block.new; b.parse_data_from_io(buf, header_only=true); b
}
@h.on_headers(headers)
end
+ def parse_mrkle_block(payload)
+ return unless @h.respond_to?(:on_mrkle_block)
+ b = Block.new
+ b.parse_data_from_io(payload, header_only= :filtered)
+ @h.on_mrkle_block(b)
+ end
+
def parse_getblocks(payload)
version, payload = payload.unpack('Va*')
count, payload = Protocol.unpack_var_int(payload)
buf, payload = payload.unpack("a#{count*32}a*")
hashes = buf.each_byte.each_slice(32).map{|i| hash = i.reverse.pack("C32").hth }
@@ -84,9 +91,10 @@
when 'pong'; @h.on_pong(payload.unpack("Q")[0])
when 'getblocks'; @h.on_getblocks(*parse_getblocks(payload)) if @h.respond_to?(:on_getblocks)
when 'getheaders'; @h.on_getheaders(*parse_getblocks(payload)) if @h.respond_to?(:on_getheaders)
when 'mempool'; handle_mempool_request(payload)
when 'notfound'; handle_notfound_reply(payload)
+ when 'merkleblock'; parse_mrkle_block(payload)
when 'reject'; handle_reject(payload)
else
parse_error :unknown_packet, [command, payload.hth]
end
end