Skip to content

Commit

Permalink
Update split/combine threshold
Browse files Browse the repository at this point in the history
Up the max to 100/200 as startup, and added rpc commands, which allow
the default max, or wallet balance divided by 250
  • Loading branch information
Tranz5 committed Apr 22, 2015
1 parent a70a8bd commit f46fa0c
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/bitcoinrpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ static const CRPCCommand vRPCCommands[] =
{ "getworkex", &getworkex, true, false, false },
{ "getcheckpoint", &getcheckpoint, true, false, false },
{ "reservebalance", &reservebalance, false, true, true },
{ "splitthreshold", &splitthreshold, false, true, false },
{ "combinethreshold", &combinethreshold, false, true, false },
{ "checkwallet", &checkwallet, false, true, true },
{ "repairwallet", &repairwallet, false, true, true },
{ "resendtx", &resendtx, false, true, true },
Expand Down Expand Up @@ -1214,6 +1216,8 @@ Array RPCConvertValues(const std::string &strMethod, const std::vector<std::stri
if (strMethod == "sendmany" && n > 2) ConvertTo<boost::int64_t>(params[2]);
if (strMethod == "reservebalance" && n > 0) ConvertTo<bool>(params[0]);
if (strMethod == "reservebalance" && n > 1) ConvertTo<double>(params[1]);
if (strMethod == "splitthreshold" && n > 0) ConvertTo<double>(params[0]);
if (strMethod == "combinethreshold" && n > 0) ConvertTo<double>(params[0]);
if (strMethod == "addmultisigaddress" && n > 0) ConvertTo<boost::int64_t>(params[0]);
if (strMethod == "addmultisigaddress" && n > 1) ConvertTo<Array>(params[1]);
if (strMethod == "createmultisig" && n > 0) ConvertTo<boost::int64_t>(params[0]);
Expand Down
2 changes: 2 additions & 0 deletions src/bitcoinrpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ extern json_spirit::Value validateaddress(CWallet* pWallet, const json_spirit::A
extern json_spirit::Value getsubsidy(CWallet* pWallet,const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value getinfo(CWallet* pWallet, const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value reservebalance(CWallet* pWallet, const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value splitthreshold(CWallet* pWallet, const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value combinethreshold(CWallet* pWallet, const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value checkwallet(CWallet* pWallet, const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value repairwallet(CWallet* pWallet, const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value resendtx(CWallet* pWallet, const json_spirit::Array& params, bool fHelp);
Expand Down
6 changes: 3 additions & 3 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,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 20))") + "\n";
strUsage += " -combinethreshold=<n> " + _("Set stake combine threshold within range (default 10),(max 40))") + "\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 += " -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 Expand Up @@ -503,7 +503,7 @@ bool AppInit2()
if (mapArgs.count("-bind")) {
// when specifying an explicit binding address, you want to listen on it
// even when -connect or -proxy is specified
SoftSetBoolArg("-listen", true);
SoftSetBoolArg("-listen", false);
}

if (mapArgs.count("-connect") && mapMultiArgs["-connect"].size() > 0) {
Expand Down
2 changes: 1 addition & 1 deletion 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 = 20 * COIN;
static const int64_t MAX_SPLIT_AMOUNT = 100 * COIN;
static const int64_t MAX_COMBINE_AMOUNT = MAX_SPLIT_AMOUNT * 2;


Expand Down
62 changes: 62 additions & 0 deletions src/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1798,6 +1798,68 @@ Value validatepubkey(CWallet* pWallet, const Array& params, bool fHelp)
return ret;
}

Value splitthreshold(CWallet* pWallet, const Array& params, bool fHelp)
{
if (fHelp || params.size() > 1)
throw runtime_error(
"splitthreshold [amount]\n"
"[amount] is a real and rounded to cent.\n"
"Set split threshold, not to split a wallet block, if the PoS reward + wallet block is smaller then this amount \n"
"If no parameters provided current setting is printed.\n");

if (params.size() > 0)
{
int64_t nAmount = AmountFromValue(params[0]);
nAmount = (nAmount / CENT) * CENT; // round to cent
if (nAmount < 0)
throw runtime_error("amount cannot be negative.\n");

int64_t nMaxAmount = MAX_SPLIT_AMOUNT;
if ((((pwalletMain->GetBalance() / 500) / CENT ) * CENT) > MAX_SPLIT_AMOUNT)
nMaxAmount = (((pwalletMain->GetBalance() / 500) / CENT ) * CENT);

if (nAmount > nMaxAmount)
nAmount = nMaxAmount;

nSplitThreshold = nAmount;
}

Object result;
result.push_back(Pair("amount", ValueFromAmount(nSplitThreshold)));
return result;
}

Value combinethreshold(CWallet* pWallet, const Array& params, bool fHelp)
{
if (fHelp || params.size() > 1)
throw runtime_error(
"combinethreshold [amount]\n"
"[amount] is a real and rounded to cent.\n"
"Set combine threshold, to combine wallet blocks. Blocks must be on the same adress and reach max maturity. \n"
"If no parameters provided current setting is printed.\n");

if (params.size() > 0)
{
int64_t nAmount = AmountFromValue(params[0]);
nAmount = (nAmount / CENT) * CENT; // round to cent
if (nAmount < 0)
throw runtime_error("amount cannot be negative.\n");

int64_t nMaxAmount = MAX_COMBINE_AMOUNT;
if ((((pwalletMain->GetBalance() / 250) / CENT ) * CENT) > MAX_COMBINE_AMOUNT)
nMaxAmount = (((pwalletMain->GetBalance() / 250) / CENT ) * CENT);

if (nAmount > nMaxAmount)
nAmount = nMaxAmount;

nCombineThreshold = nAmount;
}

Object result;
result.push_back(Pair("amount", ValueFromAmount(nCombineThreshold)));
return result;
}

// ppcoin: reserve balance from being staked for network protection
Value reservebalance(CWallet* pWallet, const Array& params, bool fHelp)
{
Expand Down

0 comments on commit f46fa0c

Please sign in to comment.