Class: Bluzelle::Swarm::Transaction

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method, endpoint, data) ⇒ Transaction

Returns a new instance of Transaction.



9
10
11
12
13
14
15
16
17
# File 'lib/bluzelle/swarm/transaction.rb', line 9

def initialize(method, endpoint, data)
  @method = method
  @endpoint = endpoint
  @data = data
  @gas_price = 0
  @max_gas = 0
  @max_fee = 0
  @retries_left = 10
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



6
7
8
# File 'lib/bluzelle/swarm/transaction.rb', line 6

def data
  @data
end

#endpointObject (readonly)

Returns the value of attribute endpoint.



6
7
8
# File 'lib/bluzelle/swarm/transaction.rb', line 6

def endpoint
  @endpoint
end

#gas_priceObject

Returns the value of attribute gas_price.



7
8
9
# File 'lib/bluzelle/swarm/transaction.rb', line 7

def gas_price
  @gas_price
end

#max_feeObject

Returns the value of attribute max_fee.



7
8
9
# File 'lib/bluzelle/swarm/transaction.rb', line 7

def max_fee
  @max_fee
end

#max_gasObject

Returns the value of attribute max_gas.



7
8
9
# File 'lib/bluzelle/swarm/transaction.rb', line 7

def max_gas
  @max_gas
end

#memoObject

Returns the value of attribute memo.



7
8
9
# File 'lib/bluzelle/swarm/transaction.rb', line 7

def memo
  @memo
end

#methodObject (readonly)

Returns the value of attribute method.



6
7
8
# File 'lib/bluzelle/swarm/transaction.rb', line 6

def method
  @method
end

#retries_leftObject

Returns the value of attribute retries_left.



7
8
9
# File 'lib/bluzelle/swarm/transaction.rb', line 7

def retries_left
  @retries_left
end

Instance Method Details

#set_gas(gas_info) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/bluzelle/swarm/transaction.rb', line 19

def set_gas(gas_info)
  return if gas_info.nil? || !gas_info.is_a?(Hash)

  gas_info = Utils.stringify_keys(gas_info)

  @gas_price = gas_info['gas_price'].to_i if gas_info.key?('gas_price')

  @max_gas = gas_info['max_gas'].to_i if gas_info.key?('max_gas')

  @max_fee = gas_info['max_fee'].to_i if gas_info.key?('max_fee')
end