Class: Peatio::Electrum::Blockchain
- Inherits:
-
Blockchain::Abstract
- Object
- Blockchain::Abstract
- Peatio::Electrum::Blockchain
- Defined in:
- lib/peatio/electrum/blockchain.rb
Overview
See the abstract class here: github.com/openware/peatio-core/blob/master/lib/peatio/blockchain/abstract.rb
Constant Summary collapse
- DEFAULT_FEATURES =
{case_sensitive: true}.freeze
Instance Method Summary collapse
-
#configure(settings = {}) ⇒ Hash
Merges given configuration parameters with defined during initialization and returns the result.
-
#fetch_block!(block_number) ⇒ Peatio::Block
Fetches blockchain block by calling API and builds block object from response payload.
-
#initialize(custom_features = {}) ⇒ Blockchain
constructor
You could override default features by passing them to initializer.
-
#latest_block_number ⇒ Integer
Fetches current blockchain height by calling API and returns it as number.
-
#load_balance_of_address!(address, currency_id) ⇒ BigDecimal
Fetches address balance of specific currency.
Constructor Details
#initialize(custom_features = {}) ⇒ Blockchain
You could override default features by passing them to initializer.
12 13 14 |
# File 'lib/peatio/electrum/blockchain.rb', line 12 def initialize(custom_features = {}) @features = DEFAULT_FEATURES.merge(custom_features) end |
Instance Method Details
#configure(settings = {}) ⇒ Hash
Be careful with your blockchain state after configure. Clean everything what could be related to other blockchain configuration. E.g. client state.
Merges given configuration parameters with defined during initialization and returns the result.
31 32 33 |
# File 'lib/peatio/electrum/blockchain.rb', line 31 def configure(settings = {}) @settings.merge!(settings.slice(*SUPPORTED_SETTINGS)) end |
#fetch_block!(block_number) ⇒ Peatio::Block
Fetches blockchain block by calling API and builds block object from response payload.
42 43 44 |
# File 'lib/peatio/electrum/blockchain.rb', line 42 def fetch_block!(block_number) method_not_implemented end |
#latest_block_number ⇒ Integer
Fetches current blockchain height by calling API and returns it as number.
51 52 53 |
# File 'lib/peatio/electrum/blockchain.rb', line 51 def latest_block_number method_not_implemented end |
#load_balance_of_address!(address, currency_id) ⇒ BigDecimal
Optional. Don’t override this method if your blockchain
Fetches address balance of specific currency.
doesn’t provide functionality to get balance by address.
if error was raised on blockchain API call ClientError is raised. if blockchain API call was successful but we can’t detect balance for address Error is raised.
67 68 69 |
# File 'lib/peatio/electrum/blockchain.rb', line 67 def load_balance_of_address!(address, currency_id) raise Peatio::Blockchain::UnavailableAddressBalanceError end |