Commit dd04c859730d9d0cfc027ee6cb36232df01ebcbb

Authored by Marius Hanne
1 parent 611b804a7f

storage: check for existing blocks only in mainchain

this solves a reorg issue when the node thinks the current chain head is a side branch

https://github.com/lian/bitcoin-ruby/issues/78

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

lib/bitcoin/storage/sequel/sequel_store.rb
... ... @@ -209,9 +209,9 @@
209 209 end
210 210 end
211 211  
212   - # check if block +blk_hash+ exists
  212 + # check if block +blk_hash+ exists in the main chain
213 213 def has_block(blk_hash)
214   - !!@db[:blk].where(:hash => blk_hash.htb.blob).get(1)
  214 + !!@db[:blk].where(:hash => blk_hash.htb.blob, :chain => 0).get(1)
215 215 end
216 216  
217 217 # check if transaction +tx_hash+ exists