Class: Istox::BlockchainHashHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/istox/consumers/blockchain_hash_handler.rb

Class Method Summary collapse

Class Method Details

.hash_generated(data, payload_target) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/istox/consumers/blockchain_hash_handler.rb', line 4

def hash_generated(data, payload_target)
  receipt = ::Istox::BlockchainReceipt.where(txid: data.uuid).first
  if receipt.nil? 
    puts 'Transaction doesnt belong here, skipping...'
    return
  end 

  # sid cannot be nil
  update_receipt = ::Istox::BlockchainReceipt.where(txid: data.uuid, txhash: nil).where.not(sid: nil).first
  raise "Unable to find receipt to update" if update_receipt.blank?

  update_receipt.update!(txhash: data.txnHash)
end