Skip to content

Commit 155ad6d

Browse files
committed
GUI: governance, IBD check before opening the proposal creation wizard.
1 parent 97728e5 commit 155ad6d

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/qt/pivx/governancewidget.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,23 @@ void GovernanceWidget::onVoteForPropClicked(const ProposalInfo& proposalInfo)
142142

143143
void GovernanceWidget::onCreatePropClicked()
144144
{
145-
if (!walletModel || !governanceModel) return;
145+
if (!walletModel || !governanceModel || !clientModel) return;
146+
147+
if (!governanceModel->isTierTwoSync()) {
148+
inform(tr("Please wait until the node is fully synced"));
149+
return;
150+
}
151+
152+
// Do not allow proposals submission 1440 blocks away (1 day) from the next superblock
153+
// The budget finalization could have been submitted and the user would never know it, losing the first superblock.
154+
// future: customizable future superblock height selection (for now, we are automatically using the next superblock).
155+
const int chainHeight = clientModel->getLastBlockProcessedHeight();
156+
const int nextSuperblock = governanceModel->getNextSuperblockHeight();
157+
const int acceptedRange = (walletModel->isTestNetwork() || walletModel->isRegTestNetwork()) ? 10 : 1440;
158+
if (nextSuperblock - acceptedRange < chainHeight) {
159+
inform(tr("Cannot create proposal, superblock is too close. Need to wait %1 blocks").arg(nextSuperblock - chainHeight));
160+
return;
161+
}
146162

147163
auto ptrUnlockedContext = std::make_unique<WalletModel::UnlockContext>(walletModel->requestUnlock());
148164
if (!ptrUnlockedContext->isValid()) {

0 commit comments

Comments
 (0)