Sha256: 774fd044538005b6888062beeaea2c1dd6b18c111531cd67474fda5fd1c0e2b3

Contents?: true

Size: 712 Bytes

Versions: 22

Compression:

Stored size: 712 Bytes

Contents

#!/usr/bin/env ruby
#
# Connect to a random peer and download the first 500 blocks.
#
#  examples/connect.rb [testnet]
#
# see Bitcoin::Connection and Bitcoin::Protocol.

$:.unshift( File.expand_path("../../lib", __FILE__) )
require 'bitcoin/connection'

Bitcoin::network = ARGV[0] || :bitcoin

class RawJSON_Connection < Bitcoin::Connection
  def on_tx(tx)
    p ['tx', tx.hash, Time.now]
    # puts tx.to_json
  end

  def on_block(block)
    p ['block', block.hash, Time.now]
    # puts block.to_json
  end
end

EM.run do

  host = '127.0.0.1'
  #host = '217.157.1.202'

  connections = []
  #RawJSON_Connection.connect(host, 8333, connections)

  RawJSON_Connection.connect_random_from_dns(connections)

end

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
bitcoin-ruby-0.0.2 examples/connect.rb
bitcoin-ruby-0.0.1 examples/connect.rb