Skip to content

Commit fd8d844

Browse files
committed
GUI: governance, IBD check before opening the proposal creation wizard.
Github-Pull: #2670 Rebased-From: 155ad6d
1 parent 33f5dd8 commit fd8d844

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
@@ -143,7 +143,23 @@ void GovernanceWidget::onVoteForPropClicked(const ProposalInfo& proposalInfo)
143143

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

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

0 commit comments

Comments
 (0)