Skip to content

Commit

Permalink
2.0.1.0
Browse files Browse the repository at this point in the history
Added SplitBlock to GUI. @presstab Hyperstake
Increaed default splitthreshold and combinethreshold, plus updated Max
for each. This will work in startup and config switchs up to 2500/5000.
And further increases in gui.
Changed max percentage for Stake For Charity to 100%
Renamed SetStakeMinAge to GetStakeMinAge
Renamed SetTargetSpacing to GetTargetSpacing
Created stub function for GetModiferInterval. Will be used to fork and
allow for 1 day min stake period.
Fixed CoinControl Weight to correct show at 8.8 days until fork fixes
it.
Fixed Stake Esimate in GUI.
Fixed Fee Esitmate when using CoinControl.
Bumped version to 2.0.1.0
  • Loading branch information
Tranz5 committed Oct 1, 2017
1 parent 1ea43c6 commit b3bff70
Show file tree
Hide file tree
Showing 23 changed files with 264 additions and 87 deletions.
2 changes: 1 addition & 1 deletion HoboNickels-qt.pro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
TEMPLATE = app
TARGET = HoboNickels-qt
VERSION = 2.0.0.0
VERSION = 2.0.1.0
QT += core gui network
INCLUDEPATH += src src/json src/qt
DEFINES += QT_GUI BOOST_THREAD_USE_LIB BOOST_SPIRIT_THREADSAFE BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN __NO_SYSTEM_INCLUDES
Expand Down
2 changes: 1 addition & 1 deletion src/checkpoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ namespace Checkpoints
assert(mapBlockIndex.count(hashSyncCheckpoint));
const CBlockIndex* pindexSync = mapBlockIndex[hashSyncCheckpoint];
return (nBestHeight >= pindexSync->nHeight + nCoinbaseMaturity ||
pindexSync->GetBlockTime() + SetStakeMinAge() < GetAdjustedTime());
pindexSync->GetBlockTime() + GetStakeMinAge() < GetAdjustedTime());
}
}

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 2
#define CLIENT_VERSION_MINOR 0
#define CLIENT_VERSION_REVISION 0
#define CLIENT_VERSION_REVISION 1
#define CLIENT_VERSION_BUILD 0

// Set to true for release, false for prerelease or test build
Expand Down
4 changes: 2 additions & 2 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,8 @@ std::string HelpMessage()
strUsage += " -keypool=<n> " + _("Set key pool size to <n> (default: 100)") + "\n";
strUsage += " -rescan " + _("Rescan the block chain for missing wallet transactions") + "\n";
strUsage += " -zapwallettxes " + _("Clear list of wallet transactions (diagnostic tool; implies -rescan)") + "\n";
strUsage += " -splitthreshold=<n> " + _("Set stake split threshold within range (default 5),(max 100))") + "\n";
strUsage += " -combinethreshold=<n> " + _("Set stake combine threshold within range (default 10),(max 200))") + "\n";
strUsage += " -splitthreshold=<n> " + _("Set stake split threshold within range (default 25),(max 2500))") + "\n";
strUsage += " -combinethreshold=<n> " + _("Set stake combine threshold within range (default 50),(max 5000))") + "\n";
strUsage += " -salvagewallet " + _("Attempt to recover private keys from a corrupt wallet.dat") + "\n";
strUsage += " -checkblocks=<n> " + _("How many blocks to check at startup (default: 2500, 0 = all)") + "\n";
strUsage += " -checklevel=<n> " + _("How thorough the block verification is (0-6, default: 1)") + "\n";
Expand Down
32 changes: 20 additions & 12 deletions src/kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@

using namespace std;

// Modifier interval: time to elapse before new modifier is computed
// Set to 6-hour for production network and 20-minute for test network
unsigned int nModifierInterval = MODIFIER_INTERVAL;
unsigned int GetModiferInterval()
{
// MODIFIER_INTERVAL: time to elapse before new modifier is computed
unsigned int nStakeModiferInterval = (fTestNet ? 20 * 60 : 6 * 60 * 60); // Modifier interval - 20min TestNet, 6 hours Mainnet(OLD)

//if (nBestHeight + 1 > (fTestNet ? MODIFER_TARGET_SWITCH_TESTNET : MODIFER_TARGET_SWITCH))
// nStakeModiferInterval = 10 * 60; // set to 10 mins for both (NEW)

return nStakeModiferInterval;
}

// Hard checkpoints of stake modifiers to ensure they are deterministic
static std::map<int, unsigned int> mapStakeModifierCheckpoints =
Expand Down Expand Up @@ -41,9 +48,9 @@ int64_t GetWeight(int64_t nIntervalBeginning, int64_t nIntervalEnd)
// Maximum TimeWeight is 30 days.

if ( nIntervalEnd > VERSION1_5_SWITCH_TIME )
return min(nIntervalEnd - nIntervalBeginning - SetStakeMinAge(), (int64_t)nStakeMaxAge);
return min(nIntervalEnd - nIntervalBeginning - GetStakeMinAge(), (int64_t)nStakeMaxAge);
else
return min(nIntervalEnd - nIntervalBeginning, (int64_t)nStakeMaxAge) - SetStakeMinAge();
return min(nIntervalEnd - nIntervalBeginning, (int64_t)nStakeMaxAge) - GetStakeMinAge();
}

// Get the last stake modifier and its generation time from a given block
Expand All @@ -64,7 +71,7 @@ static bool GetLastStakeModifier(const CBlockIndex* pindex, uint64_t& nStakeModi
static int64_t GetStakeModifierSelectionIntervalSection(int nSection)
{
assert (nSection >= 0 && nSection < 64);
return (nModifierInterval * 63 / (63 + ((63 - nSection) * (MODIFIER_INTERVAL_RATIO - 1))));
return (GetModiferInterval() * 63 / (63 + ((63 - nSection) * (MODIFIER_INTERVAL_RATIO - 1))));
}

// Get stake modifier selection interval (in seconds)
Expand Down Expand Up @@ -137,6 +144,7 @@ static bool SelectBlockFromCandidates(vector<pair<int64_t, uint256> >& vSortedBy
bool ComputeNextStakeModifier(const CBlockIndex* pindexPrev, uint64_t& nStakeModifier, bool& fGeneratedStakeModifier)
{
nStakeModifier = 0;
unsigned int nStakeModifierInterval = GetModiferInterval();
fGeneratedStakeModifier = false;
if (!pindexPrev)
{
Expand All @@ -151,14 +159,14 @@ bool ComputeNextStakeModifier(const CBlockIndex* pindexPrev, uint64_t& nStakeMod

LogPrint("stakemodifier", "ComputeNextStakeModifier: prev modifier=0x%016x time=%s\n", nStakeModifier, DateTimeStrFormat(nModifierTime));

if (nModifierTime / nModifierInterval >= pindexPrev->GetBlockTime() / nModifierInterval)
if (nModifierTime / nStakeModifierInterval >= pindexPrev->GetBlockTime() / nStakeModifierInterval)
return true;

// Sort candidate blocks by timestamp
vector<pair<int64_t, uint256> > vSortedByTimestamp;
vSortedByTimestamp.reserve(64 * nModifierInterval / SetTargetSpacing());
vSortedByTimestamp.reserve(64 * nStakeModifierInterval / GetTargetSpacing());
int64_t nSelectionInterval = GetStakeModifierSelectionInterval();
int64_t nSelectionIntervalStart = (pindexPrev->GetBlockTime() / nModifierInterval) * nModifierInterval - nSelectionInterval;
int64_t nSelectionIntervalStart = (pindexPrev->GetBlockTime() / nStakeModifierInterval) * nStakeModifierInterval - nSelectionInterval;
const CBlockIndex* pindex = pindexPrev;
while (pindex && pindex->GetBlockTime() >= nSelectionIntervalStart)
{
Expand Down Expand Up @@ -234,7 +242,7 @@ static bool GetKernelStakeModifier(uint256 hashBlockFrom, uint64_t& nStakeModifi
{
if (!pindex->pnext)
{ // reached best block; may happen if node is behind on block chain
if (fPrintProofOfStake || (pindex->GetBlockTime() + SetStakeMinAge() - nStakeModifierSelectionInterval > GetAdjustedTime()))
if (fPrintProofOfStake || (pindex->GetBlockTime() + GetStakeMinAge() - nStakeModifierSelectionInterval > GetAdjustedTime()))
return error("GetKernelStakeModifier() : reached best block %s at height %d from block %s",
pindex->GetBlockHash().ToString(), pindex->nHeight, hashBlockFrom.ToString());
else
Expand Down Expand Up @@ -287,7 +295,7 @@ bool CheckStakeKernelHash(unsigned int nBits, const CBlock& blockFrom, unsigned
return error("CheckStakeKernelHash() : nTime violation");

unsigned int nTimeBlockFrom = blockFrom.GetBlockTime();
if (nTimeBlockFrom + SetStakeMinAge() > nTimeTx) // Min age requirement
if (nTimeBlockFrom + GetStakeMinAge() > nTimeTx) // Min age requirement
return error("CheckStakeKernelHash() : min age violation");

CBigNum bnTargetPerCoinDay;
Expand Down Expand Up @@ -365,7 +373,7 @@ bool ScanForStakeKernelHash(MetaMap &mapMeta, KernelSearchSettings &settings, Co
static int nMaxStakeSearchInterval = 60;

// only count coins meeting min age requirement
if (SetStakeMinAge() + block.nTime > settings.nTime - nMaxStakeSearchInterval)
if (GetStakeMinAge() + block.nTime > settings.nTime - nMaxStakeSearchInterval)
continue;

// Transaction offset inside block
Expand Down
6 changes: 2 additions & 4 deletions src/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@
#include "main.h"
#include "wallet.h"

// MODIFIER_INTERVAL: time to elapse before new modifier is computed
static const unsigned int MODIFIER_INTERVAL = 6 * 60 * 60;
extern unsigned int nModifierInterval;

// MODIFIER_INTERVAL_RATIO:
// ratio of group interval length between the last group and the first group
static const int MODIFIER_INTERVAL_RATIO = 3;

unsigned int GetModiferInterval();

// Compute the hash modifier for proof-of-stake
bool ComputeNextStakeModifier(const CBlockIndex* pindexPrev, uint64_t& nStakeModifier, bool& fGeneratedStakeModifier);

Expand Down
27 changes: 9 additions & 18 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ int64_t nSplitThreshold = GetProofOfWorkReward();
int64_t nCombineThreshold = GetProofOfWorkReward() * 2;
extern enum Checkpoints::CPMode CheckpointsMode;

unsigned int SetTargetSpacing()
unsigned int GetTargetSpacing()
{
unsigned int nStakeTargetSpacingSwitch = (fTestNet ? 1 * 60 : 1 * 30); // block spacing, 1 min tesnet, 30 seconds Main (OLD)
if ( nBestHeight + 1 > (fTestNet ? SPACING_TARGET_SWITCH_TESTNET : SPACING_TARGET_SWITCH))
Expand All @@ -91,7 +91,7 @@ unsigned int SetTargetSpacing()
return nStakeTargetSpacingSwitch;
}

unsigned int SetStakeMinAge()
unsigned int GetStakeMinAge()
{
unsigned int nStakeMinAgeSwitch = (fTestNet ? 2 * 60 * 60 : 60 * 60 * 24 * 10); // minimum age for coin age - 2hrs TestNet, 10 days Main (OLD)
if (nBestHeight + 1 > (fTestNet ? SPACING_TARGET_SWITCH_TESTNET : SPACING_TARGET_SWITCH))
Expand Down Expand Up @@ -1367,7 +1367,7 @@ unsigned int GetNextTargetRequired(const CBlockIndex* pindexLast, bool fProofOfS
unsigned int GetNextTargetRequiredV1(const CBlockIndex* pindexLast, bool fProofOfStake)
{
CBigNum bnTargetLimit = !fProofOfStake ? bnProofOfWorkLimit : bnProofOfStakeLimit;
int64_t nTargetSpacingWorkMax = 12 * SetTargetSpacing(); // 2-hour
int64_t nTargetSpacingWorkMax = 12 * GetTargetSpacing(); // 2-hour

if(fProofOfStake)
{
Expand Down Expand Up @@ -1399,7 +1399,7 @@ unsigned int GetNextTargetRequiredV1(const CBlockIndex* pindexLast, bool fProofO
// ppcoin: retarget with exponential moving toward target spacing
CBigNum bnNew;
bnNew.SetCompact(pindexPrev->nBits);
unsigned int nTargetStakeSpacing = SetTargetSpacing();
unsigned int nTargetStakeSpacing = GetTargetSpacing();
int64_t nTargetSpacing = fProofOfStake ? nTargetStakeSpacing : min(nTargetSpacingWorkMax, (int64_t) nTargetStakeSpacing * (1 + pindexLast->nHeight - pindexPrev->nHeight));
int64_t nInterval = nTargetTimespan / nTargetSpacing;
bnNew *= ((nInterval - 1) * nTargetSpacing + nActualSpacing + nActualSpacing);
Expand All @@ -1414,7 +1414,7 @@ unsigned int GetNextTargetRequiredV1(const CBlockIndex* pindexLast, bool fProofO
unsigned int GetNextTargetRequiredV2(const CBlockIndex* pindexLast, bool fProofOfStake)
{
CBigNum bnTargetLimit = !fProofOfStake ? bnProofOfWorkLimit : bnProofOfStakeLimit;
int64_t nTargetSpacingWorkMax = 12 * SetTargetSpacing(); // 2-hour
int64_t nTargetSpacingWorkMax = 12 * GetTargetSpacing(); // 2-hour

if (pindexLast == NULL)
return bnTargetLimit.GetCompact(); // genesis block
Expand All @@ -1426,7 +1426,7 @@ unsigned int GetNextTargetRequiredV2(const CBlockIndex* pindexLast, bool fProofO
if (pindexPrevPrev->pprev == NULL)
return bnTargetLimit.GetCompact(); // second block

unsigned int nTargetStakeSpacing = SetTargetSpacing();
unsigned int nTargetStakeSpacing = GetTargetSpacing();
int64_t nActualSpacing = pindexPrev->GetBlockTime() - pindexPrevPrev->GetBlockTime();
int64_t nTargetSpacing = fProofOfStake ? nTargetStakeSpacing : min(nTargetSpacingWorkMax, (int64_t) nTargetStakeSpacing * (1 + pindexLast->nHeight - pindexPrev->nHeight));

Expand Down Expand Up @@ -2258,7 +2258,7 @@ bool CTransaction::GetCoinAge(CTxDB& txdb, uint64_t& nCoinAge) const
CBlock block;
if (!block.ReadFromDisk(txindex.pos.nFile, txindex.pos.nBlockPos, false))
return false; // unable to read block of previous transaction
if (block.GetBlockTime() + SetStakeMinAge() > nTime)
if (block.GetBlockTime() + GetStakeMinAge() > nTime)
continue; // only count coins meeting min age requirement

int64_t nValueIn = txPrev.vout[txin.prevout.n].nValue;
Expand Down Expand Up @@ -2880,7 +2880,7 @@ bool CheckDiskSpace(uint64_t nAdditionalBytes)
{
uint64_t nFreeBytesAvailable = filesystem::space(GetDataDir()).available;

// Check for nMinDiskSpace bytes (currently 50MB)
// Check for nMinDiskSpace bytes (currently 1GB)
if (nFreeBytesAvailable < nMinDiskSpace + nAdditionalBytes)
{
fShutdown = true;
Expand Down Expand Up @@ -2954,7 +2954,6 @@ bool LoadBlockIndex(bool fAllowNew)

bnProofOfStakeLimit = bnProofOfStakeLimitTestNet; // 0x00000fff PoS base target is fixed in testnet
bnProofOfWorkLimit = bnProofOfWorkLimitTestNet; // 0x0000ffff PoW base target is fixed in testnet
nModifierInterval = 20 * 60; // test modifier interval is 20 minutes
nCoinbaseMaturity = 10; // test maturity is 10 blocks
}

Expand Down Expand Up @@ -3355,14 +3354,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
return false;
}

if (pfrom->nVersion < 70010 && pindexBest->nHeight + 1 > SPACING_TARGET_SWITCH)
{
// disconnect from peers older than this proto version
LogPrintf("partner %s using obsolete version %i; disconnecting\n", pfrom->addr.ToString(), pfrom->nVersion);
pfrom->fDisconnect = true;
return false;
}

if (pfrom->nVersion == 10300)
pfrom->nVersion = 300;
if (!vRecv.empty())
Expand Down Expand Up @@ -3681,7 +3672,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
LogPrint("net", " getblocks stopping at %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString().substr(0,20));
// ppcoin: tell downloading node about the latest block if it's
// without risk being rejected due to stake connection check
if (hashStop != hashBestChain && pindex->GetBlockTime() + SetStakeMinAge() > pindexBest->GetBlockTime())
if (hashStop != hashBestChain && pindex->GetBlockTime() + GetStakeMinAge() > pindexBest->GetBlockTime())
pfrom->PushInventory(CInv(MSG_BLOCK, hashBestChain));
break;
}
Expand Down
8 changes: 4 additions & 4 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static const int64_t MAX_MINT_PROOF_OF_STAKE_FIX2 = 100 * CENT; // Correct just
/** Transactions smaller then this are ignored */
static const int64_t MIN_TXOUT_AMOUNT = MIN_TX_FEE;
/** Split/Combine Threshold Max */
static const int64_t MAX_SPLIT_AMOUNT = 100 * COIN;
static const int64_t MAX_SPLIT_AMOUNT = 2500 * COIN;
static const int64_t MAX_COMBINE_AMOUNT = MAX_SPLIT_AMOUNT * 2;

/** Hard Fork Change Times/Block */
Expand Down Expand Up @@ -150,7 +150,7 @@ extern bool fUseFastIndex;
extern int nScriptCheckThreads;

// Minimum disk space required - used in CheckDiskSpace()
static const uint64_t nMinDiskSpace = 52428800;
static const uint64_t nMinDiskSpace = 1073741824;


class CReserveKey;
Expand All @@ -159,8 +159,8 @@ class CTxIndex;
class CScriptCheck;
struct CNodeStateStats;

unsigned int SetTargetSpacing();
unsigned int SetStakeMinAge();
unsigned int GetTargetSpacing();
unsigned int GetStakeMinAge();
void RegisterWallet(CWallet* pwalletIn);
void UnregisterWallet(CWallet* pwalletIn);
void UnregisterAllWallets();
Expand Down
4 changes: 2 additions & 2 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1277,7 +1277,7 @@ void BitcoinGUI::updateStakingIcon()

if (!clientModel->getNumConnections())
labelStakingIcon->setToolTip(tr("Not staking because wallet is offline"));
else if (clientModel->getNumConnections() < 3 )
else if (clientModel->getNumConnections()< (fTestNet ? 0 : 3) )
labelStakingIcon->setToolTip(tr("Not staking because wallet is still acquiring nodes"));
else if (clientModel->inInitialBlockDownload() ||
clientModel->getNumBlocks() < clientModel->getNumBlocksOfPeers())
Expand All @@ -1296,7 +1296,7 @@ void BitcoinGUI::updateStakingIcon()
else
{
quint64 nNetworkWeight = clientModel->getPosKernalPS();
int nEstimateTime = clientModel->getStakeTargetSpacing() * 10 * nNetworkWeight / nWeight;
int nEstimateTime = clientModel->getStakeTargetSpacing() * nNetworkWeight / nWeight;
QString text = (GUIUtil::formatDurationStr(nEstimateTime));

labelStakingIcon->setPixmap(QIcon(":/icons/staking_on").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
Expand Down
6 changes: 3 additions & 3 deletions src/qt/charitydialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ StakeForCharityDialog::StakeForCharityDialog(QWidget *parent) :

#if (QT_VERSION >= 0x040700)
/* Do not move this to the XML file, Qt before 4.7 will choke on it */
ui->charityPercentEdit->setPlaceholderText(tr("Enter % to Give (1-50)"));
ui->charityPercentEdit->setPlaceholderText(tr("Enter % to Give (1-100)"));
ui->charityAddressEdit->setPlaceholderText(tr("Enter Charity Address"));
ui->charityMinEdit->setPlaceholderText(tr("Enter Min Amount (optional)"));
ui->charityMaxEdit->setPlaceholderText(tr("Enter Max Amount (optional)"));
Expand Down Expand Up @@ -117,10 +117,10 @@ void StakeForCharityDialog::on_enableButton_clicked()
}

int nCharityPercent = ui->charityPercentEdit->text().toInt(&fValidConversion, 10);
if (!fValidConversion || nCharityPercent > 50 || nCharityPercent <= 0)
if (!fValidConversion || nCharityPercent > 100 || nCharityPercent <= 0)
{
ui->message->setStyleSheet("QLabel { color: red; }");
ui->message->setText(tr("Please Enter 1 - 50 for percent."));
ui->message->setText(tr("Please Enter 1 - 100 for percent."));
ui->charityPercentEdit->setFocus();
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/qt/clientmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ double ClientModel::getPosKernalPS()

int ClientModel::getStakeTargetSpacing()
{
return SetTargetSpacing();
return GetTargetSpacing();
}

quint64 ClientModel::getTotalBytesRecv() const
Expand Down
10 changes: 8 additions & 2 deletions src/qt/coincontroldialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,12 @@ void CoinControlDialog::customSelectCoins()
//Age
double dAge = (GetTime() - out.tx->GetTxTime()) / (double)(1440 * 60);

//Tranz temp code to fix min weight at 8.8 days. (This should be removed once MODIFIER is set correctly
if (dAge < 8.8) {
nTxWeight = 0;
}


COutPoint outpt(txhash, out.i);

//selecting the coins
Expand Down Expand Up @@ -567,7 +573,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
sPriorityLabel = CoinControlDialog::getPriorityLabel(dPriority);

// Fee
qint64 nFee = nTransactionFee * (1 + (qint64)nBytes / 1000);
qint64 nFee = nTransactionFee;

// Min Fee
qint64 nMinFee = txDummy.GetMinFee(1, false, GMF_SEND, nBytes);
Expand Down Expand Up @@ -796,7 +802,7 @@ void CoinControlDialog::updateView()
itemOutput->setText(COLUMN_AGE_INT64, strPad(QString::number(nCoinAge), 15, " "));

// Potential Stake
qint64 nStakeAge = nAge - SetStakeMinAge() < 0 ? 0 : nCoinAge;
qint64 nStakeAge = nAge - GetStakeMinAge() < 0 ? 0 : nCoinAge;
qint64 nPotentialStake = (((nYearlyPercent * 1.001) / (365 * COIN)) * nStakeAge * nValue) / COIN;
itemOutput->setText(COLUMN_POTENTIALSTAKE, BitcoinUnits::formatAge(nDisplayUnit, nPotentialStake));
itemOutput->setText(COLUMN_POTENTIALSTAKE_INT64, strPad(QString::number(nPotentialStake), 15, " "));
Expand Down
Loading

0 comments on commit b3bff70

Please sign in to comment.