Commit Graph

52 Commits

Author SHA1 Message Date
lunar-mining
4a748d85f1 Merge branch 'master' of github.com:darkrenaissance/darkfi 2022-03-28 23:53:39 +02:00
parazyd
f940f653b2 General clippy cleanups. 2022-03-28 21:03:17 +02:00
parazyd
9b429d9b6c Update dependency versions. 2022-03-28 19:59:38 +02:00
parazyd
29c0cb9c09 Update dependency versions throughout project. 2022-03-28 19:59:37 +02:00
lunar-mining
d6b48f71a8 remove Addr structs and cleanup 2022-03-20 11:21:14 +01:00
lunar-mining
ba574bd75c create new data structures to enable addr sub-list 2022-03-19 09:23:05 +01:00
lunar-mining
6e5d94c632 ui: removed redundant is_empty check 2022-03-19 07:43:15 +01:00
lunar-mining
845040f978 small fix on Empty slot data
* Stopped pasting "Empty" on top of "Null"
2022-03-19 07:38:06 +01:00
lunar-mining
acb77e5be9 display node name instead of rpc_url
* read name param from config and display in UI
* rename node_id to rpc_url
2022-03-19 07:22:08 +01:00
lunar-mining
f19aeeecc8 add 'name' param to dnetview_config.toml 2022-03-19 07:13:00 +01:00
lunar-mining
344e06f7c8 rename Map struct to DNetView 2022-03-19 07:12:36 +01:00
ghassmo
75d01fb0cb bin/dnetview: use fxhash for HashMap and HashSet 2022-03-19 00:52:33 +04:00
lunar-mining
d773815e63 bug fix: only render title if it's not empty 2022-03-18 18:56:31 +01:00
lunar-mining
6165a9fb96 bug fix: stop rendering outbound recursively
move outbound outside loop
2022-03-18 18:56:31 +01:00
lunar-mining
ce810207e9 bug fix: only print Incoming/ Outgoing/ Manual once
move title outside for loop so it doesn't get printed recursively.
2022-03-18 18:56:31 +01:00
lunar-mining
7b57c39314 bug fix: stop saving duplicate incoming values
removed nested loop that was causing incoming data to be saved twice.
2022-03-18 18:56:31 +01:00
lunar-mining
1e7c8c09eb model: add is_empty param to Slot, OutboundInfo and InboundInfo
discard empty connections efficiently and only render when is_empty
== false.

for outbound connections, use iter().all() to ensure that is_empty is
only set to false when all slots are empty.
2022-03-18 18:56:31 +01:00
lunar-mining
9e14a3849f ui: add debug info 2022-03-18 18:56:31 +01:00
lunar-mining
7895493c84 ui: don't render Incoming sessions if they are empty 2022-03-18 18:56:31 +01:00
parazyd
36fa2e020c net: Minor cleanups for idiomatic naming. 2022-03-17 13:35:18 +01:00
parazyd
92a4410e31 Miscellaneous fixes and 'make fix'. 2022-03-16 22:30:54 +01:00
parazyd
c7d0d4ca32 Update crate version dependencies throughout the codebase. 2022-03-16 22:30:54 +01:00
lunar-mining
560acab1b6 ui: render msgs as a vec![Spans]. finish first version of dnetview.
Previously, we were trying to render messages using a seperate widget
called Paragraph. This would enable us to put msgs on the right of the
screen using the enum Alignment.

However, rendering msgs as a seperate widget meant we had to keep track
of the position of other widgets in order to align properly. This quickly
became highly complex.

Instead, we have now rendered all the data in a single widget called List.
List is composed of a ListItem which is composed of Spans. Spans
indiciate a seperate line whereas Span is a grapheme on a single line.

We render addrs and msgs on the same line as follows:

    lines.push(Spans::from(vec![addr, msgs])

Where lines is a Vec<Spans> that initializes ListItem.

We are currently aligning the msgs Span with empty spaces, which is the
method used by tui-rs/example/list.rs. Ideally we would use some variant
of Alignment for this so we don't have variation between screen sizes.
2022-03-16 08:49:38 +01:00
lunar-mining
72205bc1f0 ui: render connection data (no msgs)
render is working properly as of this commit. we still do not render
msgs, as using a different alignment requires more complexity.
2022-03-15 14:08:22 +01:00
lunar-mining
0086435862 ui: dramatically simplify.
removed all structs and now simply printing connection data under the
related node ID.

for now there is zero formatting: we simply print the info.
2022-03-15 14:08:22 +01:00
lunar-mining
a43c8a84bd ui: better names.
ListObject -> NodeBox
NetFrame -> ConnectBox
NetWidget -> InfoBox
2022-03-14 11:47:58 +01:00
lunar-mining
4f79726875 ui() bug fix.
replace

    if foo.to_str().is_empty()

with

    if foo.to_str() == "Empty"
2022-03-14 10:49:08 +01:00
lunar-mining
73af3e4d02 poll() bug fix.
do not discard empty values on outgoing connections.
2022-03-14 10:49:08 +01:00
ghassmo
456cee39dd bin/dnetview: cargo fmt 2022-03-14 01:44:50 +04:00
lunar-mining
a4f0904e46 ui() bug fix.
get_and_draw_outbound():
    * loop through the slots of every outbound connection, instead of
      just the first value (&connect.outbound[0])
    * recursively initialize and draw new widgets for each node instead
    of writing everything to the same vectors and frame.

get_and_draw_inbound()
    * recursively initialize and draw new widgets for each node instead
    of writing everything to the same vectors and frame.
2022-03-13 22:20:57 +01:00
lunar-mining
33f299f8c6 poll() bug fix.
write "Null" to Outbound object instead of empty String when the channel
is "Null".
2022-03-13 22:18:56 +01:00
lunar-mining
e6dce6d3f7 poll: fix match error due to quotation marks around str
serde_json deserializes strings with quotation marks, and you can have
to explicitly convert them using to_str() to extract the inner value.
2022-03-13 20:15:45 +01:00
lunar-mining
964c033752 ui: renamed ListWidget to ListObject 2022-03-13 13:37:25 +01:00
lunar-mining
2b408b5d88 ui: organize functions into structs
for now we have the following hierarchy:

    ListObject
    NetFrame
    NetWidget

where ListObject is composed of NetFrame's and NetFrame is composed of
NetWidget's.
2022-03-13 13:37:25 +01:00
lunar-mining
4bcf0024b3 poll: fixed bug that was discarding data from inbound connections
this line was silently crashing:

    let inbound_connect: InboundInfo = serde_json::from_value(inbound_connected.clone())?;

we resolve this by parsing the data manually.
2022-03-13 13:37:25 +01:00
lunar-mining
0756fbefb9 ui: generalize and tidy render functions
we reduce boilerplate by creating a new generic function called draw().
variables are initialized in draw_outbound(), draw_inbound(), and
draw_manual() and are then sent to draw().

dynamic resizing is enabled by returning the total frame length like so:

    let len = draw_outbound(...)
    let len = draw_inbound(..., len)

it would be cleaner to store this value in a struct. however this is non
trivial to implement.

ui::ui() cannot be async and therefore cannot use mutexes due to its use
in the following non-async function from external library tui::Terminal:

    terminal.draw(|f| {
        ui::ui(f, view.clone());
    })?;

however ui::ui() is called within the async function render(), which
means values set inside ui::ui() may be overwritten during async calls.
2022-03-12 11:43:55 +01:00
parazyd
f172f62250 cargo +nightly fmt. 2022-03-11 16:57:43 +01:00
lunar-mining
0a2cd81afe ui: check whether msg is sent or recv and display on the right
this is a quick fix to display info properly and ui.rs still needs a major cleanup and refactor.
2022-03-11 09:40:23 +01:00
lunar-mining
c522218159 poll: bug fix on external_addr parsing
let external_addr = addr.as_str().unwrap()

^ this line was crashing when we receive a Null value for external_addr.
we now set the string value to "Null" if external_addr.is_null()
2022-03-11 08:32:12 +01:00
Dastan-glitch
3c05ed70fc bin/tau-cli: remove Client struct and imple and adding optional feature on some subcommands 2022-03-10 16:38:13 -05:00
lunar-mining
827062ff96 ui: render Outbound, Inbound, and Manual connection data
created seperate functions to render the different data types.  frames
dynamically resize according to the length of the data.  we do this by
keeping track of the previous length and passing it into each new render.

there's a lot of boilerplate rn that needs to be cleaned up, and the
dynamic resizing can probably be further simplified.
2022-03-10 13:54:09 +01:00
lunar-mining
69161945d9 stop passing Config to ui::ui
NodeId is read from config and is initalized into Model.
The values from Model are then copied into View.

We therefore do not need to read this data in the UI, as it already exists in View.
2022-03-10 13:54:09 +01:00
lunar-mining
4dd9bc00d7 poll: initalize node_info HashMap and pass parsed values.
node_info = HashMap<NodeId, NodeInfo>

If we receive an external addr from the rpc data, we set that as the NodeID.
otherwise we display client's rpc port as the NodeID.

Note: this is a temporary solution until we add a 'name' param to the
config. This commit indicates a number of TODOs.
2022-03-10 13:54:09 +01:00
Dastan-glitch
657f8ec806 formatting 2022-03-09 10:22:46 -05:00
lunar-mining
70819883e2 poll: parse json data into Model structs
as the values may be null we cannot parse using this form:

    let foo: Foo = serde_json::from_value(bar)

manual_connect is the exception to this as right now we are just parsing
dummy data which is never null.

otherwise if the data is empty we simply write empty values to NodeInfo.
this will be rendered as Null in ui::ui()
2022-03-09 12:09:18 +01:00
lunar-mining
ab7650e3e0 model: created new data structures to handle p2p data
this change removes the struct called Connection and introduces ManualInfo, OutboundInfo and InboundInfo structs
2022-03-09 08:45:37 +01:00
lunar-mining
a3a8112f2e make DnvConfig a seperate crate and pass to ui 2022-03-09 08:45:37 +01:00
lunar-mining
0fadfe39d1 renamed MapConfig to DnvConfig and pass to render() 2022-03-09 08:45:37 +01:00
lunar-mining
b91955c151 cleaned up old comments and simplified run_rpc() 2022-03-09 08:45:36 +01:00
narodnik
e3857fd211 add get_info() hooks throughout net code (incomplete) used for introspecting state while p2p network is live. 2022-03-07 15:47:07 +01:00