Class: Bitcoin::Message::CFilter
- Defined in:
- lib/bitcoin/message/cfilter.rb
Overview
cfilter message for BIP-157 github.com/bitcoin/bips/blob/master/bip-0157.mediawiki#cfilter
Constant Summary collapse
- COMMAND =
'cfilter'
Instance Attribute Summary collapse
-
#block_hash ⇒ Object
little endian.
-
#filter ⇒ Object
little endian.
-
#filter_type ⇒ Object
Returns the value of attribute filter_type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(filter_type, block_hash, filter) ⇒ CFilter
constructor
A new instance of CFilter.
- #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_type, block_hash, filter) ⇒ CFilter
Returns a new instance of CFilter.
14 15 16 17 18 |
# File 'lib/bitcoin/message/cfilter.rb', line 14 def initialize(filter_type, block_hash, filter) @filter_type = filter_type @block_hash = block_hash @filter = filter end |
Instance Attribute Details
#block_hash ⇒ Object
little endian
11 12 13 |
# File 'lib/bitcoin/message/cfilter.rb', line 11 def block_hash @block_hash end |
#filter ⇒ Object
little endian
12 13 14 |
# File 'lib/bitcoin/message/cfilter.rb', line 12 def filter @filter end |
#filter_type ⇒ Object
Returns the value of attribute filter_type.
10 11 12 |
# File 'lib/bitcoin/message/cfilter.rb', line 10 def filter_type @filter_type end |
Class Method Details
.parse_from_payload(payload) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/bitcoin/message/cfilter.rb', line 20 def self.parse_from_payload(payload) buf = StringIO.new(payload) type = buf.read(1).unpack1("C") hash = buf.read(32).bth len = Bitcoin.unpack_var_int_from_io(buf) filter = buf.read(len).bth self.new(type, hash, filter) end |
Instance Method Details
#to_payload ⇒ Object
29 30 31 |
# File 'lib/bitcoin/message/cfilter.rb', line 29 def to_payload [filter_type, block_hash].pack('CH*') + Bitcoin.pack_var_string(filter.htb) end |