Skip to content

Commit 0843876

Browse files
authored
Merge pull request #45 from HathorNetwork/dev
Release: v0.6.0
2 parents 223c145 + 22d031f commit 0843876

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

hathorlib/client.py

+13
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#
33
# This source code is licensed under the MIT license found in the
44
# LICENSE file in the root directory of this source tree.
5+
import json
56
import re
67
from typing import Any, Dict, List, NamedTuple, Optional, cast
78
from urllib.parse import urljoin
@@ -105,6 +106,18 @@ async def version(self) -> HathorVersion:
105106
else:
106107
raise RuntimeError(f'Cannot parse version {version}')
107108

109+
async def health(self) -> Dict[str, Any]:
110+
"""Return the health information of the backend."""
111+
assert self._session is not None
112+
113+
async with self._session.get(self._get_url('health')) as resp:
114+
data = await resp.text()
115+
try:
116+
parsed_json: Dict[str, Any] = json.loads(data)
117+
except json.JSONDecodeError:
118+
raise RuntimeError('Cannot parse health response: {}'.format(data))
119+
return parsed_json
120+
108121
async def get_block_template(self, address: Optional[str] = None) -> BlockTemplate:
109122
"""Return a block template."""
110123
assert self._session is not None

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
[tool.poetry]
1616
name = "hathorlib"
17-
version = "0.5.2"
17+
version = "0.6.0"
1818
description = "Hathor Network base objects library"
1919
authors = ["Hathor Team <[email protected]>"]
2020
license = "Apache-2.0"

0 commit comments

Comments
 (0)