mirror of https://github.com/nucypher/nucypher.git
Hook-up JSON-IPC to Character CLI action entry points
parent
92b7a62d3a
commit
ef088d8f31
|
@ -480,5 +480,4 @@ class Character(Learner):
|
|||
crash_on_error=crash_on_error)
|
||||
|
||||
drone.controller = controller
|
||||
rpc_control = controller.make_control_transport() # TODO
|
||||
return controller
|
||||
|
|
|
@ -6,13 +6,16 @@ from typing import Callable
|
|||
|
||||
from flask import Response, Flask
|
||||
from hendrix.deploy.base import HendrixDeploy
|
||||
from twisted.internet import reactor
|
||||
from twisted.internet import reactor, stdio
|
||||
from twisted.logger import Logger
|
||||
|
||||
from nucypher.characters.control.emitters import StdoutEmitter, WebEmitter, JSONRPCStdoutEmitter
|
||||
from nucypher.characters.control.interfaces import (AliceInterface, character_control_interface, EnricoInterface, \
|
||||
BobInterface
|
||||
)
|
||||
from nucypher.characters.control.interfaces import (
|
||||
AliceInterface,
|
||||
character_control_interface,
|
||||
EnricoInterface,
|
||||
BobInterface
|
||||
)
|
||||
from nucypher.characters.control.serializers import (
|
||||
AliceControlJSONSerializer,
|
||||
BobControlJSONSerializer,
|
||||
|
@ -201,7 +204,7 @@ class JSONRPCController(CharacterControlServer):
|
|||
_emitter_class = JSONRPCStdoutEmitter
|
||||
|
||||
def start(self):
|
||||
self.make_control_transport()
|
||||
_transport = self.make_control_transport()
|
||||
reactor.run() # < ------ Blocking Call (Reactor)
|
||||
|
||||
def test_client(self) -> JSONRPCTestClient:
|
||||
|
@ -209,7 +212,7 @@ class JSONRPCController(CharacterControlServer):
|
|||
return test_client
|
||||
|
||||
def make_control_transport(self):
|
||||
transport = JSONRPCLineReceiver(rpc_controller=self)
|
||||
transport = stdio.StandardIO(JSONRPCLineReceiver(rpc_controller=self))
|
||||
return transport
|
||||
|
||||
def get_interface(self, name: str) -> Callable:
|
||||
|
|
|
@ -188,6 +188,7 @@ def alice(click_config,
|
|||
# RPC
|
||||
if click_config.json_ipc:
|
||||
rpc_controller = ALICE.make_rpc_controller()
|
||||
_transport = rpc_controller.make_control_transport()
|
||||
rpc_controller.start()
|
||||
return
|
||||
|
||||
|
|
|
@ -136,6 +136,15 @@ def bob(click_config,
|
|||
|
||||
# Echo Public Keys
|
||||
click_config.emit(message=f"Bob Verifying Key {bytes(BOB.stamp).hex()}", color='green', bold=True)
|
||||
|
||||
# RPC
|
||||
if click_config.json_ipc:
|
||||
rpc_controller = BOB.make_rpc_controller()
|
||||
_transport = rpc_controller.make_control_transport()
|
||||
rpc_controller.start()
|
||||
return
|
||||
|
||||
click_config.emitter(message=f"Bob Verifying Key {bytes(BOB.stamp).hex()}", color='green', bold=True)
|
||||
bob_encrypting_key = bytes(BOB.public_keys(DecryptingPower)).hex()
|
||||
click_config.emit(message=f"Bob Encrypting Key {bob_encrypting_key}", color="blue", bold=True)
|
||||
|
||||
|
|
|
@ -46,6 +46,14 @@ def enrico(click_config, action, policy_encrypting_key, dry_run, http_port, mess
|
|||
#
|
||||
|
||||
if action == 'run':
|
||||
|
||||
# RPC
|
||||
if click_config.json_ipc:
|
||||
rpc_controller = ENRICO.make_rpc_controller()
|
||||
_transport = rpc_controller.make_control_transport()
|
||||
rpc_controller.start()
|
||||
return
|
||||
|
||||
ENRICO.log.info('Starting HTTP Character Web Controller')
|
||||
controller = ENRICO.make_web_controller()
|
||||
return controller.start(http_port=http_port, dry_run=dry_run)
|
||||
|
|
Loading…
Reference in New Issue