mirror of
https://github.com/dashpay/dash.git
synced 2024-12-28 13:32:47 +01:00
Various fixes
- Proposal submitting now works properly - Syncing proposals now works properly - Finalized budgets are now created correctly
This commit is contained in:
parent
0a02fa00bb
commit
0b3ef3c9fe
@ -2360,6 +2360,7 @@ void ThreadCheckDarkSendPool()
|
|||||||
if(c % 5 == 0 && RequestedMasternodeAssets <= 5){
|
if(c % 5 == 0 && RequestedMasternodeAssets <= 5){
|
||||||
bool fIsInitialDownload = IsInitialBlockDownload();
|
bool fIsInitialDownload = IsInitialBlockDownload();
|
||||||
if(!fIsInitialDownload) {
|
if(!fIsInitialDownload) {
|
||||||
|
|
||||||
CBlockIndex* pindexPrev = chainActive.Tip();
|
CBlockIndex* pindexPrev = chainActive.Tip();
|
||||||
if(pindexPrev != NULL) {
|
if(pindexPrev != NULL) {
|
||||||
if(pindexPrev->nTime > GetAdjustedTime() - 60)
|
if(pindexPrev->nTime > GetAdjustedTime() - 60)
|
||||||
@ -2368,11 +2369,13 @@ void ThreadCheckDarkSendPool()
|
|||||||
LOCK(cs_vNodes);
|
LOCK(cs_vNodes);
|
||||||
BOOST_FOREACH(CNode* pnode, vNodes)
|
BOOST_FOREACH(CNode* pnode, vNodes)
|
||||||
{
|
{
|
||||||
if (pnode->nVersion >= MIN_POOL_PEER_PROTO_VERSION) {
|
if (pnode->nVersion >= MIN_POOL_PEER_PROTO_VERSION) {
|
||||||
|
bool IsLocal = pnode->addr.IsRFC1918() || pnode->addr.IsLocal();
|
||||||
//keep track of who we've asked for the list
|
if(!IsLocal) {
|
||||||
if(pnode->HasFulfilledRequest("mnsync")) continue;
|
//keep track of who we've asked for the list
|
||||||
pnode->FulfilledRequest("mnsync");
|
if(pnode->HasFulfilledRequest("mnsync")) continue;
|
||||||
|
pnode->FulfilledRequest("mnsync");
|
||||||
|
}
|
||||||
|
|
||||||
//request full mn list only if Masternodes.dat was updated quite a long time ago
|
//request full mn list only if Masternodes.dat was updated quite a long time ago
|
||||||
|
|
||||||
|
@ -126,6 +126,7 @@ void CBudgetManager::SubmitFinalBudget()
|
|||||||
CBlockIndex* pindexPrev = chainActive.Tip();
|
CBlockIndex* pindexPrev = chainActive.Tip();
|
||||||
if(!pindexPrev) return;
|
if(!pindexPrev) return;
|
||||||
|
|
||||||
|
|
||||||
int nBlockStart = pindexPrev->nHeight-(pindexPrev->nHeight % GetBudgetPaymentCycleBlocks())+GetBudgetPaymentCycleBlocks();
|
int nBlockStart = pindexPrev->nHeight-(pindexPrev->nHeight % GetBudgetPaymentCycleBlocks())+GetBudgetPaymentCycleBlocks();
|
||||||
if(nSubmittedFinalBudget >= nBlockStart) return;
|
if(nSubmittedFinalBudget >= nBlockStart) return;
|
||||||
if(nBlockStart - pindexPrev->nHeight > 100) return;
|
if(nBlockStart - pindexPrev->nHeight > 100) return;
|
||||||
@ -155,26 +156,34 @@ void CBudgetManager::SubmitFinalBudget()
|
|||||||
|
|
||||||
if(!darkSendSigner.SetKey(strMasterNodePrivKey, errorMessage, keyMasternode, pubKeyMasternode)){
|
if(!darkSendSigner.SetKey(strMasterNodePrivKey, errorMessage, keyMasternode, pubKeyMasternode)){
|
||||||
LogPrintf("SubmitFinalBudget - Error upon calling SetKey\n");
|
LogPrintf("SubmitFinalBudget - Error upon calling SetKey\n");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CFinalizedBudgetBroadcast tempBudget(strBudgetName, nBlockStart, vecTxBudgetPayments, 0);
|
||||||
|
|
||||||
//create fee tx
|
//create fee tx
|
||||||
uint256 hash = 0;
|
CTransaction tx;
|
||||||
|
if(!pwalletMain->GetBudgetSystemCollateralTX(tx, tempBudget.GetHash(), true)){
|
||||||
|
LogPrintf("SubmitFinalBudget - Can't make collateral transaction\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//create the proposal incase we're the first to make it
|
//create the proposal incase we're the first to make it
|
||||||
CFinalizedBudgetBroadcast finalizedBudgetBroadcast(strBudgetName, nBlockStart, vecTxBudgetPayments, hash);
|
CFinalizedBudgetBroadcast finalizedBudgetBroadcast(strBudgetName, nBlockStart, vecTxBudgetPayments, tx.GetHash());
|
||||||
|
|
||||||
if(!finalizedBudgetBroadcast.IsValid()){
|
if(!finalizedBudgetBroadcast.IsValid()){
|
||||||
LogPrintf("SubmitFinalBudget - Invalid finalized budget broadcast (are all the hashes correct?)\n");
|
LogPrintf("SubmitFinalBudget - Invalid finalized budget broadcast (are all the hashes correct?)\n");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mapSeenFinalizedBudgets.insert(make_pair(finalizedBudgetBroadcast.GetHash(), finalizedBudgetBroadcast));
|
mapSeenFinalizedBudgets.insert(make_pair(finalizedBudgetBroadcast.GetHash(), finalizedBudgetBroadcast));
|
||||||
finalizedBudgetBroadcast.Relay();
|
finalizedBudgetBroadcast.Relay();
|
||||||
budget.AddFinalizedBudget(finalizedBudgetBroadcast);
|
budget.AddFinalizedBudget(finalizedBudgetBroadcast);
|
||||||
|
|
||||||
|
|
||||||
CFinalizedBudgetVote vote(activeMasternode.vin, finalizedBudgetBroadcast.GetHash());
|
CFinalizedBudgetVote vote(activeMasternode.vin, finalizedBudgetBroadcast.GetHash());
|
||||||
if(!vote.Sign(keyMasternode, pubKeyMasternode)){
|
if(!vote.Sign(keyMasternode, pubKeyMasternode)){
|
||||||
LogPrintf("SubmitFinalBudget - Failure to sign.\n");
|
LogPrintf("SubmitFinalBudget - Failure to sign.\n");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mapSeenFinalizedBudgetVotes.insert(make_pair(vote.GetHash(), vote));
|
mapSeenFinalizedBudgetVotes.insert(make_pair(vote.GetHash(), vote));
|
||||||
@ -696,19 +705,19 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
|
|||||||
LOCK(cs_budget);
|
LOCK(cs_budget);
|
||||||
|
|
||||||
if (strCommand == "mnvs") { //Masternode vote sync
|
if (strCommand == "mnvs") { //Masternode vote sync
|
||||||
|
uint256 nProp;
|
||||||
|
vRecv >> nProp;
|
||||||
|
|
||||||
bool IsLocal = pfrom->addr.IsRFC1918() || pfrom->addr.IsLocal();
|
bool IsLocal = pfrom->addr.IsRFC1918() || pfrom->addr.IsLocal();
|
||||||
if(!IsLocal){
|
if(!IsLocal && nProp == 0){
|
||||||
if(pfrom->HasFulfilledRequest("mnvs")) {
|
if(pfrom->HasFulfilledRequest("mnvs")) {
|
||||||
LogPrintf("mnvs - peer already asked me for the list\n");
|
LogPrintf("mnvs - peer already asked me for the list\n");
|
||||||
Misbehaving(pfrom->GetId(), 20);
|
Misbehaving(pfrom->GetId(), 20);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
pfrom->FulfilledRequest("mnvs");
|
||||||
}
|
}
|
||||||
|
|
||||||
uint256 nProp;
|
|
||||||
vRecv >> nProp;
|
|
||||||
|
|
||||||
pfrom->FulfilledRequest("mnvs");
|
|
||||||
budget.Sync(pfrom, nProp);
|
budget.Sync(pfrom, nProp);
|
||||||
LogPrintf("mnvs - Sent Masternode votes to %s\n", pfrom->addr.ToString());
|
LogPrintf("mnvs - Sent Masternode votes to %s\n", pfrom->addr.ToString());
|
||||||
}
|
}
|
||||||
@ -735,8 +744,6 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//delete if it exists and insert the new object
|
|
||||||
if(mapSeenMasternodeBudgetProposals.count(budgetProposalBroadcast.GetHash())) mapSeenMasternodeBudgetProposals.erase(budgetProposalBroadcast.GetHash());
|
|
||||||
mapSeenMasternodeBudgetProposals.insert(make_pair(budgetProposalBroadcast.GetHash(), budgetProposalBroadcast));
|
mapSeenMasternodeBudgetProposals.insert(make_pair(budgetProposalBroadcast.GetHash(), budgetProposalBroadcast));
|
||||||
|
|
||||||
CBudgetProposal budgetProposal(budgetProposalBroadcast);
|
CBudgetProposal budgetProposal(budgetProposalBroadcast);
|
||||||
@ -797,8 +804,6 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//delete if it exists and insert the new object
|
|
||||||
if(mapSeenFinalizedBudgets.count(finalizedBudgetBroadcast.GetHash())) mapSeenFinalizedBudgets.erase(finalizedBudgetBroadcast.GetHash());
|
|
||||||
mapSeenFinalizedBudgets.insert(make_pair(finalizedBudgetBroadcast.GetHash(), finalizedBudgetBroadcast));
|
mapSeenFinalizedBudgets.insert(make_pair(finalizedBudgetBroadcast.GetHash(), finalizedBudgetBroadcast));
|
||||||
|
|
||||||
CFinalizedBudget finalizedBudget(finalizedBudgetBroadcast);
|
CFinalizedBudget finalizedBudget(finalizedBudgetBroadcast);
|
||||||
@ -1398,7 +1403,7 @@ bool CFinalizedBudget::IsValid()
|
|||||||
if(vecProposals.size() > 100) return false;
|
if(vecProposals.size() > 100) return false;
|
||||||
if(strBudgetName == "") return false;
|
if(strBudgetName == "") return false;
|
||||||
if(nBlockStart == 0) return false;
|
if(nBlockStart == 0) return false;
|
||||||
|
if(nFeeTXHash == 0) return false;
|
||||||
|
|
||||||
//can only pay out 10% of the possible coins (min value of coins)
|
//can only pay out 10% of the possible coins (min value of coins)
|
||||||
if(GetTotalPayout() > budget.GetTotalBudget(nBlockStart)) return false;
|
if(GetTotalPayout() > budget.GetTotalBudget(nBlockStart)) return false;
|
||||||
|
@ -166,10 +166,13 @@ void CMasternodePayments::ProcessMessageMasternodePayments(CNode* pfrom, std::st
|
|||||||
if (strCommand == "mnget") { //Masternode Payments Request Sync
|
if (strCommand == "mnget") { //Masternode Payments Request Sync
|
||||||
if(fLiteMode) return; //disable all Darksend/Masternode related functionality
|
if(fLiteMode) return; //disable all Darksend/Masternode related functionality
|
||||||
|
|
||||||
if(pfrom->HasFulfilledRequest("mnget")) {
|
bool IsLocal = pfrom->addr.IsRFC1918() || pfrom->addr.IsLocal();
|
||||||
LogPrintf("mnget - peer already asked me for the list\n");
|
if(!IsLocal){
|
||||||
Misbehaving(pfrom->GetId(), 20);
|
if(pfrom->HasFulfilledRequest("mnget")) {
|
||||||
return;
|
LogPrintf("mnget - peer already asked me for the list\n");
|
||||||
|
Misbehaving(pfrom->GetId(), 20);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pfrom->FulfilledRequest("mnget");
|
pfrom->FulfilledRequest("mnget");
|
||||||
|
@ -198,6 +198,7 @@ Value mnbudget(const Array& params, bool fHelp)
|
|||||||
|
|
||||||
mapSeenMasternodeBudgetProposals.insert(make_pair(budgetProposalBroadcast.GetHash(), budgetProposalBroadcast));
|
mapSeenMasternodeBudgetProposals.insert(make_pair(budgetProposalBroadcast.GetHash(), budgetProposalBroadcast));
|
||||||
budgetProposalBroadcast.Relay();
|
budgetProposalBroadcast.Relay();
|
||||||
|
budget.AddProposal(budgetProposalBroadcast);
|
||||||
|
|
||||||
return budgetProposalBroadcast.GetHash().ToString().c_str();
|
return budgetProposalBroadcast.GetHash().ToString().c_str();
|
||||||
|
|
||||||
@ -255,6 +256,7 @@ Value mnbudget(const Array& params, bool fHelp)
|
|||||||
|
|
||||||
mapSeenMasternodeBudgetVotes.insert(make_pair(vote.GetHash(), vote));
|
mapSeenMasternodeBudgetVotes.insert(make_pair(vote.GetHash(), vote));
|
||||||
vote.Relay();
|
vote.Relay();
|
||||||
|
budget.UpdateProposal(vote, NULL);
|
||||||
|
|
||||||
success++;
|
success++;
|
||||||
}
|
}
|
||||||
|
@ -1980,6 +1980,16 @@ bool CWallet::CreateCollateralTransaction(CMutableTransaction& txCollateral, std
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CWallet::GetBudgetSystemCollateralTX(CTransaction& tx, uint256 hash, bool useIX)
|
||||||
|
{
|
||||||
|
CWalletTx wtx;
|
||||||
|
if(GetBudgetSystemCollateralTX(wtx, hash, useIX)){
|
||||||
|
tx = (CTransaction)wtx;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool CWallet::GetBudgetSystemCollateralTX(CWalletTx& tx, uint256 hash, bool useIX)
|
bool CWallet::GetBudgetSystemCollateralTX(CWalletTx& tx, uint256 hash, bool useIX)
|
||||||
{
|
{
|
||||||
// make our change address
|
// make our change address
|
||||||
|
@ -345,6 +345,7 @@ public:
|
|||||||
|
|
||||||
std::set<CTxDestination> GetAccountAddresses(std::string strAccount) const;
|
std::set<CTxDestination> GetAccountAddresses(std::string strAccount) const;
|
||||||
|
|
||||||
|
bool GetBudgetSystemCollateralTX(CTransaction& tx, uint256 hash, bool useIX);
|
||||||
bool GetBudgetSystemCollateralTX(CWalletTx& tx, uint256 hash, bool useIX);
|
bool GetBudgetSystemCollateralTX(CWalletTx& tx, uint256 hash, bool useIX);
|
||||||
|
|
||||||
bool IsDenominated(const CTxIn &txin) const;
|
bool IsDenominated(const CTxIn &txin) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user