-
Notifications
You must be signed in to change notification settings - Fork 0
/
service.py
68 lines (52 loc) · 1.42 KB
/
service.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
"""
Provide implementation of the node.
"""
import asyncio
from accessify import implements
from cli.node.interfaces import NodeInterface
loop = asyncio.get_event_loop()
@implements(NodeInterface)
class Node:
"""
Implements node.
"""
def __init__(self, service):
"""
Constructor.
Arguments:
service: object to interact with Remme core API.
"""
self.service = service
def get_configs(self):
"""
Get node configurations.
"""
try:
configurations = loop.run_until_complete(self.service.node_management.get_node_config())
except Exception as error:
return None, str(error)
return {
'configurations': configurations.data,
}, None
def get_peers(self):
"""
Get the node's peers.
"""
try:
peers = loop.run_until_complete(self.service.blockchain_info.get_peers())
except Exception as error:
return None, str(error)
return {
'peers': peers,
}, None
def get_info(self):
"""
Get node information.
"""
try:
information = loop.run_until_complete(self.service.node_management.get_node_info())
except Exception as error:
return None, str(error)
return {
'information': information.data,
}, None