Class: Bitcoin::Message::Addr
Overview
addr message bitcoin.org/en/developer-reference#addr
Constant Summary collapse
- COMMAND =
'addr'
Instance Attribute Summary collapse
-
#addrs ⇒ Object
readonly
Returns the value of attribute addrs.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(addrs = []) ⇒ Addr
constructor
A new instance of Addr.
- #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(addrs = []) ⇒ Addr
Returns a new instance of Addr.
14 15 16 |
# File 'lib/bitcoin/message/addr.rb', line 14 def initialize(addrs = []) @addrs = addrs end |
Instance Attribute Details
#addrs ⇒ Object (readonly)
Returns the value of attribute addrs.
12 13 14 |
# File 'lib/bitcoin/message/addr.rb', line 12 def addrs @addrs end |
Class Method Details
.parse_from_payload(payload) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/bitcoin/message/addr.rb', line 18 def self.parse_from_payload(payload) buf = StringIO.new(payload) addr_count = Bitcoin.unpack_var_int_from_io(buf) addr = new addr_count.times do addr.addrs << NetworkAddr.parse_from_payload(buf) end addr end |
Instance Method Details
#to_payload ⇒ Object
28 29 30 |
# File 'lib/bitcoin/message/addr.rb', line 28 def to_payload Bitcoin.pack_var_int(addrs.length) << addrs.map(&:to_payload).join end |