Introduce PeersIndicator component #127

Closed
hebasto wants to merge 4 commits from 220603-peers into main AGit
hebasto commented 2022-06-03 17:59:02 +00:00 (Migrated from github.com)

The reference design: https://bitcoindesign.github.io/Bitcoin-Core-App/assets/images/block-clock-connection-states-big.png

Design features implementation:

  • a single blinking dot
  • dots are lit up proportional to the count of the outbound peers

Looking for designers' Concept (N)ACK, and developers' notes regarding QML code.

Windows
macOS
Android

The reference design: https://bitcoindesign.github.io/Bitcoin-Core-App/assets/images/block-clock-connection-states-big.png Design features implementation: - [x] a single blinking dot - [x] dots are lit up proportional to the count of the outbound peers Looking for designers' Concept (N)ACK, and developers' notes regarding QML code. [![Windows](https://img.shields.io/badge/OS-Windows-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/win64/insecure_win_gui.zip?branch=pull/127) [![macOS](https://img.shields.io/badge/OS-macOS-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/macos/insecure_mac_gui.zip?branch=pull/127) [![Android](https://img.shields.io/badge/OS-Android-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/android/insecure_android_apk.zip?branch=pull/127)
jarolrod (Migrated from github.com) requested changes 2022-06-03 18:33:54 +00:00
jarolrod (Migrated from github.com) left a comment

the design specifies spacing of 5 between each connection dot, and that each connection dot be 3x3, see: https://www.figma.com/file/GaCoOSNHB2yMB9ThiDtred/Bitcoin-Core-App?node-id=3288%3A70945

With these changes, it'll look a bit small in its current demo. But it should look fine when it's a part of the block clock.

the design specifies spacing of 5 between each connection dot, and that each connection dot be 3x3, see: https://www.figma.com/file/GaCoOSNHB2yMB9ThiDtred/Bitcoin-Core-App?node-id=3288%3A70945 With these changes, it'll look a bit small in its current demo. But it should look fine when it's a part of the block clock.
jarolrod (Migrated from github.com) commented 2022-06-03 18:31:57 +00:00
        spacing: 5
```suggestion spacing: 5 ```
jarolrod (Migrated from github.com) commented 2022-06-03 18:32:05 +00:00
                width: 3
```suggestion width: 3 ```
jarolrod (Migrated from github.com) commented 2022-06-03 18:32:12 +00:00
                height: 3
```suggestion height: 3 ```
hebasto commented 2022-06-03 19:28:37 +00:00 (Migrated from github.com)

Fixed circular dependency.

the design specifies spacing of 5 between each connection dot, and that each connection dot be 3x3, see: https://www.figma.com/file/GaCoOSNHB2yMB9ThiDtred/Bitcoin-Core-App?node-id=3288%3A70945

Thanks! Updated.

But now dots look like square pixels :)

cc @GBKS

Fixed circular dependency. > the design specifies spacing of 5 between each connection dot, and that each connection dot be 3x3, see: https://www.figma.com/file/GaCoOSNHB2yMB9ThiDtred/Bitcoin-Core-App?node-id=3288%3A70945 Thanks! Updated. But now dots look like square pixels :) cc @GBKS
jarolrod commented 2022-06-03 19:38:03 +00:00 (Migrated from github.com)

@hebasto yes that is true, if we need to scale it, we can scale it from the current proportions. The orginal implementation looked a lot like the PageIndicator we had before.

@hebasto yes that is true, if we need to scale it, we can scale it from the current proportions. The orginal implementation looked a lot like the PageIndicator we had before.
hebasto commented 2022-06-03 19:47:35 +00:00 (Migrated from github.com)

we can scale it from the current proportions

Talking about scaling, we should scale down, rather up.

> we can scale it from the current proportions Talking about scaling, we should scale down, rather up.
shaavan (Migrated from github.com) reviewed 2022-06-03 20:32:03 +00:00
shaavan (Migrated from github.com) left a comment

Concept ACK

  • The added code changes effectively introduce the progress indicator.
  • I was able to successfully compile and run the PR on Ubuntu 22.04 with Qt version 5.15.3
  • As @jarolrod mentioned, following the design guide precisely regarding sizing and spacing leads to dots being relatively smaller than the ones displayed in PR.

Demo:

According to this PR According design guide
Screencast from 04-06-22 01 35 41 AM IST Screencast from 04-06-22 01 37 59 AM IST

I have attached my notes for this PR.

Notes:

  1. The first commit replaces the “notify only about the total number of nodes change” to “notify about change in any type of nodes”. This change is necessary for the progress indicator component.
    1. This is done by introducing a new struct PeersNumByType, which tracks all the types of nodes along with the total number of nodes.
  2. The second commit introduces the variable to track the number of outbound peers connected and the total number of outbound peers that can connect.
  3. The third commit introduces the PageIndicator.qml file, which utilizes the above two variables to display a real-time indicator for the number of peers connected to our node.
  4. Commit four, including the PageIndicator.qml to the stub.qml file, allowing it to be displayed on the screen.
Concept ACK - The added code changes effectively introduce the progress indicator. - I was able to successfully compile and run the PR on Ubuntu 22.04 with Qt version 5.15.3 - As @jarolrod mentioned, following the design guide precisely regarding sizing and spacing leads to dots being relatively smaller than the ones displayed in PR. Demo: |According to this PR | According design guide| |----------------------------|--------------------------------| |![Screencast from 04-06-22 01 35 41 AM IST](https://user-images.githubusercontent.com/85434418/171947216-0d75fce5-47e1-4849-8afc-fcd242664d1c.gif)|![Screencast from 04-06-22 01 37 59 AM IST](https://user-images.githubusercontent.com/85434418/171947259-c129d1c7-3ac5-4b95-9b57-8e653b6237e3.gif)| I have attached my notes for this PR. **Notes:** 1. The first commit replaces the “notify only about the total number of nodes change” to “notify about change in any type of nodes”. This change is necessary for the progress indicator component. 1. This is done by introducing a new struct PeersNumByType, which tracks all the types of nodes along with the total number of nodes. 2. The second commit introduces the variable to track the number of outbound peers connected and the total number of outbound peers that can connect. 3. The third commit introduces the PageIndicator.qml file, which utilizes the above two variables to display a real-time indicator for the number of peers connected to our node. 4. Commit four, including the PageIndicator.qml to the stub.qml file, allowing it to be displayed on the screen.
shaavan (Migrated from github.com) commented 2022-06-03 20:31:53 +00:00

How about making it a readonly property? Should we permit other files to edit this property outside of this file?

    readonly property int maxNumOutboundPeers: 10
How about making it a readonly property? Should we permit other files to edit this property outside of this file? ```suggestion readonly property int maxNumOutboundPeers: 10 ```
jarolrod (Migrated from github.com) reviewed 2022-06-03 20:35:30 +00:00
jarolrod (Migrated from github.com) commented 2022-06-03 20:35:30 +00:00

this can change when there's configuration and options handling, it's set to this value by default

this can change when there's configuration and options handling, it's set to this value by default
promag (Migrated from github.com) reviewed 2022-06-04 10:32:01 +00:00
promag (Migrated from github.com) commented 2022-06-04 10:21:14 +00:00

36e20da886

Correct me if I'm wrong but I think it's safe to use node without AddRef/Release because DeleteNode isn't called concurrently with CConnman::NotifyNumConnectionsChanged.

36e20da8867a73bdae51e211b101ffc0cbf4b55f Correct me if I'm wrong but I think it's safe to use `node` without `AddRef`/`Release` because `DeleteNode` isn't called concurrently with `CConnman::NotifyNumConnectionsChanged`.
promag (Migrated from github.com) commented 2022-06-04 10:28:55 +00:00

b0b36d6668bcf2d14438b19d849de650951ac02f

This can be Row? Then can drop width and height bindings below.

Otherwise below should bind implicitWidth and implicitHeight.

b0b36d6668bcf2d14438b19d849de650951ac02f This can be `Row`? Then can drop `width` and `height` bindings below. Otherwise below should bind `implicitWidth` and `implicitHeight`.
hebasto (Migrated from github.com) reviewed 2022-06-04 11:27:03 +00:00
hebasto (Migrated from github.com) commented 2022-06-04 11:27:03 +00:00

This can be Row?

Yes, it can. But using Item provides better encapsulation and hiding implementation details. For example, PeersIndicator { padding: 42 } will fail in the current branch.

> This can be `Row`? Yes, it can. But using `Item` provides better encapsulation and hiding implementation details. For example, `PeersIndicator { padding: 42 }` will fail in the current branch.
hebasto commented 2022-06-04 11:32:40 +00:00 (Migrated from github.com)

Updated 88b99c9a543bc0527a30c1a5d1051fddd3511513 -> aad0ff4d01c3a6fc1100d9717a21c4bce866c159 (pr127.02 -> pr127.03, diff):

Otherwise below should bind implicitWidth and implicitHeight.

Updated 88b99c9a543bc0527a30c1a5d1051fddd3511513 -> aad0ff4d01c3a6fc1100d9717a21c4bce866c159 ([pr127.02](https://github.com/hebasto/gui-qml/commits/pr127.02) -> [pr127.03](https://github.com/hebasto/gui-qml/commits/pr127.03), [diff](https://github.com/hebasto/gui-qml/compare/pr127.02..pr127.03)): - addressed @promag's [comment](https://github.com/bitcoin-core/gui-qml/pull/127#discussion_r889514484): > Otherwise below should bind `implicitWidth` and `implicitHeight`.
hebasto (Migrated from github.com) reviewed 2022-06-04 11:33:21 +00:00
hebasto (Migrated from github.com) commented 2022-06-04 11:33:21 +00:00

Otherwise below should bind implicitWidth and implicitHeight.

Thanks! Updated.

> Otherwise below should bind `implicitWidth` and `implicitHeight`. Thanks! [Updated](https://github.com/bitcoin-core/gui-qml/pull/127#issuecomment-1146592288).
hebasto (Migrated from github.com) reviewed 2022-06-04 11:36:17 +00:00
hebasto (Migrated from github.com) commented 2022-06-04 11:36:17 +00:00

Do you mind elaborating? What change do you suggest?

Do you mind elaborating? What change do you suggest?
promag (Migrated from github.com) reviewed 2022-06-04 22:16:42 +00:00
promag (Migrated from github.com) commented 2022-06-04 22:16:42 +00:00

That's my point, I think the correct code is fine. Initially, I wondered if some AddRef/Release was needed.

That's my point, I think the correct code is fine. Initially, I wondered if some `AddRef`/`Release` was needed.
jarolrod (Migrated from github.com) reviewed 2022-06-05 21:11:40 +00:00
jarolrod (Migrated from github.com) commented 2022-06-05 21:11:39 +00:00

why lump this in here, isn't the following cleaner?

diff --git a/src/qml/nodemodel.cpp b/src/qml/nodemodel.cpp
index 533baf5ef..3e2232c8a 100644
--- a/src/qml/nodemodel.cpp
+++ b/src/qml/nodemodel.cpp
@@ -18,6 +18,7 @@ NodeModel::NodeModel(interfaces::Node& node)
     : m_node{node}
 {
     ConnectToBlockTipSignal();
+    ConnectToNumConnectionsChangedSignal();
 }
 
 void NodeModel::setBlockTipHeight(int new_height)
@@ -78,16 +79,20 @@ void NodeModel::timerEvent(QTimerEvent* event)
 void NodeModel::ConnectToBlockTipSignal()
 {
     assert(!m_handler_notify_block_tip);
-    assert(!m_handler_notify_num_peers_changed);
 
     m_handler_notify_block_tip = m_node.handleNotifyBlockTip(
         [this](SynchronizationState state, interfaces::BlockTip tip, double verification_progress) {
             setBlockTipHeight(tip.block_height);
             setVerificationProgress(verification_progress);
         });
+}
 
-    m_handler_notify_num_peers_changed = m_node.handleNotifyNumConnectionsChanged(
-        [this](PeersNumByType new_num_peers) {
-            setNumOutboundPeers(new_num_peers.outbound_full_relay + new_num_peers.block_relay);
-        });
+void NodeModel::ConnectToNumConnectionsChangedSignal()
+{
+      assert(!m_handler_notify_num_peers_changed);
+
+      m_handler_notify_num_peers_changed = m_node.handleNotifyNumConnectionsChanged(
+          [this](PeersNumByType new_num_peers) {
+              setNumOutboundPeers(new_num_peers.outbound_full_relay + new_num_peers.block_relay);
+          });
 }
diff --git a/src/qml/nodemodel.h b/src/qml/nodemodel.h
index f81fce7a4..2cd3661f2 100644
--- a/src/qml/nodemodel.h
+++ b/src/qml/nodemodel.h
@@ -72,6 +72,7 @@ private:
     std::unique_ptr<interfaces::Handler> m_handler_notify_num_peers_changed;
 
     void ConnectToBlockTipSignal();
+    void ConnectToNumConnectionsChangedSignal();
 };
 
 #endif // BITCOIN_QML_NODEMODEL_H
why lump this in here, isn't the following cleaner? ``` diff diff --git a/src/qml/nodemodel.cpp b/src/qml/nodemodel.cpp index 533baf5ef..3e2232c8a 100644 --- a/src/qml/nodemodel.cpp +++ b/src/qml/nodemodel.cpp @@ -18,6 +18,7 @@ NodeModel::NodeModel(interfaces::Node& node) : m_node{node} { ConnectToBlockTipSignal(); + ConnectToNumConnectionsChangedSignal(); } void NodeModel::setBlockTipHeight(int new_height) @@ -78,16 +79,20 @@ void NodeModel::timerEvent(QTimerEvent* event) void NodeModel::ConnectToBlockTipSignal() { assert(!m_handler_notify_block_tip); - assert(!m_handler_notify_num_peers_changed); m_handler_notify_block_tip = m_node.handleNotifyBlockTip( [this](SynchronizationState state, interfaces::BlockTip tip, double verification_progress) { setBlockTipHeight(tip.block_height); setVerificationProgress(verification_progress); }); +} - m_handler_notify_num_peers_changed = m_node.handleNotifyNumConnectionsChanged( - [this](PeersNumByType new_num_peers) { - setNumOutboundPeers(new_num_peers.outbound_full_relay + new_num_peers.block_relay); - }); +void NodeModel::ConnectToNumConnectionsChangedSignal() +{ + assert(!m_handler_notify_num_peers_changed); + + m_handler_notify_num_peers_changed = m_node.handleNotifyNumConnectionsChanged( + [this](PeersNumByType new_num_peers) { + setNumOutboundPeers(new_num_peers.outbound_full_relay + new_num_peers.block_relay); + }); } diff --git a/src/qml/nodemodel.h b/src/qml/nodemodel.h index f81fce7a4..2cd3661f2 100644 --- a/src/qml/nodemodel.h +++ b/src/qml/nodemodel.h @@ -72,6 +72,7 @@ private: std::unique_ptr<interfaces::Handler> m_handler_notify_num_peers_changed; void ConnectToBlockTipSignal(); + void ConnectToNumConnectionsChangedSignal(); }; #endif // BITCOIN_QML_NODEMODEL_H ```
hebasto commented 2022-06-05 22:32:21 +00:00 (Migrated from github.com)

Updated aad0ff4d01c3a6fc1100d9717a21c4bce866c159 -> 179ca2370a (pr127.03 -> pr127.04, diff):

  • addressed @jarolrod's comment
  • added blinking of the first dot according to the design
  • other small improvements (I hope)
Updated aad0ff4d01c3a6fc1100d9717a21c4bce866c159 -> 179ca2370afc154944fafc8b651a3cf4e7ec7772 ([pr127.03](https://github.com/hebasto/gui-qml/commits/pr127.03) -> [pr127.04](https://github.com/hebasto/gui-qml/commits/pr127.04), [diff](https://github.com/hebasto/gui-qml/compare/pr127.03..pr127.04)): - addressed @jarolrod's [comment](https://github.com/bitcoin-core/gui-qml/pull/127#discussion_r889737467) - added blinking of the first dot according to the design - other small improvements (I hope)
hebasto (Migrated from github.com) reviewed 2022-06-05 22:32:45 +00:00
hebasto (Migrated from github.com) commented 2022-06-05 22:32:45 +00:00

Thanks! Updated.

Thanks! [Updated](https://github.com/bitcoin-core/gui-qml/pull/127#issuecomment-1146895205).
jarolrod commented 2022-06-06 02:25:51 +00:00 (Migrated from github.com)

concept ACK on node changes and QML changes. Node changes seem ready to open upstream

concept ACK on node changes and QML changes. Node changes seem ready to open upstream
jarolrod (Migrated from github.com) reviewed 2022-08-05 03:24:30 +00:00
jarolrod (Migrated from github.com) commented 2022-08-05 03:24:03 +00:00

I guess there's no need for this line, just look at the path and name of the file

I guess there's no need for this line, just look at the path and name of the file
jarolrod (Migrated from github.com) commented 2022-08-05 03:24:27 +00:00

Perhaps every component with a one to one link to a design file should have a link for easy reference to the design spec?

Perhaps every component with a one to one link to a design file should have a link for easy reference to the design spec?
jarolrod commented 2023-02-01 00:19:05 +00:00 (Migrated from github.com)
replaced by https://github.com/bitcoin-core/gui-qml/pull/236
hebasto commented 2023-02-01 13:37:22 +00:00 (Migrated from github.com)

replaced by #236

Closed in favour of #236.

> replaced by #236 Closed in favour of #236.
Sign in to join this conversation.
No description provided.