forked from ethereum/web3.py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin.py
93 lines (72 loc) · 1.56 KB
/
admin.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
from typing import (
Callable,
List,
Tuple,
)
from web3._utils.compat import (
Protocol,
)
from web3._utils.rpc_abi import (
RPC,
)
from web3.method import (
Method,
default_root_munger,
)
from web3.module import (
Module,
)
from web3.types import (
EnodeURI,
NodeInfo,
Peer,
)
def admin_start_params_munger(
_module: Module,
host: str = "localhost",
port: int = 8546,
cors: str = "",
apis: str = "eth,net,web3",
) -> Tuple[str, int, str, str]:
return (host, port, cors, apis)
add_peer: Method[Callable[[EnodeURI], bool]] = Method(
RPC.admin_addPeer,
mungers=[default_root_munger],
)
datadir: Method[Callable[[], str]] = Method(
RPC.admin_datadir,
is_property=True,
)
node_info: Method[Callable[[], NodeInfo]] = Method(
RPC.admin_nodeInfo,
is_property=True,
)
peers: Method[Callable[[], List[Peer]]] = Method(
RPC.admin_peers,
is_property=True,
)
class ServerConnection(Protocol):
def __call__(
self,
host: str = "localhost",
port: int = 8546,
cors: str = "",
apis: str = "eth,net,web3",
) -> bool:
pass
start_http: Method[ServerConnection] = Method(
RPC.admin_startHTTP,
mungers=[admin_start_params_munger],
)
start_ws: Method[ServerConnection] = Method(
RPC.admin_startWS,
mungers=[admin_start_params_munger],
)
stop_http: Method[Callable[[], bool]] = Method(
RPC.admin_stopHTTP,
is_property=True,
)
stop_ws: Method[Callable[[], bool]] = Method(
RPC.admin_stopWS,
is_property=True,
)