class Bitcoin::Message::Headers
headers message bitcoin.org/en/developer-reference#headers
Constants
- COMMAND
Attributes
headers[RW]
Public Class Methods
new(headers = [])
click to toggle source
# File lib/bitcoin/message/headers.rb, line 13 def initialize(headers = []) @headers = headers end
parse_from_payload(payload)
click to toggle source
# File lib/bitcoin/message/headers.rb, line 17 def self.parse_from_payload(payload) buf = StringIO.new(payload) header_count = Bitcoin.unpack_var_int_from_io(buf) h = new header_count.times do h.headers << Bitcoin::BlockHeader.parse_from_payload(buf.read(80)) buf.read(1) # read tx count 0x00 (headers message doesn't include any tx.) end h end
Public Instance Methods
to_payload()
click to toggle source
# File lib/bitcoin/message/headers.rb, line 28 def to_payload Bitcoin.pack_var_int(headers.size) << headers.map { |h| h.to_payload << 0x00 }.join end