class Bitcoin::Message::CFHeaders
cfheaders message for BIP-157 github.com/bitcoin/bips/blob/master/bip-0157.mediawiki#cfheaders
Constants
- COMMAND
Attributes
filter_hashes[RW]
filter_type[RW]
prev_filter_header[RW]
stop_hash[RW]
Public Class Methods
new(filter_type, stop_hash, prev_filter_header, filter_hashes)
click to toggle source
# File lib/bitcoin/message/cfheaders.rb, line 15 def initialize(filter_type, stop_hash, prev_filter_header, filter_hashes) @filter_type = filter_type @stop_hash = stop_hash @prev_filter_header = prev_filter_header @filter_hashes = filter_hashes end
parse_from_payload(payload)
click to toggle source
# File lib/bitcoin/message/cfheaders.rb, line 22 def self.parse_from_payload(payload) buf = StringIO.new(payload) type = buf.read(1).unpack1("C") hash = buf.read(32).bth header = buf.read(32).bth count = Bitcoin.unpack_var_int_from_io(buf) hashes = count.times.map{buf.read(32).bth} self.new(type, hash, header, hashes) end
Public Instance Methods
to_payload()
click to toggle source
# File lib/bitcoin/message/cfheaders.rb, line 32 def to_payload [filter_type].pack('C') + stop_hash.htb + prev_filter_header.htb + Bitcoin.pack_var_int(filter_hashes.size) + filter_hashes.map(&:htb).join end