lib/bitcoin/protocol/parser.rb in bitcoin-ruby-0.0.5 vs lib/bitcoin/protocol/parser.rb in bitcoin-ruby-0.0.6
- old
+ new
@@ -109,12 +109,12 @@
@h.on_alert Bitcoin::Protocol::Alert.parse(payload)
end
# https://en.bitcoin.it/wiki/BIP_0035
def handle_mempool_request(payload)
- return unless @version[:version] >= 60002 # Protocol version >= 60002
- return unless (@version[:services] & Bitcoin::Protocol::Version::NODE_NETWORK) == 1 # NODE_NETWORK bit set in Services
+ return unless @version.fields[:version] >= 60002 # Protocol version >= 60002
+ return unless (@version.fields[:services] & Bitcoin::Protocol::Version::NODE_NETWORK) == 1 # NODE_NETWORK bit set in Services
@h.on_mempool if @h.respond_to?(:on_mempool)
end
def handle_notfound_reply(payload)
return unless @h.respond_to?(:on_notfound)
@@ -137,10 +137,10 @@
end
def parse_buffer
head_magic = Bitcoin::network[:magic_head]
head_size = 24
- return false if @buf.size <= head_size
+ return false if @buf.size < head_size
magic, cmd, length, checksum = @buf.unpack("a4A12Va4")
payload = @buf[head_size...head_size+length]
unless magic == head_magic