Class: Glueby::AR::SystemInformation

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/glueby/active_record/system_information.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.broadcast_on_background?Boolean

If return timestamp is to be executed immediately

Returns:

  • (Boolean)

    true status of broadcast_on_background



72
73
74
# File 'lib/glueby/active_record/system_information.rb', line 72

def self.broadcast_on_background?
  find_by(info_key: "broadcast_on_background")&.int_value != 0
end

.set_broadcast_on_background(status) ⇒ Object

Set the status of broadcast_on_background

Parameters:

  • status (Boolean)

    status of broadcast_on_background



78
79
80
81
82
83
84
85
86
87
88
# File 'lib/glueby/active_record/system_information.rb', line 78

def self.set_broadcast_on_background(status)
  current = find_by(info_key: "broadcast_on_background")
  if current
   current.update!(info_value: boolean_to_string(status))
  else
    create!(
      info_key: "broadcast_on_background", 
      info_value: boolean_to_string(status)
    )
  end
end

.set_use_only_finalized_utxo(status) ⇒ Object

Set use_only_finalized_utxo

Parameters:

  • status (Boolean)

    status of whether to use only finalized utxo



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/glueby/active_record/system_information.rb', line 18

def self.set_use_only_finalized_utxo(status)
  current = find_by(info_key: "use_only_finalized_utxo")
  if current
    current.update!(info_value: boolean_to_string(status))
  else
    create!(
      info_key: "use_only_finalized_utxo", 
      info_value: boolean_to_string(status)
    )
  end
end

.set_utxo_provider_default_value(value) ⇒ Object

Set utxo_provider_default_value

Parameters:

  • value (Integer)

    default value for utxo provider



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/glueby/active_record/system_information.rb', line 38

def self.set_utxo_provider_default_value(value)
  current = find_by(info_key: "utxo_provider_default_value")
  if current
    current.update!(info_value: value)
  else
    create!(
      info_key: "utxo_provider_default_value", 
      info_value: value
    )
  end
end

.set_utxo_provider_pool_size(size) ⇒ Object

Set utxo_provider_pool_size

Parameters:

  • size (Integer)

    pool size of the utxo provider



58
59
60
61
62
63
64
65
66
67
68
# File 'lib/glueby/active_record/system_information.rb', line 58

def self.set_utxo_provider_pool_size(size)
  current = find_by(info_key: "utxo_provider_pool_size")
  if current
    current.update!(info_value: size)
  else
    create!(
      info_key: "utxo_provider_pool_size", 
      info_value: size
    )
  end
end

.synced_block_heightObject



5
6
7
# File 'lib/glueby/active_record/system_information.rb', line 5

def self.synced_block_height
  find_by(info_key: "synced_block_number")
end

.use_only_finalized_utxo?Boolean

Return if wallet allows to use only finalized utxo.

Returns:

  • (Boolean)

    true if wallet allows to use only finalized utxo, otherwise false.



11
12
13
# File 'lib/glueby/active_record/system_information.rb', line 11

def self.use_only_finalized_utxo?
  find_by(info_key: "use_only_finalized_utxo")&.int_value != 0
end

.utxo_provider_default_valueInteger

Return default value of the utxo provider

Returns:

  • (Integer)

    default value of utxo provider



32
33
34
# File 'lib/glueby/active_record/system_information.rb', line 32

def self.utxo_provider_default_value
  find_by(info_key: "utxo_provider_default_value")&.int_value
end

.utxo_provider_pool_sizeInteger

Return pool size of the utxo provider

Returns:

  • (Integer)

    pool size of utxo provider



52
53
54
# File 'lib/glueby/active_record/system_information.rb', line 52

def self.utxo_provider_pool_size
  find_by(info_key: "utxo_provider_pool_size")&.int_value
end

Instance Method Details

#int_valueObject



90
91
92
# File 'lib/glueby/active_record/system_information.rb', line 90

def int_value
  info_value.to_i
end