Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions qubipy/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

CORE_URL = 'https://api.qubic.org/v1'

MONERO_URL = 'https://xmr-stats.qubic.org' # This URL is only used to obtain monero mining stats.

TIMEOUT = 5

HEADERS = {
Expand Down
28 changes: 28 additions & 0 deletions qubipy/core/core_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,4 +541,32 @@ def get_qx_fees(self) -> Dict[str, Any]:
return data
except requests.RequestException as E:
raise QubiPy_Exceptions(f"Error when getting QX fees: {str(E)}") from None

def get_monero_mining_stats(self) -> Dict[str, Any]:

"""
Retrieves current Monero mining statistics from the external Monero system.

This function makes an API call to fetch real-time or recent data related
to Monero network mining.

Returns:
Dict[str, Any]: A dictionary containing various statistics related to Monero mining,
such as pool and network hashrates, network difficulty, block height,
and other relevant pool/miner data. The exact structure and content
depend on the Monero API response.

Raises:
QubiPy_Exceptions: If there is an issue during the API request execution (e.g.,
a network connection error, a non-2xx HTTP status code from the
API server, a timeout during the request, or if the API
response cannot be parsed as valid JSON).
"""
try:
response = requests.get(f'{MONERO_URL}{MONERO_MINING_STATS}', headers=HEADERS, timeout=self.timeout)
response.raise_for_status() # Raise an exception for bad HTTP status codes
data = response.json()
return data
except requests.RequestException as E:
raise QubiPy_Exceptions(f"Error when getting the monero mining stats: {str(E)}") from None

6 changes: 5 additions & 1 deletion qubipy/endpoints_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,8 @@

QX_ENTITY_BID_ORDERS = '/qx/getEntityBidOrders'

QX_FEES = '/qx/getFees'
QX_FEES = '/qx/getFees'

# MONERO MINING STATS

MONERO_MINING_STATS = '/stats'
2 changes: 1 addition & 1 deletion qubipy/endpoints_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

RICH_LIST = '/rich-list'

# Testing
# ASSETS

ASSETS_ISSUANCE = '/assets/issuances'

Expand Down