lib/bitcoin/protocol.rb in bitcoin-ruby-0.0.5 vs lib/bitcoin/protocol.rb in bitcoin-ruby-0.0.6
- old
+ new
@@ -10,11 +10,11 @@
# bitcoin/src/main.h
MAX_INV_SZ = 50000
# BIP 0031, pong message, is enabled for all versions AFTER this one
BIP0031_VERSION = 60000
-
+
autoload :TxIn, 'bitcoin/protocol/txin'
autoload :TxOut, 'bitcoin/protocol/txout'
autoload :Tx, 'bitcoin/protocol/tx'
autoload :Block, 'bitcoin/protocol/block'
autoload :Addr, 'bitcoin/protocol/address'
@@ -157,9 +157,13 @@
pkt "getblocks", locator_payload(version, locator_hashes, stop_hash)
end
def self.getheaders_pkt(version, locator_hashes, stop_hash=DEFAULT_STOP_HASH)
pkt "getheaders", locator_payload(version, locator_hashes, stop_hash)
+ end
+
+ def self.headers_pkt(version, blocks)
+ pkt "headers", [pack_var_int(blocks.size), blocks.map{|block| block.block_header}.join].join
end
def self.read_binary_file(path)
File.open(path, 'rb'){|f| f.read }
end