Class: Glueby::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/glueby/configuration.rb

Overview

Global configuration on runtime

The global configuration treats configurations for all modules in Glueby.

Examples:

Glueby.configure do |config|
  config.wallet_adapter = :activerecord
  config.rpc_config = { schema: 'http', host: '127.0.0.1', port: 12381, user: 'user', password: 'pass' }
end

Defined Under Namespace

Modules: Errors

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



21
22
23
24
# File 'lib/glueby/configuration.rb', line 21

def initialize
  @fee_provider_bears = false
  @use_utxo_provider = false
end

Instance Attribute Details

#fee_provider_bearsObject (readonly) Also known as: fee_provider_bears?

Returns the value of attribute fee_provider_bears.



13
14
15
# File 'lib/glueby/configuration.rb', line 13

def fee_provider_bears
  @fee_provider_bears
end

#use_utxo_providerObject (readonly) Also known as: use_utxo_provider?

Returns the value of attribute use_utxo_provider.



13
14
15
# File 'lib/glueby/configuration.rb', line 13

def use_utxo_provider
  @use_utxo_provider
end

Instance Method Details

#default_fee_rate=(fee_rate) ⇒ Object

Set default fee rate to the FeeEstimator::Auto

Parameters:

  • fee_rate (Integer)

    The default fee rate in tapyrus/kB to the FeeEstimator::Auto



96
97
98
# File 'lib/glueby/configuration.rb', line 96

def default_fee_rate=(fee_rate)
  Contract::FeeEstimator::Auto.default_fee_rate = fee_rate
end

#default_fixed_fee=(fee) ⇒ Object

Set default fixed fee to the FeeEstimator::Fixed

Parameters:

  • fee (Integer)

    The default fee value in tapyrus to the FeeEstimator::Fixed



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

def default_fixed_fee=(fee)
  Contract::FeeEstimator::Fixed.default_fixed_fee = fee
end

#disable_fee_provider_bears!Object

Use This to disable to use FeeProvider



58
59
60
# File 'lib/glueby/configuration.rb', line 58

def disable_fee_provider_bears!
  @fee_provider_bears = false
end

#disable_utxo_provider!Object

Disable UtxoProvider feature



76
77
78
# File 'lib/glueby/configuration.rb', line 76

def disable_utxo_provider!
  @use_utxo_provider = false
end

#enable_utxo_provider!Object

Enable UtxoProvider feature



71
72
73
# File 'lib/glueby/configuration.rb', line 71

def enable_utxo_provider!
  @use_utxo_provider = true
end

#fee_provider_bears!Object

Use This to enable to use FeeProvider to supply inputs for fees on each transaction that is created on Glueby.



53
54
55
# File 'lib/glueby/configuration.rb', line 53

def fee_provider_bears!
  @fee_provider_bears = true
end

#fee_provider_config=(config) ⇒ Object

Specify FeeProvider configuration.

Parameters:

  • config (Hash)

Options Hash (config):

  • :fixed_fee (Integer)
    • The fee that Fee Provider pays on each transaction.

  • :utxo_pool_size (Integer)
    • Fee Provider tries to keep the number of utxo in utxo pool as this size using ‘glueby:fee_provider:manage_utxo_pool` rake task. this size should not be greater than 2000.



66
67
68
# File 'lib/glueby/configuration.rb', line 66

def fee_provider_config=(config)
  FeeProvider.configure(config)
end

#rpc_config=(config) ⇒ Object

Specify connection information to Tapyrus Core RPC.

Parameters:

  • config (Hash)

Options Hash (config):

  • :schema (String)
    • http or https

  • :host (String)
    • The host of the RPC endpoint

  • :port (Integer)
    • The port of the RPC endpoint



48
49
50
# File 'lib/glueby/configuration.rb', line 48

def rpc_config=(config)
  Glueby::Internal::RPC.configure(config)
end

#utxo_provider_config=(config) ⇒ Object

Set UtxoProvider configuration

Parameters:

  • config (Hash)

Options Hash (config):

  • :default_value (Integer)
    • The fee that Fee Provider pays on each transaction.

  • :utxo_pool_size (Integer)
    • Utxo Provider tries to keep the number of utxo in utxo pool as this size using ‘glueby:utxo_provider:manage_utxo_pool` rake task. this size should not be greater than 2000.



84
85
86
# File 'lib/glueby/configuration.rb', line 84

def utxo_provider_config=(config)
  UtxoProvider.configure(config)
end

#wallet_adapter=(adapter) ⇒ Object

Specify wallet adapter.

Parameters:

  • adapter (Symbol)
    • The adapter type :activerecord, :core, or :mysql is currently supported.



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/glueby/configuration.rb', line 28

def wallet_adapter=(adapter)
  case adapter
  when :core
    Glueby::Internal::Wallet.wallet_adapter = Glueby::Internal::Wallet::TapyrusCoreWalletAdapter.new
  when :activerecord
    Glueby::Internal::Wallet.wallet_adapter = Glueby::Internal::Wallet::ActiveRecordWalletAdapter.new
  when :mysql
    Glueby::Internal::Wallet.wallet_adapter = Glueby::Internal::Wallet::MySQLWalletAdapter.new
  else
    raise 'Not implemented'
  end
end