diff --git a/docs/state-machines/Makefile b/docs/state-machines/Makefile index d9c6ab1..b64cf90 100644 --- a/docs/state-machines/Makefile +++ b/docs/state-machines/Makefile @@ -1,7 +1,7 @@ default: images -images: boss.png code.png key.png machines.png mailbox.png nameplate.png nameplate_lister.png order.png receive.png send.png terminator.png +images: boss.png code.png key.png machines.png mailbox.png nameplate.png lister.png order.png receive.png send.png terminator.png .PHONY: default images diff --git a/docs/state-machines/code.dot b/docs/state-machines/code.dot index 2b76493..b56fa1d 100644 --- a/docs/state-machines/code.dot +++ b/docs/state-machines/code.dot @@ -15,7 +15,7 @@ digraph { S2 -> P2_completion [label=""] P2_completion [shape="box" label="do completion"] P2_completion -> P0_list_nameplates - P0_list_nameplates [shape="box" label="NL.refresh_nameplates"] + P0_list_nameplates [shape="box" label="L.refresh_nameplates"] P0_list_nameplates -> S2 S2 -> P2_got_nameplates [label="got_nameplates"] diff --git a/docs/state-machines/nameplate_lister.dot b/docs/state-machines/lister.dot similarity index 89% rename from docs/state-machines/nameplate_lister.dot rename to docs/state-machines/lister.dot index 77b7e1e..c7300e7 100644 --- a/docs/state-machines/nameplate_lister.dot +++ b/docs/state-machines/lister.dot @@ -1,6 +1,6 @@ digraph { {rank=same; title S0A S0B} - title [label="Nameplate\nLister" style="dotted"] + title [label="(Nameplate)\nLister" style="dotted"] S0A [label="S0A:\nnot wanting\nunconnected"] S0B [label="S0B:\nnot wanting\nconnected" color="orange"] @@ -38,5 +38,5 @@ digraph { {rank=same; foo foo2 legend} legend [shape="box" style="dotted" - label="refresh: NL.refresh_nameplates()\nrx: NL.rx_nameplates()"] + label="refresh: L.refresh_nameplates()\nrx: L.rx_nameplates()"] } diff --git a/docs/state-machines/machines.dot b/docs/state-machines/machines.dot index 14955fd..e3d48d8 100644 --- a/docs/state-machines/machines.dot +++ b/docs/state-machines/machines.dot @@ -12,8 +12,8 @@ digraph { Send [shape="box" label="Send" color="blue" fontcolor="blue"] Receive [shape="box" label="Receive" color="blue" fontcolor="blue"] Code [shape="box" label="Code" color="blue" fontcolor="blue"] - NameplateLister [shape="box" label="Nameplate\nLister" - color="blue" fontcolor="blue"] + Lister [shape="box" label="(Nameplate)\nLister" + color="blue" fontcolor="blue"] Terminator [shape="box" color="blue" fontcolor="blue"] Connection -> websocket [color="blue"] @@ -58,12 +58,12 @@ digraph { Connection -> Mailbox [style="dashed" label="connected\nlost\nrx_message\nrx_closed\nstopped"] - Connection -> NameplateLister [style="dashed" - label="connected\nlost\nrx_nameplates" - ] - NameplateLister -> Connection [style="dashed" - label="tx_list" - ] + Connection -> Lister [style="dashed" + label="connected\nlost\nrx_nameplates" + ] + Lister -> Connection [style="dashed" + label="tx_list" + ] #Boss -> Code [color="blue"] Connection -> Code [style="dashed" @@ -71,13 +71,13 @@ digraph { Code -> Connection [style="dashed" label="tx_allocate" ] - NameplateLister -> Code [style="dashed" - label="got_nameplates" - ] - #Code -> NameplateLister [color="blue"] - Code -> NameplateLister [style="dashed" - label="refresh_nameplates" - ] + Lister -> Code [style="dashed" + label="got_nameplates" + ] + #Code -> Lister [color="blue"] + Code -> Lister [style="dashed" + label="refresh_nameplates" + ] Boss -> Code [style="dashed" label="allocate_code\ninput_code\nset_code_code"] Code -> Boss [style="dashed" diff --git a/src/wormhole/_boss.py b/src/wormhole/_boss.py index 709fd62..f89b964 100644 --- a/src/wormhole/_boss.py +++ b/src/wormhole/_boss.py @@ -14,7 +14,7 @@ from ._order import Order from ._key import Key from ._receive import Receive from ._rendezvous import RendezvousConnector -from ._nameplate_lister import NameplateListing +from ._lister import Lister from ._code import Code from ._terminator import Terminator from .errors import ServerError, LonelyError, WrongPasswordError @@ -44,7 +44,7 @@ class Boss(object): self._RC = RendezvousConnector(self._url, self._appid, self._side, self._reactor, self._journal, self._timing) - self._NL = NameplateListing() + self._L = Lister() self._C = Code(self._timing) self._T = Terminator() @@ -54,9 +54,9 @@ class Boss(object): self._O.wire(self._K, self._R) self._K.wire(self, self._M, self._R) self._R.wire(self, self._S) - self._RC.wire(self, self._N, self._M, self._C, self._NL, self._T) - self._NL.wire(self._RC, self._C) - self._C.wire(self, self._RC, self._NL) + self._RC.wire(self, self._N, self._M, self._C, self._L, self._T) + self._L.wire(self._RC, self._C) + self._C.wire(self, self._RC, self._L) self._T.wire(self, self._RC, self._N, self._M) self._next_tx_phase = 0 @@ -72,7 +72,7 @@ class Boss(object): def _set_trace(self, client_name, which, logger): names = {"B": self, "N": self._N, "M": self._M, "S": self._S, "O": self._O, "K": self._K, "R": self._R, - "RC": self._RC, "NL": self._NL, "C": self._C, + "RC": self._RC, "L": self._L, "C": self._C, "T": self._T} for machine in which.split(): def tracer(old_state, input, new_state, machine=machine): diff --git a/src/wormhole/_code.py b/src/wormhole/_code.py index b483f07..eeba08f 100644 --- a/src/wormhole/_code.py +++ b/src/wormhole/_code.py @@ -28,10 +28,10 @@ class Code(object): @m.setTrace() def set_trace(): pass # pragma: no cover - def wire(self, boss, rendezvous_connector, nameplate_lister): + def wire(self, boss, rendezvous_connector, lister): self._B = _interfaces.IBoss(boss) self._RC = _interfaces.IRendezvousConnector(rendezvous_connector) - self._NL = _interfaces.INameplateLister(nameplate_lister) + self._L = _interfaces.ILister(lister) @m.state(initial=True) def S0_unknown(self): pass # pragma: no cover @@ -62,7 +62,7 @@ class Code(object): @m.input() def rx_allocated(self, nameplate): pass - # from NameplateLister + # from Lister @m.input() def got_nameplates(self, nameplates): pass @@ -75,12 +75,12 @@ class Code(object): def RETURN(self, code): pass @m.output() - def NL_refresh_nameplates(self): - self._NL.refresh_nameplates() + def L_refresh_nameplates(self): + self._L.refresh_nameplates() @m.output() - def start_input_and_NL_refresh_nameplates(self, stdio): + def start_input_and_L_refresh_nameplates(self, stdio): self._stdio = stdio - self._NL.refresh_nameplates() + self._L.refresh_nameplates() @m.output() def stash_code_length(self, code_length): self._code_length = code_length @@ -124,7 +124,7 @@ class Code(object): outputs=[generate_and_B_got_code]) S0_unknown.upon(input_code, enter=S2_typing_nameplate, - outputs=[start_input_and_NL_refresh_nameplates]) + outputs=[start_input_and_L_refresh_nameplates]) S2_typing_nameplate.upon(tab, enter=S2_typing_nameplate, outputs=[do_completion_nameplates]) S2_typing_nameplate.upon(got_nameplates, enter=S2_typing_nameplate, diff --git a/src/wormhole/_interfaces.py b/src/wormhole/_interfaces.py index 0fbeaa4..e9df8c5 100644 --- a/src/wormhole/_interfaces.py +++ b/src/wormhole/_interfaces.py @@ -18,7 +18,7 @@ class IReceive(Interface): pass class IRendezvousConnector(Interface): pass -class INameplateLister(Interface): +class ILister(Interface): pass class ICode(Interface): pass diff --git a/src/wormhole/_nameplate_lister.py b/src/wormhole/_lister.py similarity index 97% rename from src/wormhole/_nameplate_lister.py rename to src/wormhole/_lister.py index e40e406..c43a927 100644 --- a/src/wormhole/_nameplate_lister.py +++ b/src/wormhole/_lister.py @@ -3,8 +3,8 @@ from zope.interface import implementer from automat import MethodicalMachine from . import _interfaces -@implementer(_interfaces.INameplateLister) -class NameplateListing(object): +@implementer(_interfaces.ILister) +class Lister(object): m = MethodicalMachine() @m.setTrace() def set_trace(): pass # pragma: no cover diff --git a/src/wormhole/_rendezvous.py b/src/wormhole/_rendezvous.py index 0806495..1074931 100644 --- a/src/wormhole/_rendezvous.py +++ b/src/wormhole/_rendezvous.py @@ -91,12 +91,12 @@ class RendezvousConnector(object): # TODO: Tor goes here return endpoints.HostnameEndpoint(self._reactor, hostname, port) - def wire(self, boss, nameplate, mailbox, code, nameplate_lister, terminator): + def wire(self, boss, nameplate, mailbox, code, lister, terminator): self._B = _interfaces.IBoss(boss) self._N = _interfaces.INameplate(nameplate) self._M = _interfaces.IMailbox(mailbox) self._C = _interfaces.ICode(code) - self._NL = _interfaces.INameplateLister(nameplate_lister) + self._L = _interfaces.ILister(lister) self._T = _interfaces.ITerminator(terminator) # from Boss @@ -127,7 +127,7 @@ class RendezvousConnector(object): d.addBoth(self._stopped) - # from NameplateLister + # from Lister def tx_list(self): self._tx("list") @@ -143,7 +143,7 @@ class RendezvousConnector(object): self._C.connected() self._N.connected() self._M.connected() - self._NL.connected() + self._L.connected() def ws_message(self, payload): msg = bytes_to_dict(payload) @@ -177,7 +177,7 @@ class RendezvousConnector(object): self._C.lost() self._N.lost() self._M.lost() - self._NL.lost() + self._L.lost() # internal def _stopped(self, res): @@ -210,7 +210,7 @@ class RendezvousConnector(object): nameplate_id = n["id"] assert isinstance(nameplate_id, type("")), type(nameplate_id) nids.append(nameplate_id) - self._NL.rx_nameplates(nids) + self._L.rx_nameplates(nids) def _response_handle_ack(self, msg): pass diff --git a/src/wormhole/wormhole.py b/src/wormhole/wormhole.py index 527bcde..42cab86 100644 --- a/src/wormhole/wormhole.py +++ b/src/wormhole/wormhole.py @@ -127,7 +127,7 @@ class _DeferredWormhole(object): self._closed_observers.append(d) return d - def debug_set_trace(self, client_name, which="B N M S O K R RC NL C T", + def debug_set_trace(self, client_name, which="B N M S O K R RC L C T", logger=_log): self._boss._set_trace(client_name, which, logger)