Class: Bitcoin::Message::BlockTransactions
- Inherits:
-
Object
- Object
- Bitcoin::Message::BlockTransactions
- Defined in:
- lib/bitcoin/message/block_transactions.rb
Overview
BIP-152 Compact Block’s data format. github.com/bitcoin/bips/blob/master/bip-0152.mediawiki#BlockTransactions
Instance Attribute Summary collapse
-
#block_hash ⇒ Object
Returns the value of attribute block_hash.
-
#transactions ⇒ Object
Returns the value of attribute transactions.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(block_hash, transactions) ⇒ BlockTransactions
constructor
A new instance of BlockTransactions.
- #to_payload ⇒ Object
Constructor Details
#initialize(block_hash, transactions) ⇒ BlockTransactions
Returns a new instance of BlockTransactions.
11 12 13 14 |
# File 'lib/bitcoin/message/block_transactions.rb', line 11 def initialize(block_hash, transactions) @block_hash = block_hash @transactions = transactions end |
Instance Attribute Details
#block_hash ⇒ Object
Returns the value of attribute block_hash.
8 9 10 |
# File 'lib/bitcoin/message/block_transactions.rb', line 8 def block_hash @block_hash end |
#transactions ⇒ Object
Returns the value of attribute transactions.
9 10 11 |
# File 'lib/bitcoin/message/block_transactions.rb', line 9 def transactions @transactions end |
Class Method Details
.parse_from_payload(payload) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/bitcoin/message/block_transactions.rb', line 16 def self.parse_from_payload(payload) buf = StringIO.new(payload) block_hash = buf.read(32).bth tx_count = Bitcoin.unpack_var_int_from_io(buf) txn = tx_count.times.map{Bitcoin::Tx.parse_from_payload(buf)} self.new(block_hash, txn) end |
Instance Method Details
#to_payload ⇒ Object
24 25 26 |
# File 'lib/bitcoin/message/block_transactions.rb', line 24 def to_payload block_hash.htb << Bitcoin.pack_var_int(transactions.size) << transactions.map(&:to_payload).join end |