Module: Weft::Facilitator::Fee

Defined in:
lib/weft/facilitator/fee.rb

Constant Summary collapse

DEFAULT_TTL =
300

Class Method Summary collapse

Class Method Details

.get_fee_info(client: Client.new, ttl: DEFAULT_TTL) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/weft/facilitator/fee.rb', line 9

def get_fee_info(client: Client.new, ttl: DEFAULT_TTL)
  return @cache[:fee] if cache_valid?

  supported = client.supported
  fee = supported['fee']
  raise 'Fee information not found in /supported response' unless fee

  validate_fee!(fee)

  @cache = {
    fee: fee,
    fetched_at: Time.now.to_i,
    ttl: ttl
  }

  fee
end

.invalidate_fee_cacheObject



27
28
29
# File 'lib/weft/facilitator/fee.rb', line 27

def invalidate_fee_cache
  @cache = nil
end