Sha256: 630537d745b688dd353c43d5920589df6896a05b6ea39bfbba9a6fdfbbcdc56d

Contents?: true

Size: 1.02 KB

Versions: 7

Compression:

Stored size: 1.02 KB

Contents

module TxCatcher

  class Address < Sequel::Model
    one_to_many :deposits

    def received_in_btc
      CryptoUnit.new(Config["currency"], self.received, from_unit: :primary).to_standart
    end

    def self.find_or_catch_and_create(a)
      # Even if there are not transactions to this address yet, we still create it,
      # because calling this method means someone is interested in this address and we need
      # to track it and maybe force catching it not just through mempool and ZeroMQ (see catcher.rb),
      # but also directly through querying RPC (slow, but at least we won't miss it).
      Address.find_or_create(address: a)

      if addr&.deposits.empty? && addr.created_at < (Time.now - 3600)
        # The address is in the DB, which means someone has been checking it,
        # but no deposits were associated with it and it's been more than 1 hour
        # since someone first got interested. Let's query the RPC directly, see if there were any transactions to this
        # address.

      end
    end

  end


end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
txcatcher-0.2.14 lib/txcatcher/models/address.rb
txcatcher-0.2.12 lib/txcatcher/models/address.rb
txcatcher-0.2.11 lib/txcatcher/models/address.rb
txcatcher-0.2.10 lib/txcatcher/models/address.rb
txcatcher-0.2.9 lib/txcatcher/models/address.rb
txcatcher-0.2.8 lib/txcatcher/models/address.rb
txcatcher-0.2.6 lib/txcatcher/models/address.rb