Class: Bitcoin::Message::Headers
- Inherits:
-
Base
- Object
- Base
- Bitcoin::Message::Headers
show all
- Defined in:
- lib/bitcoin/message/headers.rb
Overview
Constant Summary
collapse
- COMMAND =
'headers'
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
from_pkt, #to_pkt
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?
#to_hex
Constructor Details
#initialize(headers = []) ⇒ Headers
13
14
15
|
# File 'lib/bitcoin/message/headers.rb', line 13
def initialize( = [])
=
end
|
Instance Attribute Details
11
12
13
|
# File 'lib/bitcoin/message/headers.rb', line 11
def
end
|
Class Method Details
.parse_from_payload(payload) ⇒ Object
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/bitcoin/message/headers.rb', line 17
def self.parse_from_payload(payload)
buf = StringIO.new(payload)
= Bitcoin.unpack_var_int_from_io(buf)
h = new
.times do
h. << Bitcoin::.parse_from_payload(buf.read(80))
buf.read(1)
end
h
end
|
Instance Method Details
#to_payload ⇒ Object
28
29
30
|
# File 'lib/bitcoin/message/headers.rb', line 28
def to_payload
Bitcoin.pack_var_int(.size) << .map { |h| h.to_payload << 0x00 }.join
end
|