├── .gitignore ├── ruby ├── Gemfile ├── readme.md ├── Gemfile.lock └── ui.rb └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | ruby/.bundle 2 | ruby/vendor 3 | -------------------------------------------------------------------------------- /ruby/Gemfile: -------------------------------------------------------------------------------- 1 | source :rubygems 2 | 3 | gem "gtk2" 4 | gem "eventmachine" 5 | -------------------------------------------------------------------------------- /ruby/readme.md: -------------------------------------------------------------------------------- 1 | $ bundle install --path vendor 2 | $ bundle exec ruby ui.rb 3 | -------------------------------------------------------------------------------- /ruby/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: http://rubygems.org/ 3 | specs: 4 | atk (1.0.0) 5 | glib2 (>= 1.0.0) 6 | cairo (1.10.0) 7 | pkg-config 8 | eventmachine (0.12.10) 9 | gdk_pixbuf2 (1.0.0) 10 | glib2 (>= 1.0.0) 11 | glib2 (1.0.0) 12 | pkg-config 13 | gtk2 (1.0.0) 14 | atk (>= 1.0.0) 15 | gdk_pixbuf2 (>= 1.0.0) 16 | pango (>= 1.0.0) 17 | pango (1.0.0) 18 | cairo (>= 1.10.0) 19 | glib2 (>= 1.0.0) 20 | pkg-config (1.1.2) 21 | 22 | PLATFORMS 23 | ruby 24 | 25 | DEPENDENCIES 26 | eventmachine 27 | gtk2 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | Exchanges are central to the growth of Bitcoin. 3 | 4 | An exchange can be broken into two parts. 5 | 6 | * The collection and distribution of bid/ask offers 7 | 8 | * Escrow service 9 | 10 | There are advantages to breaking up this functionality into seperate 11 | services because they have very different properties. This project focuses 12 | on the bid/ask offer database. See https://github.com/donpdonp/smallest-escrow 13 | for an escrow service. 14 | 15 | A traditional exchange with a central offers database allows for consistency 16 | at the cost of a single point of failure and a communication bottleneck. An 17 | alternative is a distributed database of offers. A participant with a history 18 | of valuable offers would be a very popular network participant and traffic would 19 | increase at their location. It eliminates the arms-race of getting closer (network-wise) 20 | to the centralized exchange at the expense of network delay. 21 | 22 | # Roccobid 23 | Roccobid is a ruby/GTK desktop app to listen and publish bid/ask offers to a telehash channel. 24 | 25 | -------------------------------------------------------------------------------- /ruby/ui.rb: -------------------------------------------------------------------------------- 1 | require 'gtk2' 2 | require 'eventmachine' 3 | require 'json' 4 | 5 | class MyApp 6 | 7 | def initialize(window, thash) 8 | #EM::connect ... 9 | @window = window 10 | window_signals 11 | build_ui 12 | @window.show_all 13 | 14 | thash.burp 15 | end 16 | 17 | def label_text=(text) 18 | @label.set_text(text) 19 | end 20 | 21 | private 22 | 23 | def window_signals 24 | @window.signal_connect("destroy") { EventMachine::stop_event_loop } 25 | end 26 | 27 | def build_ui 28 | vbox = Gtk::VBox.new 29 | @button = Gtk::Button.new("Hello World") 30 | vbox.add(@button) 31 | @label = Gtk::Label.new("Time") 32 | vbox.add(@label) 33 | @window.add(vbox) 34 | end 35 | end 36 | 37 | module Thash 38 | def post_init 39 | puts "Connected to telehash.org" 40 | end 41 | 42 | def receive_data(data) 43 | json = JSON.parse(data) 44 | puts "#{json.inspect}" 45 | @my_address = json["_to"] 46 | end 47 | 48 | def burp 49 | send_datagram '{"+end":"a9993e364706816aba3e25717850c26c9cd0d89d"}', "telehash.org", 42424 50 | end 51 | end 52 | 53 | EM::run do 54 | thash = EventMachine::open_datagram_socket "0.0.0.0", 0, Thash 55 | 56 | window = Gtk::Window.new 57 | client = MyApp.new(window, thash) 58 | 59 | EventMachine::PeriodicTimer.new(1) do 60 | client.label_text = Time.now.to_s 61 | end 62 | 63 | give_tick = proc { Gtk::main_iteration; EM.next_tick(give_tick); } 64 | give_tick.call 65 | end 66 | 67 | --------------------------------------------------------------------------------