@@ -689,6 +689,35 @@ bool CBudgetManager::FillBlockPayee(CMutableTransaction& txNew, bool fProofOfSta
689689 return true ;
690690}
691691
692+ void CBudgetManager::SubmitVote (const uint256& nBudgetHash)
693+ {
694+ // function called only from initialized masternodes
695+ assert (fMasterNode && activeMasternode.vin != nullopt );
696+
697+ CPubKey pubKeyMasternode;
698+ CKey keyMasternode;
699+ if (!CMessageSigner::GetKeysFromSecret (strMasterNodePrivKey, keyMasternode, pubKeyMasternode)) {
700+ LogPrint (BCLog::MNBUDGET," %s: Error upon calling GetKeysFromSecret\n " , __func__);
701+ return ;
702+ }
703+
704+ CFinalizedBudgetVote vote (*(activeMasternode.vin ), nBudgetHash);
705+ if (!vote.Sign (keyMasternode, pubKeyMasternode)) {
706+ LogPrint (BCLog::MNBUDGET," %s: Failure to sign." , __func__);
707+ return ;
708+ }
709+
710+ std::string strError = " " ;
711+ if (!UpdateFinalizedBudget (vote, NULL , strError)) {
712+ LogPrintf (" %s: Error submitting vote - %s\n " , __func__, strError);
713+ return ;
714+ }
715+
716+ LogPrint (BCLog::MNBUDGET," %s: new finalized budget vote signed: %s\n " , __func__, vote.GetHash ().ToString ());
717+ AddSeenFinalizedBudgetVote (vote);
718+ vote.Relay ();
719+ }
720+
692721CFinalizedBudget* CBudgetManager::FindFinalizedBudget (const uint256& nHash)
693722{
694723 AssertLockHeld (cs_budgets);
@@ -1960,7 +1989,8 @@ void CFinalizedBudget::CheckAndVote()
19601989 }
19611990
19621991 LogPrint (BCLog::MNBUDGET," %s: Finalized Budget Matches! Submitting Vote.\n " , __func__);
1963- SubmitVote ();
1992+ // TODO: move CheckAndVote to budget manager
1993+ g_budgetman.SubmitVote (GetHash ());
19641994 }
19651995}
19661996
@@ -2208,37 +2238,6 @@ bool CFinalizedBudget::GetPayeeAndAmount(int64_t nBlockHeight, CScript& payee, C
22082238 return true ;
22092239}
22102240
2211- void CFinalizedBudget::SubmitVote ()
2212- {
2213- // function called only from initialized masternodes
2214- assert (fMasterNode && activeMasternode.vin != nullopt );
2215-
2216- std::string strError = " " ;
2217- CPubKey pubKeyMasternode;
2218- CKey keyMasternode;
2219-
2220- if (!CMessageSigner::GetKeysFromSecret (strMasterNodePrivKey, keyMasternode, pubKeyMasternode)) {
2221- LogPrint (BCLog::MNBUDGET," %s: Error upon calling GetKeysFromSecret\n " , __func__);
2222- return ;
2223- }
2224-
2225- CFinalizedBudgetVote vote (*(activeMasternode.vin ), GetHash ());
2226- if (!vote.Sign (keyMasternode, pubKeyMasternode)) {
2227- LogPrint (BCLog::MNBUDGET," %s: Failure to sign." , __func__);
2228- return ;
2229- }
2230-
2231- // !TODO: move to CBudgetManager
2232- if (g_budgetman.UpdateFinalizedBudget (vote, NULL , strError)) {
2233- LogPrint (BCLog::MNBUDGET," %s: new finalized budget vote - %s\n " , __func__, vote.GetHash ().ToString ());
2234-
2235- g_budgetman.AddSeenFinalizedBudgetVote (vote);
2236- vote.Relay ();
2237- } else {
2238- LogPrint (BCLog::MNBUDGET," %s: Error submitting vote - %s\n " , __func__, strError);
2239- }
2240- }
2241-
22422241// return broadcast serialization
22432242CDataStream CFinalizedBudget::GetBroadcast () const
22442243{
0 commit comments