mirror of
https://github.com/logos-blockchain/logos-blockchain-ui.git
synced 2026-07-08 00:39:28 +00:00
Add info box with peer id
This commit is contained in:
parent
ac5f0c0923
commit
c47fc8ddea
@ -219,6 +219,17 @@ QVariantMap BlockchainBackend::getCryptarchiaInfo()
|
||||
BLOCKCHAIN_MODULE_NAME, QStringLiteral("get_cryptarchia_info"))));
|
||||
}
|
||||
|
||||
QVariantMap BlockchainBackend::getPeerId()
|
||||
{
|
||||
if (!m_blockchainClient)
|
||||
return result::toVariantMap(result::err(QStringLiteral("Module not initialized.")));
|
||||
|
||||
// Derived from the node key in the user config; available without the node
|
||||
// running.
|
||||
return result::toVariantMap(result::toLogosResult(m_blockchainClient->invokeRemoteMethod(
|
||||
BLOCKCHAIN_MODULE_NAME, QStringLiteral("get_peer_id"), userConfig())));
|
||||
}
|
||||
|
||||
void BlockchainBackend::startBlockchain()
|
||||
{
|
||||
if (!m_blockchainClient) {
|
||||
|
||||
@ -46,6 +46,7 @@ public slots:
|
||||
QVariantMap transferFunds(QString fromKeyHex, QString toKeyHex, QString amountStr) override;
|
||||
QVariantMap claimLeaderRewards() override;
|
||||
QVariantMap getCryptarchiaInfo() override;
|
||||
QVariantMap getPeerId() override;
|
||||
QVariantMap generateConfig(QString outputPath, QStringList initialPeers, int netPort,
|
||||
int blendPort, QString httpAddr, QString externalAddress,
|
||||
bool noPublicIpCheck, int deploymentMode,
|
||||
|
||||
@ -16,6 +16,7 @@ class BlockchainBackend
|
||||
SLOT(QVariantMap transferFunds(QString fromKeyHex, QString toKeyHex, QString amountStr))
|
||||
SLOT(QVariantMap claimLeaderRewards())
|
||||
SLOT(QVariantMap getCryptarchiaInfo())
|
||||
SLOT(QVariantMap getPeerId())
|
||||
SLOT(QVariantMap generateConfig(QString outputPath, QStringList initialPeers, int netPort, int blendPort, QString httpAddr, QString externalAddress, bool noPublicIpCheck, int deploymentMode, QString deploymentConfigPath, QString statePath))
|
||||
SLOT(QVariantMap getNotes(QString walletAddressHex, QString optionalTipHex))
|
||||
SLOT(QVariantMap channelDepositWithNotes(QString channelIdHex, QStringList inputNoteIdHexes, QString metadataBase58, QString changePublicKeyHex, QStringList fundingPublicKeyHexes, QString maxTxFee, QString optionalTipHex))
|
||||
|
||||
@ -25,8 +25,10 @@ Rectangle {
|
||||
Connections {
|
||||
target: logos
|
||||
function onViewModuleReadyChanged(moduleName, isReady) {
|
||||
if (moduleName === "blockchain_ui")
|
||||
if (moduleName === "blockchain_ui") {
|
||||
root.ready = isReady && root.backend !== null
|
||||
if (root.ready) root.refreshPeerId()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,6 +36,7 @@ Rectangle {
|
||||
// Cover the case where the replica is already Valid by the time
|
||||
// we attach the Connections handler.
|
||||
root.ready = root.backend !== null && logos.isViewModuleReady("blockchain_ui")
|
||||
if (root.ready) root.refreshPeerId()
|
||||
}
|
||||
|
||||
// Graceful shutdown: if the window is closed while the node is running,
|
||||
@ -93,6 +96,29 @@ Rectangle {
|
||||
visible: false
|
||||
}
|
||||
|
||||
// Self libp2p peer id, derived from the selected user config (no running
|
||||
// node required). Refreshed when ready and whenever the config changes.
|
||||
property string peerId: ""
|
||||
|
||||
function refreshPeerId() {
|
||||
if (!root.backend || !root.backend.userConfig) {
|
||||
root.peerId = ""
|
||||
return
|
||||
}
|
||||
logos.watch(
|
||||
root.backend.getPeerId(),
|
||||
function(result) { root.peerId = result.success ? result.value : "" },
|
||||
function(error) { root.peerId = "" }
|
||||
)
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: root.backend
|
||||
enabled: root.backend !== null
|
||||
ignoreUnknownSignals: true
|
||||
function onUserConfigChanged() { root.refreshPeerId() }
|
||||
}
|
||||
|
||||
// Live Cryptarchia consensus state, polled while the node runs.
|
||||
property string cryptarchiaInfoJson: ""
|
||||
property string cryptarchiaInfoError: ""
|
||||
@ -306,6 +332,12 @@ Rectangle {
|
||||
onChangeConfigRequested: _d.currentPage = 0
|
||||
}
|
||||
|
||||
NodeInfoView {
|
||||
Layout.fillWidth: true
|
||||
peerId: root.peerId
|
||||
onCopyToClipboard: (text) => root.copyText(text)
|
||||
}
|
||||
|
||||
CryptarchiaInfoView {
|
||||
Layout.fillWidth: true
|
||||
visible: opPage.nodeRunning
|
||||
|
||||
62
src/qml/views/NodeInfoView.qml
Normal file
62
src/qml/views/NodeInfoView.qml
Normal file
@ -0,0 +1,62 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
|
||||
import Logos.Theme
|
||||
import Logos.Controls
|
||||
|
||||
import "../controls"
|
||||
|
||||
// "Node info" card — node identity that doesn't depend on the consensus
|
||||
// runtime. Currently the self libp2p peer id (derived from the user config).
|
||||
Rectangle {
|
||||
id: root
|
||||
|
||||
property string peerId: ""
|
||||
|
||||
signal copyToClipboard(string text)
|
||||
|
||||
implicitHeight: contentCol.implicitHeight + 2 * Theme.spacing.large
|
||||
color: Theme.palette.backgroundTertiary
|
||||
radius: Theme.spacing.radiusLarge
|
||||
border.color: Theme.palette.border
|
||||
border.width: 1
|
||||
|
||||
ColumnLayout {
|
||||
id: contentCol
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
anchors.margins: Theme.spacing.large
|
||||
spacing: Theme.spacing.small
|
||||
|
||||
LogosText {
|
||||
text: qsTr("Node info")
|
||||
font.pixelSize: Theme.typography.secondaryText
|
||||
font.bold: true
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
spacing: Theme.spacing.small
|
||||
LogosText {
|
||||
text: qsTr("Peer ID")
|
||||
Layout.preferredWidth: 70
|
||||
color: Theme.palette.textSecondary
|
||||
font.pixelSize: Theme.typography.secondaryText
|
||||
}
|
||||
LogosText {
|
||||
Layout.fillWidth: true
|
||||
text: root.peerId || qsTr("—")
|
||||
elide: Text.ElideMiddle
|
||||
font.pixelSize: Theme.typography.secondaryText
|
||||
}
|
||||
LogosCopyButton {
|
||||
Layout.preferredHeight: 24
|
||||
Layout.preferredWidth: 24
|
||||
visible: root.peerId.length > 0
|
||||
onCopyText: root.copyToClipboard(root.peerId)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2,6 +2,7 @@ module views
|
||||
StatusConfigView 1.0 StatusConfigView.qml
|
||||
BlocksView 1.0 BlocksView.qml
|
||||
CryptarchiaInfoView 1.0 CryptarchiaInfoView.qml
|
||||
NodeInfoView 1.0 NodeInfoView.qml
|
||||
AccountsView 1.0 AccountsView.qml
|
||||
TransferView 1.0 TransferView.qml
|
||||
LeaderRewardsView 1.0 LeaderRewardsView.qml
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user