Skip to content

Commit

Permalink
Merge pull request #13 from aurovine/testbranch
Browse files Browse the repository at this point in the history
Testbranch
  • Loading branch information
locohammerhead authored Feb 19, 2018
2 parents 515d52d + 224faf5 commit 9fc2aac
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 61 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
6 changes: 3 additions & 3 deletions share/seeds/generate-seeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ def main():
g.write('// AUTOGENERATED by contrib/devtools/generate-seeds.py\n\n')
g.write('// Each line contains a 16-byte IPv6 address and a port.\n')
g.write('// IPv4 as well as onion addresses are wrapped inside a IPv6 address accordingly.\n')
with open(os.path.join(indir,r'/home/balaji/AudioCoin/share/seeds/nodes_main.txt'),'r') as f:
process_nodes(g, f, 'pnSeed6_main', 25159)
with open(os.path.join(indir,'nodes_main.txt'),'r') as f:
- process_nodes(g, f, 'pnSeed6_main', 25159)
g.write('\n')
with open(os.path.join(indir,r'/home/balaji/AudioCoin/share/seeds/nodes_test.txt'),'r') as f:
with open(os.path.join(indir,'nodes_test.txt'),'r') as f:
process_nodes(g, f, 'pnSeed6_test', 25714)
g.write('#endif\n')

Expand Down
2 changes: 1 addition & 1 deletion src/clientversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it
#define CLIENT_VERSION_MAJOR 1
#define CLIENT_VERSION_MINOR 2
#define CLIENT_VERSION_REVISION 2
#define CLIENT_VERSION_REVISION 3
#define CLIENT_VERSION_BUILD 0

// Set to true for release, false for prerelease or test build
Expand Down
3 changes: 2 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2792,7 +2792,8 @@ string GetWarnings(string strFor)
{
nPriority = alert.nPriority;
strStatusBar = alert.strStatusBar;

if (nPriority > 1000)
strRPC = strStatusBar;
//Removed below lines from commit: revert: PPCoin: Enter safe mode with high priority alert
//https://github.com/bitcoin/bitcoin/commit/4a90ade35a289ad3bce43dada5b7ad6038def080
//if (nPriority > 1000)
Expand Down
7 changes: 2 additions & 5 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1003,9 +1003,9 @@ void BitcoinGUI::updateStakingIcon()

if (nLastCoinStakeSearchInterval && nWeight)
{
uint64_t nWeight = this->nWeight;
uint64_t nWeight = this->nWeight / COIN;
uint64_t nNetworkWeight = GetPoSKernelPS();
unsigned nEstimateTime = GetTargetSpacing(nBestHeight) * nNetworkWeight / nWeight;
double nEstimateTime = GetTargetSpacing(nBestHeight) * nNetworkWeight / nWeight;

QString text;
if (nEstimateTime < 60)
Expand All @@ -1025,9 +1025,6 @@ void BitcoinGUI::updateStakingIcon()
text = tr("%n day(s)", "", nEstimateTime/(60*60*24));
}

nWeight /= COIN;
nNetworkWeight /= COIN;

labelStakingIcon->setPixmap(QIcon(fUseBlackTheme ? ":/icons/black/staking_on" : ":/icons/staking_on").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
labelStakingIcon->setToolTip(tr("Staking.<br>Your weight is %1<br>Network weight is %2<br>Expected time to earn reward is %3").arg(nWeight).arg(nNetworkWeight).arg(text));
}
Expand Down
80 changes: 53 additions & 27 deletions src/rpcmining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,31 +85,31 @@ Value getmininginfo(const Array& params, bool fHelp)

uint64_t nWeight = 0;
if (pwalletMain)
nWeight = pwalletMain->GetStakeWeight();
nWeight = pwalletMain->GetStakeWeight() / COIN;

Object obj, diff, weight;
obj.push_back(Pair("blocks", (int)nBestHeight));
obj.push_back(Pair("currentblocksize",(uint64_t)nLastBlockSize));
obj.push_back(Pair("currentblocktx",(uint64_t)nLastBlockTx));

diff.push_back(Pair("proof-of-work", GetDifficulty()));
diff.push_back(Pair("proof-of-stake", GetDifficulty(GetLastBlockIndex(pindexBest, true))));
diff.push_back(Pair("search-interval", (int)nLastCoinStakeSearchInterval));
obj.push_back(Pair("difficulty", diff));

obj.push_back(Pair("blockvalue", (uint64_t)GetProofOfWorkReward(999999, 0)));
obj.push_back(Pair("netmhashps", GetPoWMHashPS()));
obj.push_back(Pair("netstakeweight", GetPoSKernelPS()));
obj.push_back(Pair("errors", GetWarnings("statusbar")));
obj.push_back(Pair("pooledtx", (uint64_t)mempool.size()));

weight.push_back(Pair("minimum", (uint64_t)nWeight));
weight.push_back(Pair("maximum", (uint64_t)0));
weight.push_back(Pair("combined", (uint64_t)nWeight));
obj.push_back(Pair("blocks", (int)nBestHeight));
obj.push_back(Pair("currentblocksize", (uint64_t)nLastBlockSize));
obj.push_back(Pair("currentblocktx", (uint64_t)nLastBlockTx));

diff.push_back(Pair("proof-of-work", GetDifficulty()));
diff.push_back(Pair("proof-of-stake", GetDifficulty(GetLastBlockIndex(pindexBest, true))));
diff.push_back(Pair("search-interval", (int)nLastCoinStakeSearchInterval));
obj.push_back(Pair("difficulty", diff));

obj.push_back(Pair("blockvalue", (uint64_t)GetProofOfWorkReward(999999, 0)));
obj.push_back(Pair("netmhashps", GetPoWMHashPS()));
obj.push_back(Pair("netstakeweight", (uint64_t)GetPoSKernelPS()));
obj.push_back(Pair("errors", GetWarnings("statusbar")));
obj.push_back(Pair("pooledtx", (uint64_t)mempool.size()));

weight.push_back(Pair("minimum", nWeight));
weight.push_back(Pair("maximum", (uint64_t)0));
weight.push_back(Pair("combined", nWeight));
obj.push_back(Pair("stakeweight", weight));

obj.push_back(Pair("stakeinterest", (uint64_t)COIN_YEAR_REWARD));
obj.push_back(Pair("testnet", TestNet()));
obj.push_back(Pair("stakeinterest", (uint64_t)COIN_YEAR_REWARD));
obj.push_back(Pair("testnet", TestNet()));
return obj;
}

Expand All @@ -120,15 +120,15 @@ Value getstakinginfo(const Array& params, bool fHelp)
"getstakinginfo\n"
"Returns an object containing staking-related information.");

uint64_t nWeight = 0;
double nWeight = 0;
if (pwalletMain)
nWeight = pwalletMain->GetStakeWeight();
nWeight = (double)pwalletMain->GetStakeWeight() / COIN;

uint64_t nNetworkWeight = GetPoSKernelPS();
double nNetworkWeight = GetPoSKernelPS();
bool staking = nLastCoinStakeSearchInterval && nWeight;
uint64_t nExpectedTime = staking ? (GetTargetSpacing(nBestHeight) * nNetworkWeight / nWeight) : 0;

Object obj;
Object obj, time;

obj.push_back(Pair("enabled", GetBoolArg("-staking", true)));
obj.push_back(Pair("staking", staking));
Expand All @@ -141,11 +141,37 @@ Value getstakinginfo(const Array& params, bool fHelp)
obj.push_back(Pair("difficulty", GetDifficulty(GetLastBlockIndex(pindexBest, true))));
obj.push_back(Pair("search-interval", (int)nLastCoinStakeSearchInterval));

obj.push_back(Pair("weight", (uint64_t)nWeight));
obj.push_back(Pair("netstakeweight", (uint64_t)nNetworkWeight));
obj.push_back(Pair("weight", nWeight));
obj.push_back(Pair("netstakeweight", nNetworkWeight));

obj.push_back(Pair("expectedtime", nExpectedTime));

if (staking)
{
string unit = "second(s)";

if (nExpectedTime >= 60 && nExpectedTime < (60 * 60))
{
nExpectedTime /= 60;
unit = "minute(s)";
}
else if (nExpectedTime < (24 * 60 * 60))
{
nExpectedTime /= (60 * 60);
unit = "hour(s)";
}
else
{
nExpectedTime /= (60 * 60 * 24);
unit = "day(s)";
}

time.push_back(Pair("value", nExpectedTime));
time.push_back(Pair("unit", unit));

obj.push_back(Pair("humanized_expectedtime", time));
}

return obj;
}

Expand Down
37 changes: 16 additions & 21 deletions src/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,7 @@ void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const

//Removed and added new line from commit https://github.com/bitcoin/bitcoin/commit/1cce0c22b02eb65635ee53d4fd62279e6dd68fbb
//void CWallet::AvailableCoinsForStaking(vector<COutput>& vCoins, unsigned int nSpendTime) const
void CWallet::AvailableCoinsForStaking(vector<COutput>& vCoins) const
void CWallet::AvailableCoinsForStaking(vector<COutput>& vCoins, unsigned int nSpendTime) const
{
vCoins.clear();

Expand Down Expand Up @@ -1362,12 +1362,11 @@ bool CWallet::SelectCoins(int64_t nTargetValue, unsigned int nSpendTime, set<pai
}

// Select some coins without random shuffle or best subset approximation
//bool CWallet::SelectCoinsForStaking(int64_t nTargetValue, unsigned int nSpendTime, set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet) const
bool CWallet::SelectCoinsForStaking(int64_t nTargetValue, set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet) const
bool CWallet::SelectCoinsForStaking(int64_t nTargetValue, unsigned int nSpendTime, set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet) const
{
vector<COutput> vCoins;
//AvailableCoinsForStaking(vCoins, nSpendTime);
AvailableCoinsForStaking(vCoins);
AvailableCoinsForStaking(vCoins, nSpendTime);
setCoinsRet.clear();
nValueRet = 0;

Expand Down Expand Up @@ -1430,7 +1429,6 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64_t> >& vecSend,
//added from commit https://github.com/bitcoin/bitcoin/commit/8e15d99955b59d496da0b45d1f0be645b71575e9
//wtxNew.nLockTime = std::max(0, nBestHeight - 10);

if (!IsInitialBlockDownload())
wtxNew.nLockTime = std::max(0, nBestHeight - 10);

// Secondly occasionally randomly pick a nLockTime even further back, so
Expand Down Expand Up @@ -1573,21 +1571,21 @@ uint64_t CWallet::GetStakeWeight() const
int64_t nValueIn = 0;

//if (!SelectCoinsForStaking(nBalance - nReserveBalance, GetTime(), setCoins, nValueIn))
if (!SelectCoinsForStaking(nBalance - nReserveBalance, setCoins, nValueIn))
if (!SelectCoinsForStaking(nBalance - nReserveBalance, GetTime(), setCoins, nValueIn))
return 0;

if (setCoins.empty())
return 0;

uint64_t nWeight = 0;

//int64_t nCurrentTime = GetTime();
//CTxDB txdb("r");
int64_t nCurrentTime = GetTime();
CTxDB txdb("r");

LOCK2(cs_main, cs_wallet);
BOOST_FOREACH(PAIRTYPE(const CWalletTx*, unsigned int) pcoin, setCoins)
{
/*

if (IsProtocolV3(nCurrentTime))
{
if (pcoin.first->GetDepthInMainChain() >= nStakeMinConfirmations)
Expand All @@ -1602,9 +1600,7 @@ uint64_t CWallet::GetStakeWeight() const
if (nCurrentTime - pcoin.first->nTime > nStakeMinAge)
nWeight += pcoin.first->vout[pcoin.second].nValue;
}
*/
if (pcoin.first->GetDepthInMainChain() >= nStakeMinConfirmations)
nWeight += pcoin.first->vout[pcoin.second].nValue;

}

return nWeight;
Expand Down Expand Up @@ -1636,8 +1632,8 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int
int64_t nValueIn = 0;

// Select coins with suitable depth
//if (!SelectCoinsForStaking(nBalance - nReserveBalance, txNew.nTime, setCoins, nValueIn))
if (!SelectCoinsForStaking(nBalance - nReserveBalance, setCoins, nValueIn))
if (!SelectCoinsForStaking(nBalance - nReserveBalance, txNew.nTime, setCoins, nValueIn))

return false;

if (setCoins.empty())
Expand Down Expand Up @@ -1730,10 +1726,10 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int
if (txNew.vout.size() == 2 && ((pcoin.first->vout[pcoin.second].scriptPubKey == scriptPubKeyKernel || pcoin.first->vout[pcoin.second].scriptPubKey == txNew.vout[1].scriptPubKey))
&& pcoin.first->GetHash() != txNew.vin[0].prevout.hash)
{
//int64_t nTimeWeight = GetWeight((int64_t)pcoin.first->nTime, (int64_t)txNew.nTime);
int64_t nTimeWeight = GetWeight((int64_t)pcoin.first->nTime, (int64_t)txNew.nTime);

// Stop adding more inputs if already too many inputs
if (txNew.vin.size() >= 10)
if (txNew.vin.size() >= 100)
break;
// Stop adding inputs if reached reserve limit
if (nCredit + pcoin.first->vout[pcoin.second].nValue > nBalance - nReserveBalance)
Expand All @@ -1742,15 +1738,15 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int
if (pcoin.first->vout[pcoin.second].nValue >= GetStakeCombineThreshold())
continue;
// Do not add input that is still too young
/*if (IsProtocolV3(txNew.nTime))
if (IsProtocolV3(txNew.nTime))
{
// properly handled by selection function
}
else
{
if (nTimeWeight < nStakeMinAge)
continue;
}*/
}

txNew.vin.push_back(CTxIn(pcoin.first->GetHash(), pcoin.second));
nCredit += pcoin.first->vout[pcoin.second].nValue;
Expand All @@ -1760,15 +1756,14 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int

// Calculate reward
{
/*

uint64_t nCoinAge;
CTxDB txdb("r");
if (!txNew.GetCoinAge(txdb, pindexPrev, nCoinAge))
return error("CreateCoinStake : failed to calculate coin age");

int64_t nReward = GetProofOfStakeReward(pindexPrev, nCoinAge, nFees);
*/
int64_t nReward = GetProofOfStakeReward(pindexPrev, 0, nFees);

if (nReward <= 0)
return false;

Expand Down
5 changes: 2 additions & 3 deletions src/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class CWallet : public CCryptoKeyStore, public CWalletInterface
{
private:
//bool SelectCoinsForStaking(int64_t nTargetValue, unsigned int nSpendTime, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet) const;
bool SelectCoinsForStaking(int64_t nTargetValue, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet) const;
bool SelectCoinsForStaking(int64_t nTargetValue, unsigned int nSpendTime, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet) const;
bool SelectCoins(int64_t nTargetValue, unsigned int nSpendTime, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet, const CCoinControl *coinControl=NULL) const;

CWalletDB *pwalletdbEncryption;
Expand Down Expand Up @@ -143,8 +143,7 @@ class CWallet : public CCryptoKeyStore, public CWalletInterface
// check whether we are allowed to upgrade (or already support) to the named feature
bool CanSupportFeature(enum WalletFeature wf) { AssertLockHeld(cs_wallet); return nWalletMaxVersion >= wf; }

//void AvailableCoinsForStaking(std::vector<COutput>& vCoins, unsigned int nSpendTime) const;
void AvailableCoinsForStaking(std::vector<COutput>& vCoins) const;
void AvailableCoinsForStaking(std::vector<COutput>& vCoins, unsigned int nSpendTime) const;
void AvailableCoins(std::vector<COutput>& vCoins, bool fOnlyConfirmed=true, const CCoinControl *coinControl=NULL) const;
bool SelectCoinsMinConf(int64_t nTargetValue, unsigned int nSpendTime, int nConfMine, int nConfTheirs, std::vector<COutput> vCoins, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet) const;

Expand Down

0 comments on commit 9fc2aac

Please sign in to comment.