Sha256: b15b5b3259247d49bd7da9e6aa26c8a8cc0bfd7de5831cbd16bbd1856da54c69
Contents?: true
Size: 619 Bytes
Versions: 9
Compression:
Stored size: 619 Bytes
Contents
module Tapyrus module Message # Common message parser which handle multiple block headers as a payload. module HeadersParser def parse_from_payload(payload) ver, payload = payload.unpack('Va*') size, payload = Tapyrus.unpack_var_int(payload) hashes = [] buf = StringIO.new(payload) size.times do hashes << buf.read(32).bth end new(ver, hashes, buf.read(32).bth) end def to_payload [version].pack('V') << Tapyrus.pack_var_int(hashes.length) << hashes.map{|h|h.htb}.join << stop_hash.htb end end end end
Version data entries
9 entries across 9 versions & 1 rubygems