Class: Bitcoin::Message::FilterLoad
- Defined in:
- lib/bitcoin/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
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, #hkdf_sha256, #hmac_sha256, #pack_boolean, #pack_var_int, #pack_var_string, #padding_zero, #sha256, #tagged_hash, #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.
17 18 19 20 |
# File 'lib/bitcoin/message/filter_load.rb', line 17 def initialize(filter, flag = BLOOM_UPDATE_ALL) @filter = filter @flag = flag end |
Instance Attribute Details
#filter ⇒ Object
Returns the value of attribute filter.
14 15 16 |
# File 'lib/bitcoin/message/filter_load.rb', line 14 def filter @filter end |
#flag ⇒ Object
Returns the value of attribute flag.
15 16 17 |
# File 'lib/bitcoin/message/filter_load.rb', line 15 def flag @flag end |
Class Method Details
.parse_from_payload(payload) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/bitcoin/message/filter_load.rb', line 22 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).unpack1('V') tweak = buf.read(4).unpack1('V') flag = buf.read(1).unpack1('C') FilterLoad.new(Bitcoin::BloomFilter.new(filter, func_count, tweak), flag) end |
Instance Method Details
#to_payload ⇒ Object
32 33 34 |
# File 'lib/bitcoin/message/filter_load.rb', line 32 def to_payload Bitcoin.pack_var_int(filter.filter.size) << filter.filter.pack('C*') << [filter.hash_funcs, filter.tweak, flag].pack('VVC') end |