mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 20:42:59 +01:00
masternode payments work, setup fork for block payment halving
This commit is contained in:
parent
1ed5e02ac7
commit
f4e4fb6a59
@ -9,7 +9,7 @@
|
||||
#define CLIENT_VERSION_MAJOR 0
|
||||
#define CLIENT_VERSION_MINOR 10
|
||||
#define CLIENT_VERSION_REVISION 15
|
||||
#define CLIENT_VERSION_BUILD 1
|
||||
#define CLIENT_VERSION_BUILD 2
|
||||
|
||||
// Set to true for release, false for prerelease or test build
|
||||
#define CLIENT_VERSION_IS_RELEASE true
|
||||
|
@ -1019,7 +1019,7 @@ bool CDarkSendPool::GetBlockHash(uint256& hash, int nBlockHeight)
|
||||
|
||||
if (BlockLastSolved == NULL || BlockLastSolved->nHeight == 0) { return false; }
|
||||
|
||||
printf(" nBlockHeight2 %"PRI64u" %"PRI64u"\n", nBlockHeight, pindexBest->nHeight+1);
|
||||
//printf(" nBlockHeight2 %"PRI64u" %"PRI64u"\n", nBlockHeight, pindexBest->nHeight+1);
|
||||
|
||||
for (unsigned int i = 1; BlockReading && BlockReading->nHeight > 0; i++) {
|
||||
if(BlockReading->nHeight == nBlockHeight) {
|
||||
@ -1188,23 +1188,17 @@ int CDarkSendPool::GetCurrentMasterNode(int mod, int64 nBlockHeight)
|
||||
return winner;
|
||||
}
|
||||
|
||||
uint256 CMasternodePayments::CalculateScore(int64 nBlockHeight, CTxIn vin)
|
||||
uint64 CMasternodePayments::CalculateScore(uint256 blockHash, CTxIn& vin)
|
||||
{
|
||||
|
||||
//printf(" nBlockHeight %"PRI64u" -- %"PRI64u"\n", nBlockHeight, nBlockHeight-200);
|
||||
if(pindexBest == NULL) return 0;
|
||||
|
||||
uint256 n1 = 0;
|
||||
if(!darkSendPool.GetBlockHash(n1, nBlockHeight-MASTERNODE_MIN_CONFIRMATIONS-5)) return 0;
|
||||
|
||||
uint256 n2 = Hash(BEGIN(n1), END(n1));
|
||||
uint256 n3 = Hash(BEGIN(vin.prevout.hash), END(vin.prevout.hash));
|
||||
uint256 n1 = blockHash;
|
||||
uint256 n2 = Hash9(BEGIN(n1), END(n1));
|
||||
uint256 n3 = Hash9(BEGIN(vin.prevout.hash), END(vin.prevout.hash));
|
||||
uint256 n4 = n3 > n2 ? (n3 - n2) : (n2 - n3);
|
||||
|
||||
//printf(" -- CMasternodePayments CalculateScore() n2 = %"PRI64u" \n", n2.Get64());
|
||||
//printf(" -- CMasternodePayments CalculateScore() n3 = %"PRI64u" \n", n3.Get64());
|
||||
|
||||
return n4;
|
||||
return n4.Get64();
|
||||
}
|
||||
|
||||
bool CMasternodePayments::GetBlockPayee(int nBlockHeight, CScript& payee)
|
||||
@ -1244,10 +1238,14 @@ bool CMasternodePayments::GetWinningMasternode(int nBlockHeight, CTxIn& vinOut)
|
||||
|
||||
bool CMasternodePayments::AddWinningMasternode(int nBlockHeight, CTxIn vinIn)
|
||||
{
|
||||
uint256 score = CalculateScore(nBlockHeight, vinIn);
|
||||
if(pindexBest == NULL) return false;
|
||||
uint256 blockHash = 0;
|
||||
if(!darkSendPool.GetBlockHash(blockHash, nBlockHeight-MASTERNODE_MIN_CONFIRMATIONS-5)) return false;
|
||||
|
||||
uint64 score = CalculateScore(blockHash, vinIn);
|
||||
|
||||
bool foundBlock = false;
|
||||
BOOST_FOREACH(PAIRTYPE(int, uint256)& item, vWinningScores){
|
||||
BOOST_FOREACH(PAIRTYPE(int, uint64)& item, vWinningScores){
|
||||
if(item.first == nBlockHeight) {
|
||||
foundBlock = true;
|
||||
if(item.second < score){
|
||||
@ -1274,11 +1272,14 @@ bool CMasternodePayments::AddWinningMasternode(int nBlockHeight, CTxIn vinIn)
|
||||
|
||||
bool CMasternodePayments::ProcessMyMasternode(int nBlockHeight, CTxIn vinIn)
|
||||
{
|
||||
uint256 winner = 0;
|
||||
uint64 winner = 0;
|
||||
bool fWeWon = false;
|
||||
|
||||
uint256 blockHash = 0;
|
||||
if(!darkSendPool.GetBlockHash(blockHash, nBlockHeight-MASTERNODE_MIN_CONFIRMATIONS-5)) return false;
|
||||
|
||||
BOOST_FOREACH(CMasterNode& mn, darkSendMasterNodes) {
|
||||
uint256 score = CalculateScore(nBlockHeight, mn.vin);
|
||||
uint64 score = CalculateScore(blockHash, mn.vin);
|
||||
if(score > winner){
|
||||
if(mn.vin == vinIn) {
|
||||
fWeWon = true;
|
||||
|
@ -100,7 +100,7 @@ public:
|
||||
class CMasternodePayments
|
||||
{
|
||||
private:
|
||||
std::vector<std::pair<int, uint256> > vWinningScores;
|
||||
std::vector<std::pair<int, uint64> > vWinningScores;
|
||||
std::vector<std::pair<int, CTxIn> > vWinningVin;
|
||||
int nSyncedFromPeer;
|
||||
|
||||
@ -110,7 +110,8 @@ public:
|
||||
// to the blockHeight. The further away they are the better, the furthest will win the election
|
||||
// and get paid this block
|
||||
//
|
||||
uint256 CalculateScore(int64 nBlockHeight, CTxIn vin);
|
||||
|
||||
uint64 CalculateScore(uint256 blockHash, CTxIn& vin);
|
||||
bool GetWinningMasternode(int nBlockHeight, CTxIn& vinOut);
|
||||
bool AddWinningMasternode(int nBlockHeight, CTxIn vinIn);
|
||||
bool ProcessMyMasternode(int nBlockHeight, CTxIn vinIn);
|
||||
|
@ -1356,8 +1356,12 @@ int64 static GetBlockValue(int nBits, int nHeight, int64 nFees)
|
||||
// LogPrintf("height %u diff %4.2f reward %i \n", nHeight, dDiff, nSubsidy);
|
||||
nSubsidy *= COIN;
|
||||
|
||||
// yearly decline of production by 7% per year, projected 21.3M coins max by year 2050.
|
||||
for(int i = 210240; i <= nHeight; i += 210240) nSubsidy *= 0.93;
|
||||
if(fTestNet){
|
||||
for(int i = 46200; i <= nHeight; i += 210240) nSubsidy -= nSubsidy/14;
|
||||
} else {
|
||||
// yearly decline of production by 7.1% per year, projected 21.3M coins max by year 2050.
|
||||
for(int i = 210240; i <= nHeight; i += 210240) nSubsidy -= nSubsidy/14;
|
||||
}
|
||||
|
||||
return nSubsidy + nFees;
|
||||
}
|
||||
@ -1394,7 +1398,6 @@ int64 GetMasternodePayment(int nHeight, int64 blockValue)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static const int64 nTargetTimespan = 24 * 60 * 60; // DarkCoin: 1 day
|
||||
static const int64 nTargetSpacing = 2.5 * 60; // DarkCoin: 2.5 minutes
|
||||
static const int64 nInterval = nTargetTimespan / nTargetSpacing; // 576
|
||||
|
@ -43,10 +43,10 @@
|
||||
#define MASTERNODE_SYNC_IN_PROCESS 8
|
||||
|
||||
#define MASTERNODE_MIN_CONFIRMATIONS 200
|
||||
#define MASTERNODE_MIN_SECONDS 5*1
|
||||
#define MASTERNODE_PING_SECONDS 30*1
|
||||
#define MASTERNODE_EXPIRATION_SECONDS 35*1
|
||||
#define MASTERNODE_REMOVAL_SECONDS 35.5*1
|
||||
#define MASTERNODE_MIN_SECONDS 5*60
|
||||
#define MASTERNODE_PING_SECONDS 20*60
|
||||
#define MASTERNODE_EXPIRATION_SECONDS 65*60
|
||||
#define MASTERNODE_REMOVAL_SECONDS 70*60
|
||||
|
||||
// status update message constants
|
||||
#define MASTERNODE_ACCEPTED 1
|
||||
|
@ -121,7 +121,7 @@ Value masternode(const Array& params, bool fHelp)
|
||||
}
|
||||
|
||||
if (strCommand == "list")
|
||||
{
|
||||
{
|
||||
std::string strCommand = "active";
|
||||
|
||||
if (params.size() == 2){
|
||||
@ -184,7 +184,7 @@ Value masternode(const Array& params, bool fHelp)
|
||||
darkSendPool.RegisterAsMasterNode(false);
|
||||
pwalletMain->Lock();
|
||||
|
||||
if(darkSendPool.isCapableMasterNode == MASTERNODE_INPUT_TOO_NEW) return "masternode input must have at least 6 confirmations";
|
||||
if(darkSendPool.isCapableMasterNode == MASTERNODE_INPUT_TOO_NEW) return "masternode input must have at least 200 confirmations";
|
||||
if(darkSendPool.isCapableMasterNode == MASTERNODE_STOPPED) return "masternode is stopped";
|
||||
if(darkSendPool.isCapableMasterNode == MASTERNODE_IS_CAPABLE) return "successfully started masternode";
|
||||
if(darkSendPool.masternodePortOpen == MASTERNODE_PORT_NOT_OPEN) return "inbound port is not open. Please open it and try again. (19999 for testnet and 9999 for mainnet)";
|
||||
|
@ -719,7 +719,7 @@ Value sendmany(const Array& params, bool fHelp)
|
||||
string strFailReason;
|
||||
|
||||
CCoinControl *coinControl=NULL;
|
||||
AvailableCoinsType act = ONLY_DENOMINATED;
|
||||
AvailableCoinsType act = ALL_COINS;
|
||||
|
||||
bool fCreated = pwalletMain->CreateTransaction(vecSend, wtx, keyChange, nFeeRequired, strFailReason, coinControl, act);
|
||||
if (!fCreated)
|
||||
|
Loading…
Reference in New Issue
Block a user