Commit 1aa0f2ec29160f6867986954c2f588604667d626

Authored by Marius Hanne
1 parent 2a3743432b

relay unconfirmed tx every 30s

Showing 1 changed file with 10 additions and 1 deletions Side-by-side Diff

lib/bitcoin/network/node.rb
... ... @@ -37,6 +37,7 @@
37 37 :inv_queue => 5,
38 38 :addrs => 5,
39 39 :connect => 15,
  40 + :relay => 30,
40 41 },
41 42 }
42 43  
... ... @@ -107,7 +108,7 @@
107 108 init_epoll if @config[:epoll]
108 109  
109 110 EM.run do
110   - [:addrs, :connect].each do |name|
  111 + [:addrs, :connect, :relay].each do |name|
111 112 interval = @config[:intervals][name]
112 113 next if !interval || interval == 0
113 114 @timers[name] = EM.add_periodic_timer(interval, method("work_#{name}"))
... ... @@ -293,6 +294,14 @@
293 294 @store.store_tx(tx)
294 295 @connections.sample((@connections.size / 2) + 1).each do |peer|
295 296 peer.send_inv(:tx, tx)
  297 + end
  298 + end
  299 +
  300 + def work_relay
  301 + log.debug { "relay worker running" }
  302 + @store.get_unconfirmed_tx.each do |tx|
  303 + log.info { "relaying tx #{tx.hash}" }
  304 + relay_tx(tx)
296 305 end
297 306 end
298 307