Commit 8d9647492c34688a75fc95e3a520ad31edc598fd

Authored by comboy
Committed by Julian Langschaedel
1 parent e5375943f0

fix on_getblocks

like this it was ignored by bitcoin core and others because it was
returning 501 blocks, it seems that we don't need to add head hash, and
just providing 500 children hashes is ok, it successfully sinced
bitcoin-qt client in this form

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

lib/bitcoin/network/connection_handler.rb
... ... @@ -223,8 +223,7 @@
223 223  
224 224 return unless depth && depth <= @node.store.get_depth
225 225 range = (depth+1..depth+500)
226   - blocks = @node.store.db[:blk].where(chain: 0, depth: range).select(:hash).all +
227   - [@node.store.db[:blk].select(:hash)[chain: 0, depth: depth+502]]
  226 + blocks = @node.store.db[:blk].where(chain: 0, depth: range).order(:depth).select(:hash).all
228 227 send_inv(:block, *blocks.map {|b| b[:hash].hth })
229 228 end
230 229