diff --git a/bin/dnetview/README.md b/bin/dnetview/README.md index de2dd05a1..46ff70a3a 100644 --- a/bin/dnetview/README.md +++ b/bin/dnetview/README.md @@ -1,131 +1,41 @@ # dnetview -A simple tui to explore darkfi ircd network topology. Lists all active -nodes, their connections and recent messages. +A simple tui to explore darkfi ircd network topology. + +dnetview displays: + +1. all active nodes +2. outgoing, incoming and manual sessions +3. each associated connection and recent messages. dnetview is based on the design-pattern Model, View, Controller. We create a logical seperation between the underlying data structure or Model; the ui rendering aspect which is the View; and the Controller or game engine that makes everything run. -## Version 0.1 +## install -The current data structure or model of dnetview is this: - -### Model -``` - Mutex> - Mutex> +```shell +% git clone https://github.com/darkrenaissance/darkfi +% cd darkfi +% make BINS=dnetview ``` -### View -View is a copy of the model data with additional parameters. We remove -the Mutex and add 'ListState' and 'Index' that allow us to use IdList -and InfoList as lists. +## usage -``` - IdList { - ListState, - HashSet - } - InfoList { - Index, - HashMap - } +Run dnetview as follows: + +```shell +dnetview -v ``` -### Controller +On first run, dnetview will create a config file in .config/darkfi. You +must manually enter the RPC ports of the nodes you want to connect to +and title them as you see fit. -Inside our main function we create two parallel threads: run_rpc and render. +Dnetview creates a logging file in /tmp/dnetview.log. To see json data +and other debug info, tail the file like so: -``` -Parallel::new() { - run_rpc(model) - render(model) -} - -``` - -run_rpc polls the rpc every 2 seconds. This function updates the -underlying model which is protected by mutexes, and detaches in the -background. - -render takes the latest model data and updates the view in a loop. - -``` -loop { - view = model.update() - } -``` - -## Version 0.2: - -In the first version, we could scroll the list of connected nodes and -also scroll a corresponding list of NodeInfo. In the lastest version, -the model is made more generic to allow for many types of selectable -objects: NodeInfo, SessionInfo, and ConnectInfo. - -### Model - -The model has 3 types of SelectableObjects which are organized around -an enum: - -``` -enum SelectableObject { - Node(NodeId) - Session(SessionId) - Connect(ConnectId) -} -``` -Id is a randomly generated number to correspond to the received info. - -We copy all of these values into a info hashmap. - -``` -infos = Mutex> -``` - -We use mutexes to protect the data because we are updating it -asynchronously. - -### View - -View is a copy of model without mutex's and with an index that allows the -objects to be scrollable lists. - -We create a IdsList which is a hashset of all the IDs and a ListState. -This allows us to transform SelectableObject's into a scrollable list. - -``` -IdsList = HashSet -``` - -We also create a function called render() that draws each window. - -``` -NodeInfo.render() -SessionInfo.render() -ConnectInfo.render() -``` - -### Controller - -Like the previous version, we have two functions that run in parallel: -run_rpc() and render(). In run_rpc, we poll the rpc and write the new -values to the model: - - -``` - info = NodeInfo::new()... - session = SessionInfo::new()... - connection = ConnectInfo::new()... - model_vec.push(info, session, connection) -``` - -We then continuously update the view with the new data from the model. - -``` -loop { - view = model.update() -} +```shell +tail -f /tmp/dnetview.log ```