Class: Tapyrus::Message::FilterLoad
- Defined in:
- lib/tapyrus/message/filter_load.rb
Overview
filterload message bitcoin.org/en/developer-reference#filterload
Constant Summary collapse
- COMMAND =
"filterload"- BLOOM_UPDATE_NONE =
0- BLOOM_UPDATE_ALL =
1- BLOOM_UPDATE_P2PUBKEY_ONLY =
2
Constants included from Util
Instance Attribute Summary collapse
-
#filter ⇒ Object
Returns the value of attribute filter.
-
#flag ⇒ Object
Returns the value of attribute flag.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(filter, flag = BLOOM_UPDATE_ALL) ⇒ FilterLoad
constructor
A new instance of FilterLoad.
- #to_payload ⇒ Object
Methods inherited from Base
Methods included from Util
#byte_to_bit, #calc_checksum, #decode_base58_address, #double_sha256, #encode_base58_address, #hash160, #hmac_sha256, #pack_boolean, #pack_var_int, #pack_var_string, #padding_zero, #sha256, #unpack_boolean, #unpack_var_int, #unpack_var_int_from_io, #unpack_var_string, #valid_address?
Methods included from HexConverter
Constructor Details
#initialize(filter, flag = BLOOM_UPDATE_ALL) ⇒ FilterLoad
Returns a new instance of FilterLoad.
15 16 17 18 |
# File 'lib/tapyrus/message/filter_load.rb', line 15 def initialize(filter, flag = BLOOM_UPDATE_ALL) @filter = filter @flag = flag end |
Instance Attribute Details
#filter ⇒ Object
Returns the value of attribute filter.
12 13 14 |
# File 'lib/tapyrus/message/filter_load.rb', line 12 def filter @filter end |
#flag ⇒ Object
Returns the value of attribute flag.
13 14 15 |
# File 'lib/tapyrus/message/filter_load.rb', line 13 def flag @flag end |
Class Method Details
.parse_from_payload(payload) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/tapyrus/message/filter_load.rb', line 20 def self.parse_from_payload(payload) buf = StringIO.new(payload) filter_count = Tapyrus.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(Tapyrus::BloomFilter.new(filter, func_count, tweak), flag) end |
Instance Method Details
#to_payload ⇒ Object
30 31 32 33 |
# File 'lib/tapyrus/message/filter_load.rb', line 30 def to_payload Tapyrus.pack_var_int(filter.filter.size) << filter.filter.pack("C*") << [filter.hash_funcs, filter.tweak, flag].pack("VVC") end |