diff --git a/peerplays_instance.py b/peerplays_instance.py new file mode 100644 index 0000000..1d8e7c7 --- /dev/null +++ b/peerplays_instance.py @@ -0,0 +1,7 @@ +""" +This module is used to initiate the peerplays instance +""" +from peerplays import PeerPlays +from config import api_url + +peerplays = PeerPlays(api_url) diff --git a/src/accounts/account_history.py b/src/accounts/account_history.py index abd423b..ce76734 100644 --- a/src/accounts/account_history.py +++ b/src/accounts/account_history.py @@ -2,12 +2,8 @@ This module contains functions to interact with the PeerPlays blockchain, specifically to retrieve account history. """ -from peerplays import PeerPlays from peerplays.account import Account -from config import api_url - -peerplays = PeerPlays(api_url) - +from peerplays_instance import peerplays def get_account_history(account_name): """ diff --git a/src/accounts/get_account.py b/src/accounts/get_account.py index d3a16ae..75c96c7 100644 --- a/src/accounts/get_account.py +++ b/src/accounts/get_account.py @@ -2,10 +2,7 @@ This module contains the function to get account information. """ from peerplays.account import Account -from peerplays import PeerPlays -from config import api_url - -peerplays = PeerPlays(api_url) +from peerplays_instance import peerplays def get_account_info(account_name): """ diff --git a/src/accounts/sons/active_sons.py b/src/accounts/sons/active_sons.py index f9b6bad..8023ed8 100644 --- a/src/accounts/sons/active_sons.py +++ b/src/accounts/sons/active_sons.py @@ -2,15 +2,13 @@ Module to fetch active sons from PeerPlays """ import sys -from peerplays import PeerPlays from src.accounts.get_account import get_account_info -from src.supply.common import api_url +from peerplays_instance import peerplays def get_active_sons(): """ Function to get active sons from PeerPlays """ - peerplays = PeerPlays(api_url) object_id_prefix = "1.33." object_id_number = 0 diff --git a/src/accounts/witnesses/witnesses.py b/src/accounts/witnesses/witnesses.py index 2cf9c00..cd9872f 100644 --- a/src/accounts/witnesses/witnesses.py +++ b/src/accounts/witnesses/witnesses.py @@ -2,15 +2,10 @@ This module contains functions to fetch the list of active witnesses. """ import logging -from peerplays import PeerPlays from peerplays.witness import Witnesses from peerplays.account import Account from cache_config import cache - - - -# connect to a peerplays1 node -peerplays = PeerPlays("wss://ca.peerplays.info/api") +from peerplays_instance import peerplays logger = logging.getLogger(__name__) diff --git a/src/blocks.py b/src/blocks.py index ece0b17..4c6f130 100644 --- a/src/blocks.py +++ b/src/blocks.py @@ -3,18 +3,15 @@ """ import logging -from peerplays import PeerPlays + from peerplays.block import Block from peerplays.witness import Witness -from config import api_url +from peerplays_instance import peerplays logger = logging.getLogger(__name__) -peerplays = PeerPlays(api_url) - - def get_block_info(block_num=None): """ Fetches and returns information about a specific block in the PeerPlays blockchain. diff --git a/src/get_latest_transactions.py b/src/get_latest_transactions.py index 77513fe..ad70c02 100644 --- a/src/get_latest_transactions.py +++ b/src/get_latest_transactions.py @@ -1,11 +1,8 @@ """ This module is used to get the latest transactions from the Peerplays blockchain. """ -from peerplays import PeerPlays from peerplays.block import Block -from config import api_url - -peerplays = PeerPlays(api_url) +from peerplays_instance import peerplays def get_block_with_transactions(block_num): """ diff --git a/src/latest_block.py b/src/latest_block.py index 7a6c89c..9c97883 100644 --- a/src/latest_block.py +++ b/src/latest_block.py @@ -2,11 +2,8 @@ This file contains the function to get the latest block from the PeerPlays blockchain. """ from peerplays.blockchain import Blockchain -from peerplays import PeerPlays +from peerplays_instance import peerplays -from config import api_url - -peerplays = PeerPlays(api_url) def get_latest_block(): """ diff --git a/src/supply/circulating_supply.py b/src/supply/circulating_supply.py index f3b2699..51670dc 100644 --- a/src/supply/circulating_supply.py +++ b/src/supply/circulating_supply.py @@ -3,7 +3,8 @@ """ from peerplays.asset import Asset from flask import Response -from src.supply.common import get_supplies, peerplays, ASSET_IDS +from src.supply.common import get_supplies, ASSET_IDS +from peerplays_instance import peerplays def circulating_supply(coin_name): diff --git a/src/supply/common.py b/src/supply/common.py index 9f62819..5fdc045 100644 --- a/src/supply/common.py +++ b/src/supply/common.py @@ -1,10 +1,6 @@ """ Common functions for supply endpoints """ -from peerplays.peerplays import PeerPlays -from config import api_url - -peerplays = PeerPlays(api_url) ASSET_IDS = { "ppy": "1.3.0", diff --git a/src/supply/max_supply.py b/src/supply/max_supply.py index 181da93..68f30ce 100644 --- a/src/supply/max_supply.py +++ b/src/supply/max_supply.py @@ -3,7 +3,8 @@ """ from peerplays.asset import Asset from flask import Response -from src.supply.common import get_supplies, peerplays, ASSET_IDS +from src.supply.common import get_supplies, ASSET_IDS +from peerplays_instance import peerplays def max_supply(coin_name): diff --git a/src/supply/rich_list.py b/src/supply/rich_list.py index cdf806e..285459d 100644 --- a/src/supply/rich_list.py +++ b/src/supply/rich_list.py @@ -3,7 +3,8 @@ """ from peerplays.asset import Asset from flask import jsonify -from src.supply.common import sats_to_fixed, peerplays, ASSET_IDS +from src.supply.common import sats_to_fixed,ASSET_IDS +from peerplays_instance import peerplays def rich_list(coin_name, num="25"): diff --git a/src/supply/supply_details.py b/src/supply/supply_details.py index 56f0061..bfe7849 100644 --- a/src/supply/supply_details.py +++ b/src/supply/supply_details.py @@ -2,15 +2,14 @@ This module is used to get the supply details of the asset. """ from peerplays.asset import Asset -from peerplays import PeerPlays from src.supply.common import get_supplies +from peerplays_instance import peerplays def get_supply_details(asset_id="1.3.0"): """ returns the supply details of the asset """ - peerplays = PeerPlays("wss://ca.peerplays.info/api") A = Asset(asset_id, blockchain_instance=peerplays) # pylint: disable=invalid-name supplies = get_supplies(A) diff --git a/src/supply/total_supply.py b/src/supply/total_supply.py index 2fcd6be..f0d266f 100644 --- a/src/supply/total_supply.py +++ b/src/supply/total_supply.py @@ -3,7 +3,8 @@ """ from peerplays.asset import Asset from flask import Response -from src.supply.common import get_supplies, peerplays, ASSET_IDS +from src.supply.common import get_supplies, ASSET_IDS +from peerplays_instance import peerplays def total_supply(coin_name):