Sha256: 0b8bb0174d61adaa2f81e93ec69737856b4383b7e32b211fdbe863c94dbb8dbb
Contents?: true
Size: 1.02 KB
Versions: 17
Compression:
Stored size: 1.02 KB
Contents
module Bitcoin module Message # filterload message # https://bitcoin.org/en/developer-reference#filterload class FilterLoad < Base COMMAND = 'filterload' BLOOM_UPDATE_NONE = 0 BLOOM_UPDATE_ALL = 1 BLOOM_UPDATE_P2PUBKEY_ONLY = 2 attr_accessor :filter attr_accessor :flag def initialize(filter, flag = BLOOM_UPDATE_ALL) @filter = filter @flag = flag end def self.parse_from_payload(payload) buf = StringIO.new(payload) filter_count = Bitcoin.unpack_var_int_from_io(buf) filter = buf.read(filter_count).unpack('C*') func_count = buf.read(4).unpack('V').first tweak = buf.read(4).unpack('V').first flag = buf.read(1).unpack('C').first FilterLoad.new(Bitcoin::BloomFilter.new(filter, func_count, tweak), flag) end def to_payload Bitcoin.pack_var_int(filter.filter.size) << filter.filter.pack('C*') << [filter.hash_funcs, filter.tweak, flag].pack('VVC') end end end end
Version data entries
17 entries across 17 versions & 1 rubygems