Class: Peatio::Blockchain::Abstract Abstract
- Inherits:
-
Object
- Object
- Peatio::Blockchain::Abstract
- Defined in:
- lib/peatio/blockchain/abstract.rb
Overview
Represents basic blockchain interface.
Subclass and override abstract methods to implement a peatio plugable blockchain. Than you need to register your blockchain implementation.
Constant Summary collapse
- SUPPORTED_FEATURES =
Note:
Features list:
case_sensitive - defines if transactions and addresses of current blockchain are case_sensitive.
cash_addr_format - defines if blockchain supports Cash Address format for more info see (support.exodus.io/article/664-bitcoin-cash-address-format)
List of features supported by peatio.
%i[case_sensitive cash_addr_format].freeze
- SUPPORTED_SETTINGS =
List of configurable settings.
%i[server currencies].freeze
Instance Attribute Summary collapse
-
#features ⇒ Hash
readonly
abstract
Hash of features supported by blockchain.
-
#settings ⇒ Hash
readonly
abstract
Current blockchain settings for performing API calls and building blocks.
Instance Method Summary collapse
-
#configure(settings = {}) ⇒ Hash
abstract
Merges given configuration parameters with defined during initialization and returns the result.
-
#fetch_block!(block_number) ⇒ Peatio::Block
abstract
Fetches blockchain block by calling API and builds block object from response payload.
-
#initialize ⇒ Abstract
constructor
abstract
Abstract constructor.
-
#latest_block_number ⇒ Integer
abstract
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 ⇒ Abstract
Abstract constructor.
86 87 88 |
# File 'lib/peatio/blockchain/abstract.rb', line 86 def initialize(*) abstract_method end |
Instance Attribute Details
#features ⇒ Hash (readonly)
Hash of features supported by blockchain.
37 38 39 |
# File 'lib/peatio/blockchain/abstract.rb', line 37 def features @features end |
#settings ⇒ Hash (readonly)
Current blockchain settings for performing API calls and building blocks.
59 60 61 |
# File 'lib/peatio/blockchain/abstract.rb', line 59 def settings @settings end |
Instance Method Details
#configure(settings = {}) ⇒ Hash
Merges given configuration parameters with defined during initialization and returns the result.
103 104 105 |
# File 'lib/peatio/blockchain/abstract.rb', line 103 def configure(settings = {}) abstract_method end |
#fetch_block!(block_number) ⇒ Peatio::Block
Fetches blockchain block by calling API and builds block object from response payload.
116 117 118 |
# File 'lib/peatio/blockchain/abstract.rb', line 116 def fetch_block!(block_number) abstract_method end |
#latest_block_number ⇒ Integer
Fetches current blockchain height by calling API and returns it as number.
127 128 129 |
# File 'lib/peatio/blockchain/abstract.rb', line 127 def latest_block_number abstract_method 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.
143 144 145 |
# File 'lib/peatio/blockchain/abstract.rb', line 143 def load_balance_of_address!(address, currency_id) raise Peatio::Blockchain::UnavailableAddressBalanceError end |