Project

em-bitcoin

0.0
No commit activity in last 3 years
No release in over 3 years
Combining Ruby's popular EventMachine library with the ruby-bitcoin implementation to provide an extensible connector to the Bitcoin network.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme

EM-Bitcoin

The Bitcoin protocol implemented using Ruby's EventMachine. Initially extracted from bitcoin-ruby.

Using EventMachine::Bitcoin::Connection to connect to the Bitcoin network

require 'em_bitcoin'
gem 'em-bitcoin'

Remember that you always need to start the EventMachine event loop. You can't just do this:

EventMachine::Bitcoin::Connection.connect_random_from_dns

You'll need to do this, which will actually connect to the Bitcoin network and you'll see a stream of transactions.

EventMachine.run do
  EventMachine::Bitcoin::Connection.connect_random_from_dns
end

You can override the EventMachine::Connection methods to provide your application-specific logic. Such as:

class TxCounter < EventMachine::Bitcoin::Connection
  def post_init
    super
    @tx_count = 0
  end

  def receive_data(data)
    super
    @tx_count += 1
  end

  def unbind
    puts "Total transactions were: #{@tx_count}!"
  end
end

EM.run { TxCounter.connect_random_from_dns }

TODO

  • Rework the integration points to both EM and the Bitcoin protocol parser
  • Warn about some of the DNS seeds being flaky
  • Put license in gemspec
  • Write some tests
  • Write some examples

License

Available here: COPYING