Skip to content

Commit

Permalink
add get_templates
Browse files Browse the repository at this point in the history
  • Loading branch information
Cifko committed Feb 26, 2024
1 parent 73aaa79 commit 39ae061
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 20 deletions.
6 changes: 6 additions & 0 deletions Processes/validator_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ def get_network_committees(self):
def get_fees(self, min_epoch, max_epoch, validator_node):
return self.call("get_fees", [[min_epoch, max_epoch], validator_node])

def get_template(self, address: list[int]):
return self.call("get_template", [address])

def get_templates(self, limit: int = 0):
return self.call("get_templates", [limit])


class ValidatorNode(CommonExec):
def __init__(self, base_node_grpc_port, wallet_grpc_port, node_id, peers=[]):
Expand Down
38 changes: 18 additions & 20 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,27 +98,25 @@ def cli_loop():
webbrowser.open(url)
elif command.startswith("stop"):
what = command.split(maxsplit=1)[1]
id = "base_node"
if what == "node":
if base_nodes.has(id):
base_nodes[id].stop()
elif what == "wallet":
if base_wallets.has(id):
base_wallets[id].stop()
# This should be 'VN <id>'
if r := re.match(r"vn (\d+)", what):
vn_id = int(r.group(1))
validator_nodes.stop(vn_id)
elif r := re.match(r"dan (\d+)", what):
dan_id = int(r.group(1))
dan_wallets.stop(dan_id)
elif r := re.match(r"indexer (\d+)", what):
indexer_id = int(r.group(1))
indexers.stop(indexer_id)
elif r := re.match(r"wallet (\d+)", what):
wallet_id = int(r.group(1))
base_wallets.stop(wallet_id)
elif r := re.match(r"node (\d+)", what):
node_id = int(r.group(1))
base_nodes.stop(node_id)
else:
# This should be 'VN <id>'
if r := re.match(r"vn (\d+)", what):
vn_id = int(r.group(1))
validator_nodes.stop(vn_id)
elif r := re.match(r"dan (\d+)", what):
dan_id = int(r.group(1))
dan_wallets.stop(dan_id)
elif r := re.match(r"indexer (\d+)", what):
indexer_id = int(r.group(1))
indexers.stop(indexer_id)
else:
print("Invalid stop command", command)
# which = what.split()
print("Invalid stop command", command)
# which = what.split()
elif command.startswith("start"):
what = command.split(maxsplit=1)[1]
r = re.match(r"^(vn|indexer)(?: (\d+))?(?: ([a-zA-Z0-9]{64}))?$", what)
Expand Down
8 changes: 8 additions & 0 deletions webui.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,14 @@ def get_file_binary(filename: str) -> Result: # type:ignore
return Success(base64.b64encode(data).decode("utf-8"))
return InvalidParams("File not found")

@method
def get_template(address: list[int]) -> Result: # type:ignore
return Success(self.commands.validator_nodes.any().jrpc_client.get_template(address))

@method
def get_templates(limit: int) -> Result: # type:ignore
return Success(self.commands.validator_nodes.any().jrpc_client.get_templates(limit))


class WebuiServer(CommonExec):
def __init__(self, jrpc_webui_server_address: str, local_ip: str):
Expand Down

0 comments on commit 39ae061

Please sign in to comment.