Skip to content

Commit

Permalink
GUI, Voting dialog: filter out legacy MNs and DMNs that don't have th…
Browse files Browse the repository at this point in the history
…e voting key
  • Loading branch information
furszy committed Feb 22, 2022
1 parent 7744ce1 commit 9d03e3e
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 8 deletions.
5 changes: 5 additions & 0 deletions src/interfaces/tiertwo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ namespace interfaces {

std::unique_ptr<TierTwo> g_tiertwo;

bool TierTwo::isLegacySystemObsolete()
{
return deterministicMNManager->LegacyMNObsolete();
}

bool TierTwo::isBlsPubKeyValid(const std::string& blsKey)
{
auto opKey = bls::DecodePublic(Params(), blsKey);
Expand Down
3 changes: 3 additions & 0 deletions src/interfaces/tiertwo.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ class TierTwo : public CValidationInterface {
// Initialize cache
void init();

// Return true if spork21 is enabled
bool isLegacySystemObsolete();

// Return true if the bls key is valid
bool isBlsPubKeyValid(const std::string& blsKey);

Expand Down
8 changes: 4 additions & 4 deletions src/qt/pivx/masternodeswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class MNHolder : public FurListRow<QWidget*>
QString address = index.sibling(index.row(), MNModel::ADDRESS).data(Qt::DisplayRole).toString();
QString status = index.sibling(index.row(), MNModel::STATUS).data(Qt::DisplayRole).toString();
bool wasCollateralAccepted = index.sibling(index.row(), MNModel::WAS_COLLATERAL_ACCEPTED).data(Qt::DisplayRole).toBool();
uint16_t type = index.sibling(index.row(), MNModel::TYPE).data(Qt::DisplayRole).toUInt();
uint8_t type = index.sibling(index.row(), MNModel::TYPE).data(Qt::DisplayRole).toUInt();
row->updateView("Address: " + address, label, status, wasCollateralAccepted, type);
}

Expand Down Expand Up @@ -194,7 +194,7 @@ void MasterNodesWidget::onEditMNClicked()
{
if (walletModel) {
if (!walletModel->isRegTestNetwork() && !checkMNsNetwork()) return;
uint16_t mnType = index.sibling(index.row(), MNModel::TYPE).data(Qt::DisplayRole).toUInt();
uint8_t mnType = index.sibling(index.row(), MNModel::TYPE).data(Qt::DisplayRole).toUInt();
if (mnType == MNViewType::LEGACY) {
if (index.sibling(index.row(), MNModel::WAS_COLLATERAL_ACCEPTED).data(Qt::DisplayRole).toBool()) {
// Start MN
Expand Down Expand Up @@ -320,7 +320,7 @@ void MasterNodesWidget::onInfoMNClicked()
QString txId = index.sibling(index.row(), MNModel::COLLATERAL_ID).data(Qt::DisplayRole).toString();
QString outIndex = index.sibling(index.row(), MNModel::COLLATERAL_OUT_INDEX).data(Qt::DisplayRole).toString();
QString pubKey = index.sibling(index.row(), MNModel::PUB_KEY).data(Qt::DisplayRole).toString();
bool isLegacy = ((uint16_t) index.sibling(index.row(), MNModel::TYPE).data(Qt::DisplayRole).toUInt()) == MNViewType::LEGACY;
bool isLegacy = ((uint8_t) index.sibling(index.row(), MNModel::TYPE).data(Qt::DisplayRole).toUInt()) == MNViewType::LEGACY;
Optional<DMNData> opDMN = nullopt;
if (!isLegacy) {
QString proTxHash = index.sibling(index.row(), MNModel::PRO_TX_HASH).data(Qt::DisplayRole).toString();
Expand Down Expand Up @@ -360,7 +360,7 @@ void MasterNodesWidget::onDeleteMNClicked()
QString txId = index.sibling(index.row(), MNModel::COLLATERAL_ID).data(Qt::DisplayRole).toString();
QString outIndex = index.sibling(index.row(), MNModel::COLLATERAL_OUT_INDEX).data(Qt::DisplayRole).toString();
QString qAliasString = index.data(Qt::DisplayRole).toString();
bool isLegacy = ((uint16_t) index.sibling(index.row(), MNModel::TYPE).data(Qt::DisplayRole).toUInt()) == MNViewType::LEGACY;
bool isLegacy = ((uint8_t) index.sibling(index.row(), MNModel::TYPE).data(Qt::DisplayRole).toUInt()) == MNViewType::LEGACY;

bool convertOK = false;
unsigned int indexOut = outIndex.toUInt(&convertOK);
Expand Down
5 changes: 5 additions & 0 deletions src/qt/pivx/mnmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,11 @@ bool MNModel::isMNCollateralMature(const QString& mnAlias)
return mn->collateralId && collateralTxAccepted.value(mn->collateralId->hash.GetHex());
}

bool MNModel::isLegacySystemObsolete()
{
return interfaces::g_tiertwo->isLegacySystemObsolete();
}

bool MNModel::isMNsNetworkSynced()
{
return g_tiertwo_sync_state.IsSynced();
Expand Down
6 changes: 4 additions & 2 deletions src/qt/pivx/mnmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class CMasternode;
class DMNView;
class WalletModel;

enum MNViewType : uint16_t
enum MNViewType : uint8_t
{
LEGACY = 0,
DMN_OWNER = (1 << 0),
Expand Down Expand Up @@ -88,7 +88,9 @@ class MNModel : public QAbstractTableModel
bool addMn(CMasternodeConfig::CMasternodeEntry* entry);
void updateMNList();


// Whether the MN legacy system is active or not
bool isLegacySystemObsolete();
// Whether the tier two synchronization completed or not
bool isMNsNetworkSynced();
// Returns the MN activeState field.
int getMNState(const QString& mnAlias);
Expand Down
2 changes: 1 addition & 1 deletion src/qt/pivx/mnrow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void MNRow::updateView(QString address,
const QString& label,
QString status,
bool wasCollateralAccepted,
uint16_t type)
uint8_t type)
{
ui->labelName->setText(label);
address = address.size() < 40 ? address : address.left(20) + "..." + address.right(20);
Expand Down
2 changes: 1 addition & 1 deletion src/qt/pivx/mnrow.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class MNRow : public QWidget
const QString& label,
QString status,
bool wasCollateralAccepted,
uint16_t type);
uint8_t type);

Q_SIGNALS:
void onMenuClicked();
Expand Down
4 changes: 4 additions & 0 deletions src/qt/pivx/mnselectiondialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ void MnSelectionDialog::updateView()
QFlags<Qt::ItemFlag> flgCheckbox = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable;
QFlags<Qt::ItemFlag> flgTristate = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsTristate;

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

0 comments on commit 9d03e3e

Please sign in to comment.