Class: Ethereum::Transaction

Inherits:
Object
  • Object
show all
Defined in:
lib/ethereum/transaction.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, connection, data, input_parameters = []) ⇒ Transaction

Returns a new instance of Transaction.


6
7
8
9
10
11
12
# File 'lib/ethereum/transaction.rb', line 6

def initialize(id, connection, data, input_parameters = [])
  @mined = false
  @connection = connection
  @id = id
  @input = data
  @input_parameters = input_parameters
end

Instance Attribute Details

#connectionObject

Returns the value of attribute connection


4
5
6
# File 'lib/ethereum/transaction.rb', line 4

def connection
  @connection
end

#idObject

Returns the value of attribute id


4
5
6
# File 'lib/ethereum/transaction.rb', line 4

def id
  @id
end

#inputObject

Returns the value of attribute input


4
5
6
# File 'lib/ethereum/transaction.rb', line 4

def input
  @input
end

#input_parametersObject

Returns the value of attribute input_parameters


4
5
6
# File 'lib/ethereum/transaction.rb', line 4

def input_parameters
  @input_parameters
end

#minedObject

Returns the value of attribute mined


4
5
6
# File 'lib/ethereum/transaction.rb', line 4

def mined
  @mined
end

Instance Method Details

#mined?Boolean

Returns:

  • (Boolean)

14
15
16
17
# File 'lib/ethereum/transaction.rb', line 14

def mined?
  return true if @mined
  @mined = @connection.get_transaction_by_hash(@id)["result"]["blockNumber"].present?
end

#wait_for_miner(timeout = 1500.seconds) ⇒ Object


19
20
21
22
23
24
25
26
# File 'lib/ethereum/transaction.rb', line 19

def wait_for_miner(timeout = 1500.seconds)
  start_time = Time.now
  while self.mined? == false
    raise Timeout::Error if ((Time.now - start_time) > timeout)
    sleep 5
    return true if self.mined?
  end
end