Skip to content

Commit 9d03e3e

Browse files
committed
GUI, Voting dialog: filter out legacy MNs and DMNs that don't have the voting key
1 parent 7744ce1 commit 9d03e3e

File tree

8 files changed

+27
-8
lines changed

8 files changed

+27
-8
lines changed

src/interfaces/tiertwo.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ namespace interfaces {
1616

1717
std::unique_ptr<TierTwo> g_tiertwo;
1818

19+
bool TierTwo::isLegacySystemObsolete()
20+
{
21+
return deterministicMNManager->LegacyMNObsolete();
22+
}
23+
1924
bool TierTwo::isBlsPubKeyValid(const std::string& blsKey)
2025
{
2126
auto opKey = bls::DecodePublic(Params(), blsKey);

src/interfaces/tiertwo.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ class TierTwo : public CValidationInterface {
5757
// Initialize cache
5858
void init();
5959

60+
// Return true if spork21 is enabled
61+
bool isLegacySystemObsolete();
62+
6063
// Return true if the bls key is valid
6164
bool isBlsPubKeyValid(const std::string& blsKey);
6265

src/qt/pivx/masternodeswidget.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class MNHolder : public FurListRow<QWidget*>
4141
QString address = index.sibling(index.row(), MNModel::ADDRESS).data(Qt::DisplayRole).toString();
4242
QString status = index.sibling(index.row(), MNModel::STATUS).data(Qt::DisplayRole).toString();
4343
bool wasCollateralAccepted = index.sibling(index.row(), MNModel::WAS_COLLATERAL_ACCEPTED).data(Qt::DisplayRole).toBool();
44-
uint16_t type = index.sibling(index.row(), MNModel::TYPE).data(Qt::DisplayRole).toUInt();
44+
uint8_t type = index.sibling(index.row(), MNModel::TYPE).data(Qt::DisplayRole).toUInt();
4545
row->updateView("Address: " + address, label, status, wasCollateralAccepted, type);
4646
}
4747

@@ -194,7 +194,7 @@ void MasterNodesWidget::onEditMNClicked()
194194
{
195195
if (walletModel) {
196196
if (!walletModel->isRegTestNetwork() && !checkMNsNetwork()) return;
197-
uint16_t mnType = index.sibling(index.row(), MNModel::TYPE).data(Qt::DisplayRole).toUInt();
197+
uint8_t mnType = index.sibling(index.row(), MNModel::TYPE).data(Qt::DisplayRole).toUInt();
198198
if (mnType == MNViewType::LEGACY) {
199199
if (index.sibling(index.row(), MNModel::WAS_COLLATERAL_ACCEPTED).data(Qt::DisplayRole).toBool()) {
200200
// Start MN
@@ -320,7 +320,7 @@ void MasterNodesWidget::onInfoMNClicked()
320320
QString txId = index.sibling(index.row(), MNModel::COLLATERAL_ID).data(Qt::DisplayRole).toString();
321321
QString outIndex = index.sibling(index.row(), MNModel::COLLATERAL_OUT_INDEX).data(Qt::DisplayRole).toString();
322322
QString pubKey = index.sibling(index.row(), MNModel::PUB_KEY).data(Qt::DisplayRole).toString();
323-
bool isLegacy = ((uint16_t) index.sibling(index.row(), MNModel::TYPE).data(Qt::DisplayRole).toUInt()) == MNViewType::LEGACY;
323+
bool isLegacy = ((uint8_t) index.sibling(index.row(), MNModel::TYPE).data(Qt::DisplayRole).toUInt()) == MNViewType::LEGACY;
324324
Optional<DMNData> opDMN = nullopt;
325325
if (!isLegacy) {
326326
QString proTxHash = index.sibling(index.row(), MNModel::PRO_TX_HASH).data(Qt::DisplayRole).toString();
@@ -360,7 +360,7 @@ void MasterNodesWidget::onDeleteMNClicked()
360360
QString txId = index.sibling(index.row(), MNModel::COLLATERAL_ID).data(Qt::DisplayRole).toString();
361361
QString outIndex = index.sibling(index.row(), MNModel::COLLATERAL_OUT_INDEX).data(Qt::DisplayRole).toString();
362362
QString qAliasString = index.data(Qt::DisplayRole).toString();
363-
bool isLegacy = ((uint16_t) index.sibling(index.row(), MNModel::TYPE).data(Qt::DisplayRole).toUInt()) == MNViewType::LEGACY;
363+
bool isLegacy = ((uint8_t) index.sibling(index.row(), MNModel::TYPE).data(Qt::DisplayRole).toUInt()) == MNViewType::LEGACY;
364364

365365
bool convertOK = false;
366366
unsigned int indexOut = outIndex.toUInt(&convertOK);

src/qt/pivx/mnmodel.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,11 @@ bool MNModel::isMNCollateralMature(const QString& mnAlias)
275275
return mn->collateralId && collateralTxAccepted.value(mn->collateralId->hash.GetHex());
276276
}
277277

278+
bool MNModel::isLegacySystemObsolete()
279+
{
280+
return interfaces::g_tiertwo->isLegacySystemObsolete();
281+
}
282+
278283
bool MNModel::isMNsNetworkSynced()
279284
{
280285
return g_tiertwo_sync_state.IsSynced();

src/qt/pivx/mnmodel.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class CMasternode;
1515
class DMNView;
1616
class WalletModel;
1717

18-
enum MNViewType : uint16_t
18+
enum MNViewType : uint8_t
1919
{
2020
LEGACY = 0,
2121
DMN_OWNER = (1 << 0),
@@ -88,7 +88,9 @@ class MNModel : public QAbstractTableModel
8888
bool addMn(CMasternodeConfig::CMasternodeEntry* entry);
8989
void updateMNList();
9090

91-
91+
// Whether the MN legacy system is active or not
92+
bool isLegacySystemObsolete();
93+
// Whether the tier two synchronization completed or not
9294
bool isMNsNetworkSynced();
9395
// Returns the MN activeState field.
9496
int getMNState(const QString& mnAlias);

src/qt/pivx/mnrow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ void MNRow::updateView(QString address,
2222
const QString& label,
2323
QString status,
2424
bool wasCollateralAccepted,
25-
uint16_t type)
25+
uint8_t type)
2626
{
2727
ui->labelName->setText(label);
2828
address = address.size() < 40 ? address : address.left(20) + "..." + address.right(20);

src/qt/pivx/mnrow.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class MNRow : public QWidget
2323
const QString& label,
2424
QString status,
2525
bool wasCollateralAccepted,
26-
uint16_t type);
26+
uint8_t type);
2727

2828
Q_SIGNALS:
2929
void onMenuClicked();

src/qt/pivx/mnselectiondialog.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,11 @@ void MnSelectionDialog::updateView()
111111
QFlags<Qt::ItemFlag> flgCheckbox = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable;
112112
QFlags<Qt::ItemFlag> flgTristate = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsTristate;
113113

114+
bool isLegacyObselete = mnModel->isLegacySystemObsolete();
114115
for (int i = 0; i < mnModel->rowCount(); ++i) {
116+
uint8_t mnType = mnModel->index(i, MNModel::TYPE, QModelIndex()).data().toUInt();
117+
if (mnType == MNViewType::LEGACY && isLegacyObselete) continue;
118+
if (mnType == MNViewType::DMN_OPERATOR || mnType == MNViewType::DMN_OWNER) continue;
115119
QString alias = mnModel->index(i, MNModel::ALIAS, QModelIndex()).data().toString();
116120
QString status = mnModel->index(i, MNModel::STATUS, QModelIndex()).data().toString();
117121
VoteInfo* ptrVoteInfo{nullptr};

0 commit comments

Comments
 (0)