Method: Coinbase::FaucetTransaction#wait!

Defined in:
lib/coinbase/faucet_transaction.rb

#wait!(interval_seconds = 0.2, timeout_seconds = 20) ⇒ Transfer

Waits until the FaucetTransaction is completed or failed by polling on the given interval.

Parameters:

  • interval_seconds (Integer) (defaults to: 0.2)

    The interval at which to poll the Network, in seconds

  • timeout_seconds (Integer) (defaults to: 20)

    The maximum amount of time to wait for the Transfer to complete, in seconds

Returns:

  • (Transfer)

    The completed Transfer object

Raises:

  • (Timeout::Error)

    if the FaucetTransaction takes longer than the given timeout



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/coinbase/faucet_transaction.rb', line 50

def wait!(interval_seconds = 0.2, timeout_seconds = 20)
  start_time = Time.now

  loop do
    reload

    return self if transaction.terminal_state?

    raise Timeout::Error, 'Faucet transaction timed out' if Time.now - start_time > timeout_seconds

    self.sleep interval_seconds
  end

  self
end