From 2b9e3a100f4beece11569cb8555699e39f066455 Mon Sep 17 00:00:00 2001 From: Andrew K Date: Sat, 9 Jun 2018 23:12:10 +0000 Subject: [PATCH 01/14] change difficulty measure --- src/main.cpp | 8 ++++---- src/main.h | 4 ++-- src/miner.cpp | 2 +- src/rpcblockchain.cpp | 8 ++++++-- src/rpcmining.cpp | 2 +- src/rpcmisc.cpp | 16 ++++++++-------- src/rpcserver.h | 2 +- 7 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 5aff827936..ee2bf13890 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1597,7 +1597,7 @@ unsigned int static DarkGravityWave(const CBlockIndex* pindexLast, int algo) { } -unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, int algo) +unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, int algo) { if (RegTest()) return Params().ProofOfWorkLimit().GetCompact(); int nHeight = pindexLast->nHeight; @@ -1677,9 +1677,9 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead } } -unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock) +unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast) { - return GetNextWorkRequired(pindexLast, pblock, ALGO_SCRYPT); + return GetNextWorkRequired(pindexLast, ALGO_SCRYPT); } bool IsInitialBlockDownload() @@ -2878,7 +2878,7 @@ bool AcceptBlock(CBlock& block, CValidationState& state, CDiskBlockPos* dbp) // Check proof of work int block_algo = GetAlgo(block.nVersion); - unsigned int next_work_required = GetNextWorkRequired(pindexPrev, &block, block_algo); + unsigned int next_work_required = GetNextWorkRequired(pindexPrev, block_algo); if (block.nBits != next_work_required) { LogPrintf("nbits = %d, required = %d\n",block.nBits,next_work_required); return state.DoS(100, error("AcceptBlock() : incorrect proof of work"), diff --git a/src/main.h b/src/main.h index 56aa974e50..6fcc388b11 100644 --- a/src/main.h +++ b/src/main.h @@ -163,8 +163,8 @@ bool GetTransaction(const uint256 &hash, CTransaction &tx, uint256 &hashBlock, b bool ActivateBestChain(CValidationState &state); bool onFork(const CBlockIndex* pindex); int64_t GetBlockValue(CBlockIndex* pindexPrev, int64_t nFees, bool scale = true); -unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock); -unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, int algo); +unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast); +unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, int algo); void UpdateTime(CBlockHeader& block, const CBlockIndex* pindexPrev); diff --git a/src/miner.cpp b/src/miner.cpp index 2c069d6cce..72fbd75ec7 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -377,7 +377,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) //printf("create new block with hash prev = %s (height %d)\n",pblock->hashPrevBlock.GetHex().c_str(),pindexPrev->nHeight); UpdateTime(*pblock, pindexPrev); - pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, miningAlgo); + pblock->nBits = GetNextWorkRequired(pindexPrev, miningAlgo); //LogPrintf("create block nBits = %s\n",CBigNum().SetCompact(pblock->nBits).getuint256().GetHex().c_str()); pblock->nNonce = 0; if (miningAlgo==ALGO_EQUIHASH) { diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 60a7364e15..0b522e7ffc 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -18,7 +18,7 @@ using namespace std; void ScriptPubKeyToJSON(const CScript& scriptPubKey, Object& out, bool fIncludeHex); -double GetDifficulty(const CBlockIndex* blockindex, int algo) +double GetDifficulty(const CBlockIndex* blockindex, int algo, bool weighted, bool next) { // Floating point number that is a multiple of the minimum difficulty, // minimum difficulty = 1.0. @@ -41,7 +41,11 @@ double GetDifficulty(const CBlockIndex* blockindex, int algo) } } unsigned int nBits = 0; - unsigned int algoWeight = GetAlgoWeight(algo); + unsigned int algoWeight = 1; + if (weighted) algoWeight = GetAlgoWeight(algo); + if (next) { + nBits = GetNextWorkRequired(chainActive.Tip(),algo); + } if (blockindex && blockindex->nHeight>0) { nBits = blockindex->nBits; } diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index 94d76fae84..07d237d6d0 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -322,7 +322,7 @@ Value getmininginfo(const Array& params, bool fHelp) obj.push_back(Pair("reward_next", ValueFromAmount(GetBlockReward(chainActive.Tip(),0)*100000000.))); obj.push_back(Pair("reward_max", ValueFromAmount(GetBlockValue(chainActive.Tip(), 0, false)))); obj.push_back(Pair("hashrate_4max_reward", (uint64_t)35000000000)); - obj.push_back(Pair("difficulty", (double)GetDifficulty(NULL,-1))); + obj.push_back(Pair("difficulty", (double)GetDifficulty(NULL,miningAlgo,false,true))); obj.push_back(Pair("errors", GetWarnings("statusbar"))); obj.push_back(Pair("genproclimit", (int)GetArg("-genproclimit", -1))); obj.push_back(Pair("networkhashps", getnetworkhashps(params, false))); diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 558eda3b9e..4de3ff40a7 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -75,14 +75,14 @@ Value getinfo(const Array& params, bool fHelp) obj.push_back(Pair("timeoffset", GetTimeOffset())); obj.push_back(Pair("connections", (int)vNodes.size())); obj.push_back(Pair("proxy", (proxy.first.IsValid() ? proxy.first.ToStringIPPort() : string()))); - obj.push_back(Pair("difficulty SCRYPT", (double)GetDifficulty(NULL,ALGO_SCRYPT))); - obj.push_back(Pair("difficulty SHA256D", (double)GetDifficulty(NULL,ALGO_SHA256D))); - obj.push_back(Pair("difficulty YESCRYPT", (double)GetDifficulty(NULL,ALGO_YESCRYPT))); - obj.push_back(Pair("difficulty ARGON2", (double)GetDifficulty(NULL,ALGO_ARGON2))); - obj.push_back(Pair("difficulty X17", (double)GetDifficulty(NULL,ALGO_X17))); - obj.push_back(Pair("difficulty LYRA2REv2", (double)GetDifficulty(NULL,ALGO_LYRA2REv2))); - obj.push_back(Pair("difficulty EQUIHASH", (double)GetDifficulty(NULL,ALGO_EQUIHASH))); - obj.push_back(Pair("difficulty CRYPTONIGHT", (double)GetDifficulty(NULL,ALGO_CRYPTONIGHT))); + obj.push_back(Pair("difficulty SCRYPT", (double)GetDifficulty(NULL,ALGO_SCRYPT,true,true))); + obj.push_back(Pair("difficulty SHA256D", (double)GetDifficulty(NULL,ALGO_SHA256D,true,true))); + obj.push_back(Pair("difficulty YESCRYPT", (double)GetDifficulty(NULL,ALGO_YESCRYPT,true,true))); + obj.push_back(Pair("difficulty ARGON2", (double)GetDifficulty(NULL,ALGO_ARGON2,true,true))); + obj.push_back(Pair("difficulty X17", (double)GetDifficulty(NULL,ALGO_X17,true,true))); + obj.push_back(Pair("difficulty LYRA2REv2", (double)GetDifficulty(NULL,ALGO_LYRA2REv2,true,true))); + obj.push_back(Pair("difficulty EQUIHASH", (double)GetDifficulty(NULL,ALGO_EQUIHASH,true,true))); + obj.push_back(Pair("difficulty CRYPTONIGHT", (double)GetDifficulty(NULL,ALGO_CRYPTONIGHT,true,true))); obj.push_back(Pair("moneysupply", (double)GetMoneySupply(NULL,-1))); obj.push_back(Pair("testnet", TestNet())); #ifdef ENABLE_WALLET diff --git a/src/rpcserver.h b/src/rpcserver.h index fa00eef490..dc647935c5 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -102,7 +102,7 @@ extern void ShutdownRPCMining(); extern int64_t nWalletUnlockTime; extern int64_t AmountFromValue(const json_spirit::Value& value); extern json_spirit::Value ValueFromAmount(int64_t amount); -extern double GetDifficulty(const CBlockIndex* blockindex = NULL, const int algo = 0); +extern double GetDifficulty(const CBlockIndex* blockindex = NULL, const int algo = 0, const bool weighted = true, const bool next = true); extern double GetPeakHashrate(const CBlockIndex* blockindex = NULL, const int algo = 0); extern double GetCurrentHashrate(const CBlockIndex* blockindex = NULL, const int algo = 0); extern double GetMoneySupply(const CBlockIndex* blockindex = NULL, const int algo = -1); From 7422dc241918f3e893da07ffda3d9e229e791110 Mon Sep 17 00:00:00 2001 From: Andrew K Date: Sun, 10 Jun 2018 01:02:34 +0000 Subject: [PATCH 02/14] use megawork units --- src/main.cpp | 2 +- src/rpcblockchain.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index ee2bf13890..ea23d49f26 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5021,7 +5021,7 @@ unsigned long get_ssf_work (const CBlockIndex * pindex) { CBigNum hashes_bn = pprev_algo->GetBlockWork(); for (int i=0; inVersion)) { - return hashes_bn.getulong(); + return (hashes_bn/1000000).getulong(); } pprev_algo = get_pprev_algo(pprev_algo,-1); if (!pprev_algo) return 0; diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 0b522e7ffc..66ade8cfe3 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -132,7 +132,7 @@ double GetPeakHashrate (const CBlockIndex* blockindex, int algo) { return std::numeric_limits::max(); } //LogPrintf("hashes = %f, time = %f\n",(double)hashes_bn.getulong(),(double)time_f); - double hashes = ((double)hashes_bn.getulong())/((double)time_f); + double hashes = ((hashes_bn/time_f)/1000000).getulong(); //LogPrintf("hashes per sec = %f\n",hashes); if (hashes>hashes_peak) hashes_peak = hashes; } @@ -196,7 +196,7 @@ double GetCurrentHashrate (const CBlockIndex* blockindex, int algo) { //as used return std::numeric_limits::max(); } //LogPrintf("return %lu / %f\n",(double)hashes_bn.getulong(),(double)time_f); - return ((double)hashes_bn.getulong())/((double)time_f); + return ((hashes_bn/time_f)/1000000).getulong(); } blockindex = get_pprev_algo(blockindex,-1); } while (blockindex); From 93d1865f523685bcf9eb606c585f2fb708f8c302 Mon Sep 17 00:00:00 2001 From: Andrew K Date: Mon, 11 Jun 2018 23:17:14 +0000 Subject: [PATCH 03/14] fix documentation --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 463b7ddb4a..4a6ce0a696 100644 --- a/README.md +++ b/README.md @@ -26,8 +26,9 @@ Bitmark aims to be a relatively stable, user focused, crypto currency, which ref **Balance**: Every aspect of Bitmark has been designed in order to balance the interests of everybody involved or associated with the project. This includes [Investor Public Mining (IPM)](https://github.com/project-bitmark/bitmark/wiki/IPM-Pool) which balances Investors, Miners, and Developers in a way that is mutually beneficial and which critically enables those at the core to provide the best network experience to those who rely on it, the users. -* [Project Project - Documentation and Plan](https://github.com/project-bitmark/bitmark/wiki) +* [Documentation and Plan](https://github.com/project-bitmark/bitmark/wiki) * [Discussion and Updates](https://bitcointalk.org/index.php?topic=660544.0) +* [Block Explorer](http://explorer.bitmark.co) ## Getting Bitmark @@ -77,7 +78,7 @@ You can also use the bitmark-cli command to mine. The last parameter is the algo `bitmark-cli setgenerate true 3` -For equihash, it is recommended to use the built in miner as the cpuminer is slow at the moment. +For equihash and cryptonight, it is recommended to use the built in miner as the cpuminer is slow at the moment. There are currently 3 types of tests implemented. @@ -89,4 +90,4 @@ There are currently 3 types of tests implemented. ## Merge Mining -Also part of the hard fork is merge mining, a way to increase the hashpower security of the chain by allowing the mining of the chain simultaneously with another chain. All 8 algorithms are supported. +Also part of the hard fork is merge mining, a way to increase the hashpower security of the chain by allowing the mining of the chain simultaneously with other chains. All 8 algorithms are supported. From 2ed964398e249dc05386ed1c16f4c582b0243cc0 Mon Sep 17 00:00:00 2001 From: DB Keys Date: Tue, 12 Jun 2018 12:51:18 +0000 Subject: [PATCH 04/14] Additional RPC abbreviations --- src/rpcmisc.cpp | 1 + src/rpcserver.cpp | 23 ++++++++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 4de3ff40a7..b500590664 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -45,6 +45,7 @@ Value getinfo(const Array& params, bool fHelp) " \"connections\": xxxxx, (numeric) the number of connections\n" " \"proxy\": \"host:port\", (string, optional) the proxy used by the server\n" " \"difficulty \": xxxxxx, (numeric) the current difficulty for the algo \n" +// Difficulties for all algos " \"moneysupply\": xxxxxx, (numeric) the total amount of coins distributed\n" " \"testnet\": true|false, (boolean) if the server is using testnet or not\n" " \"keypoololdest\": xxxxxx, (numeric) the timestamp (seconds since GMT epoch) of the oldest pre-generated key in the key pool\n" diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index 2e71a0bd86..73a1a9bd90 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2010 Satoshi Nakamoto // Original Code: Copyright (c) 2009-2014 The Bitcoin Core Developers -// Modified Code: Copyright (c) 2014 Project Bitmark +// Modified Code: Copyright (c) 2014-2018 Project Bitmark // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -227,7 +227,8 @@ static const CRPCCommand vRPCCommands[] = /* Overall control/query calls */ { "getinfo", &getinfo, true, false, false }, /* uses wallet if enabled */ { "gi", &getinfo, true, false, false }, /* uses wallet if enabled */ - { "chaindynamics", &chaindynamics, true, false, false}, + { "chaindynamics", &chaindynamics, true, false, false}, + { "cd", &chaindynamics, true, false, false}, { "help", &help, true, true, false }, { "stop", &stop, true, true, false }, @@ -256,10 +257,10 @@ static const CRPCCommand vRPCCommands[] = { "gbbh", &getbestblockhash, true, false, false }, { "getblockcount", &getblockcount, true, false, false }, { "gbc", &getblockcount, true, false, false }, - { "getblock", &getblock, true, false, false }, - { "gb", &getblock, true, false, false }, - { "getblockhash", &getblockhash, true, false, false }, - { "gbh", &getblockhash, true, false, false }, + { "getblock", &getblock, true, false, false }, + { "gb", &getblock, true, false, false }, + { "getblockhash", &getblockhash, true, false, false }, + { "gbh", &getblockhash, true, false, false }, { "getrawmempool", &getrawmempool, true, false, false }, { "grmp", &getrawmempool, true, false, false }, { "gettxout", &gettxout, true, false, false }, @@ -269,9 +270,12 @@ static const CRPCCommand vRPCCommands[] = { "verifychain", &verifychain, true, false, false }, { "vc", &verifychain, true, false, false }, { "getblockspacing", &getblockspacing, true, false, false }, - { "getblockreward", &getblockreward, true, false, false }, - { "getmoneysupply", &getmoneysupply, true, false, false }, - { "getdifficulty", &getdifficulty, true, false, false }, + { "gbs", &getblockspacing, true, false, false }, + { "getblockreward", &getblockreward, true, false, false }, + { "gbr", &getblockreward, true, false, false }, + { "getmoneysupply", &getmoneysupply, true, false, false }, + { "gms", &getmoneysupply, true, false, false }, + { "getdifficulty", &getdifficulty, true, false, false }, { "gd", &getdifficulty, true, false, false }, /* Mining */ @@ -284,6 +288,7 @@ static const CRPCCommand vRPCCommands[] = { "submitblock", &submitblock, true, false, false }, { "sb", &submitblock, true, false, false }, { "getauxblock", &getauxblock, true, false, false }, + { "gab", &getauxblock, true, false, false }, /* Raw transactions */ { "createrawtransaction", &createrawtransaction, true, false, false }, From 4cc9fe95432b8068d9769f9318679f9ab2577f69 Mon Sep 17 00:00:00 2001 From: Andrew K Date: Wed, 13 Jun 2018 14:20:39 +0000 Subject: [PATCH 05/14] show parent prev block hash --- src/main.cpp | 2 +- src/main.h | 2 +- src/rpcblockchain.cpp | 6 ++++-- src/rpcmining.cpp | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index ea23d49f26..2079b61d08 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1202,7 +1202,7 @@ bool onFork (const CBlockIndex * pindex) { return pindex->onFork(); } -int64_t GetBlockValue(CBlockIndex* pindex, int64_t nFees, bool scale) +int64_t GetBlockValue(CBlockIndex* pindex, int64_t nFees) { // for testnet int nHeight = pindex->nHeight; diff --git a/src/main.h b/src/main.h index 6fcc388b11..d646f32a54 100644 --- a/src/main.h +++ b/src/main.h @@ -162,7 +162,7 @@ bool GetTransaction(const uint256 &hash, CTransaction &tx, uint256 &hashBlock, b /** Find the best known block, and make it the tip of the block chain */ bool ActivateBestChain(CValidationState &state); bool onFork(const CBlockIndex* pindex); -int64_t GetBlockValue(CBlockIndex* pindexPrev, int64_t nFees, bool scale = true); +int64_t GetBlockValue(CBlockIndex* pindexPrev, int64_t nFees); unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast); unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, int algo); diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 66ade8cfe3..0bcd131318 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -355,9 +355,11 @@ Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex) // 7 is the typical offset in monero, but not fully general sprintf(prev_id+2*i,"%02x",vector_rep[i+7]); } - result.push_back(Pair("parentblockprevid",prev_id)); + result.push_back(Pair("parentblockprevhash",prev_id)); + } + else { + result.push_back(Pair("parentblockprevhash",block.auxpow->parentBlock.hashPrevBlock.GetHex())); } - } result.push_back(Pair("SSF height",get_ssf_height(blockindex))); result.push_back(Pair("SSF work", (int64_t)get_ssf_work(blockindex))); diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index 07d237d6d0..b1562e314d 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -319,8 +319,8 @@ Value getmininginfo(const Array& params, bool fHelp) obj.push_back(Pair("blocks", (int)chainActive.Height())); obj.push_back(Pair("currentblocksize", (uint64_t)nLastBlockSize)); obj.push_back(Pair("currentblocktx", (uint64_t)nLastBlockTx)); - obj.push_back(Pair("reward_next", ValueFromAmount(GetBlockReward(chainActive.Tip(),0)*100000000.))); - obj.push_back(Pair("reward_max", ValueFromAmount(GetBlockValue(chainActive.Tip(), 0, false)))); + obj.push_back(Pair("reward_next", ValueFromAmount(GetBlockReward(chainActive.Tip(),miningAlgo)*100000000.))); + obj.push_back(Pair("reward_max", ValueFromAmount(GetBlockValue(chainActive.Tip(), 0)))); obj.push_back(Pair("hashrate_4max_reward", (uint64_t)35000000000)); obj.push_back(Pair("difficulty", (double)GetDifficulty(NULL,miningAlgo,false,true))); obj.push_back(Pair("errors", GetWarnings("statusbar"))); From abfdc29899765d0dd5875ce866fa7e9485589040 Mon Sep 17 00:00:00 2001 From: dbkeys Date: Tue, 19 Jun 2018 06:33:31 -0700 Subject: [PATCH 06/14] Standardize ouput of RPC calls 'getinfo' & 'getmininginfo' 'getmininginfo' displays both weighted & unweighted difficulty --- src/core.cpp | 13 +++++++++++-- src/rpcblockchain.cpp | 2 +- src/rpcmining.cpp | 36 ++++++++++++++++++++++++++++++++---- src/rpcmisc.cpp | 17 +++++++++++++++-- 4 files changed, 59 insertions(+), 9 deletions(-) diff --git a/src/core.cpp b/src/core.cpp index 5ed3ac8c73..ff48205ea5 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -649,9 +649,18 @@ bool CheckAuxPowProofOfWork(const CBlockHeader& block, const CChainParams& param return true; } -// Based on tests with general purpose CPUs, except for SHA256 which was designed for simplicity and suited for ASICs, so given a factor of 16 decrease in weight. +// Based on tests with general purpose CPUs, +// ( Except for SHA256 which was designed for simplicity and suited for ASICs, +// so given a factor of 16 decrease in weight. ) +// Weighing gives more value to hashes from some algos over others, +// because, for example a Cryptonight hash is much more computationally expensive +// than a SHA256d hash. +// Weights should ultimately reflect the market value of hashes by different algorithms; +// this will vary constantly (and more significantly long-term with hardware developement) +// As of June, 2018 these values are closely reflective of market values seen on +// nicehash.com and miningrigrentals.com unsigned int GetAlgoWeight (const int algo) { - unsigned int weight = 8000; // scrypt, lyra2rev2, and share this value + unsigned int weight = 8000; // scrypt, lyra2rev2 and 17 share this value. switch (algo) { case ALGO_SHA256D: diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 66ade8cfe3..e582e036ca 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2010 Satoshi Nakamoto // Original Code: Copyright (c) 2009-2014 The Bitcoin Core Developers -// Modified Code: Copyright (c) 2014 Project Bitmark +// Modified Code: Copyright (c) 2014-2018 Project Bitmark // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index 07d237d6d0..aebec138da 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -302,7 +302,19 @@ Value getmininginfo(const Array& params, bool fHelp) " \"reward_next\": nnn, (numeric) The next block reward\n" " \"reward_max\": nnn, (numeric) The maximum block reward\n" " \"hashrate_4max_reward\": nnn, (numeric) The hashrate required for max reward\n" - " \"difficulty\": xxx.xxxxx (numeric) The current difficulty\n" + " \"pow_algo_id\": n (numeric) The active mining algorithm id\n" + " \"pow_algo\": \"name\" (string) The active mining algorithm name\n" + " \"difficulty\": xxx.xxxxx (numeric) The current (weighted) difficulty\n" +// unweighted "simple" difficulty. + " \"sdifficulty\": xxx.xxxxx (numeric) The current (unweighted) difficulty\n" + " \"difficulty_scrypt\": xxxxxx, (numeric) the current scrypt difficulty\n" + " \"difficulty_sha256d\": xxxxxx, (numeric) the current sha256d difficulty\n" + " \"difficulty_yescrypt\": xxxxxx, (numeric) the current yescrypt difficulty\n" + " \"difficulty_argon2d\": xxxxxx, (numeric) the current argon2d difficulty\n" + " \"difficulty_x17\": xxxxxx, (numeric) the current x17 difficulty\n" + " \"difficulty_lyra2rev2\": xxxxxx, (numeric) the current lyra2rev2 difficulty\n" + " \"difficulty_equihash\": xxxxxx, (numeric) the current equihash difficulty\n" + " \"difficulty_cryptonight\": xxxxxx, (numeric) the current cryptonight difficulty\n" " \"errors\": \"...\" (string) Current errors\n" " \"generate\": true|false (boolean) If the generation is on or off (see getgenerate or setgenerate calls)\n" " \"genproclimit\": n (numeric) The processor limit for generation. -1 if no generation. (see getgenerate or setgenerate calls)\n" @@ -319,10 +331,26 @@ Value getmininginfo(const Array& params, bool fHelp) obj.push_back(Pair("blocks", (int)chainActive.Height())); obj.push_back(Pair("currentblocksize", (uint64_t)nLastBlockSize)); obj.push_back(Pair("currentblocktx", (uint64_t)nLastBlockTx)); + obj.push_back(Pair("pow_algo_id", miningAlgo)); + obj.push_back(Pair("pow_algo",GetAlgoName(miningAlgo))); obj.push_back(Pair("reward_next", ValueFromAmount(GetBlockReward(chainActive.Tip(),0)*100000000.))); obj.push_back(Pair("reward_max", ValueFromAmount(GetBlockValue(chainActive.Tip(), 0, false)))); obj.push_back(Pair("hashrate_4max_reward", (uint64_t)35000000000)); - obj.push_back(Pair("difficulty", (double)GetDifficulty(NULL,miningAlgo,false,true))); + obj.push_back(Pair("pow_algo_id", miningAlgo)); + obj.push_back(Pair("pow_algo",GetAlgoName(miningAlgo))); +// difficulty is weighted in Bitmark to more meaningfully compare relative values of competing chains +// boolean for weighted / unweighted -------v + obj.push_back(Pair("difficulty", (double)GetDifficulty(NULL,miningAlgo,true,true))); +// sdifficulty: the "simple", unweighted difficulty + obj.push_back(Pair("sdifficulty", (double)GetDifficulty(NULL,miningAlgo,false,true))); + obj.push_back(Pair("difficulty SCRYPT", (double)GetDifficulty(NULL,ALGO_SCRYPT,true,true))); + obj.push_back(Pair("difficulty SHA256D", (double)GetDifficulty(NULL,ALGO_SHA256D,true,true))); + obj.push_back(Pair("difficulty YESCRYPT", (double)GetDifficulty(NULL,ALGO_YESCRYPT,true,true))); + obj.push_back(Pair("difficulty ARGON2", (double)GetDifficulty(NULL,ALGO_ARGON2,true,true))); + obj.push_back(Pair("difficulty X17", (double)GetDifficulty(NULL,ALGO_X17,true,true))); + obj.push_back(Pair("difficulty LYRA2REv2", (double)GetDifficulty(NULL,ALGO_LYRA2REv2,true,true))); + obj.push_back(Pair("difficulty EQUIHASH", (double)GetDifficulty(NULL,ALGO_EQUIHASH,true,true))); + obj.push_back(Pair("difficulty CRYPTONIGHT", (double)GetDifficulty(NULL,ALGO_CRYPTONIGHT,true,true))); obj.push_back(Pair("errors", GetWarnings("statusbar"))); obj.push_back(Pair("genproclimit", (int)GetArg("-genproclimit", -1))); obj.push_back(Pair("networkhashps", getnetworkhashps(params, false))); @@ -330,8 +358,8 @@ Value getmininginfo(const Array& params, bool fHelp) obj.push_back(Pair("testnet", TestNet())); #ifdef ENABLE_WALLET obj.push_back(Pair("generate", getgenerate(params, false))); - obj.push_back(Pair("algo", miningAlgo)); - obj.push_back(Pair("algoname",GetAlgoName(miningAlgo))); + obj.push_back(Pair("pow_algo_id", miningAlgo)); + obj.push_back(Pair("pow_algo",GetAlgoName(miningAlgo))); obj.push_back(Pair("hashespersec", gethashespersec(params, false))); #endif return obj; diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index b500590664..eedc758606 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -12,6 +12,7 @@ #include "netbase.h" #include "rpcserver.h" #include "util.h" +#include "miner.h" #ifdef ENABLE_WALLET #include "wallet.h" #include "walletdb.h" @@ -44,8 +45,17 @@ Value getinfo(const Array& params, bool fHelp) " \"timeoffset\": xxxxx, (numeric) the time offset\n" " \"connections\": xxxxx, (numeric) the number of connections\n" " \"proxy\": \"host:port\", (string, optional) the proxy used by the server\n" - " \"difficulty \": xxxxxx, (numeric) the current difficulty for the algo \n" -// Difficulties for all algos + " \"pow_algo_id\": n (numeric) The active mining algorithm id\n" + " \"pow_algo\": \"name\" (string) The active mining algorithm name\n" +// " \"difficulty \": xxxxxx, (numeric) the current difficulty for the algo \n" + " \"difficulty_scrypt\": xxxxxx, (numeric) the current scrypt difficulty\n" + " \"difficulty_sha256d\": xxxxxx, (numeric) the current sha256d difficulty\n" + " \"difficulty_yescrypt\": xxxxxx, (numeric) the current yescrypt difficulty\n" + " \"difficulty_argon2d\": xxxxxx, (numeric) the current argon2d difficulty\n" + " \"difficulty_x17\": xxxxxx, (numeric) the current x17 difficulty\n" + " \"difficulty_lyra2rev2\": xxxxxx, (numeric) the current lyra2rev2 difficulty\n" + " \"difficulty_equihash\": xxxxxx, (numeric) the current equihash difficulty\n" + " \"difficulty_cryptonight\": xxxxxx, (numeric) the current cryptonight difficulty\n" " \"moneysupply\": xxxxxx, (numeric) the total amount of coins distributed\n" " \"testnet\": true|false, (boolean) if the server is using testnet or not\n" " \"keypoololdest\": xxxxxx, (numeric) the timestamp (seconds since GMT epoch) of the oldest pre-generated key in the key pool\n" @@ -76,6 +86,9 @@ Value getinfo(const Array& params, bool fHelp) obj.push_back(Pair("timeoffset", GetTimeOffset())); obj.push_back(Pair("connections", (int)vNodes.size())); obj.push_back(Pair("proxy", (proxy.first.IsValid() ? proxy.first.ToStringIPPort() : string()))); + obj.push_back(Pair("pow_algo_id", miningAlgo)); + obj.push_back(Pair("pow_algo",GetAlgoName(miningAlgo))); + obj.push_back(Pair("difficulty", (double)GetDifficulty(NULL,miningAlgo,true,true))); obj.push_back(Pair("difficulty SCRYPT", (double)GetDifficulty(NULL,ALGO_SCRYPT,true,true))); obj.push_back(Pair("difficulty SHA256D", (double)GetDifficulty(NULL,ALGO_SHA256D,true,true))); obj.push_back(Pair("difficulty YESCRYPT", (double)GetDifficulty(NULL,ALGO_YESCRYPT,true,true))); From 6e914ee20bee337d17450608ddd058306709ee89 Mon Sep 17 00:00:00 2001 From: dbkeys Date: Tue, 19 Jun 2018 06:39:05 -0700 Subject: [PATCH 07/14] Only show pow_algo_id & pow_algo once --- src/rpcmining.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index aebec138da..c648bc7ec3 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -358,8 +358,6 @@ Value getmininginfo(const Array& params, bool fHelp) obj.push_back(Pair("testnet", TestNet())); #ifdef ENABLE_WALLET obj.push_back(Pair("generate", getgenerate(params, false))); - obj.push_back(Pair("pow_algo_id", miningAlgo)); - obj.push_back(Pair("pow_algo",GetAlgoName(miningAlgo))); obj.push_back(Pair("hashespersec", gethashespersec(params, false))); #endif return obj; From a0d9a4e6559c1ab24765943df69f063ea4906b33 Mon Sep 17 00:00:00 2001 From: dbkeys Date: Sat, 23 Jun 2018 11:29:11 -0700 Subject: [PATCH 08/14] Bump Network Protocol ---> 70003; Bump Build Version v0.9.7.1 --- README.md | 4 ++-- configure.ac | 4 ++-- doc/README.md | 7 +++---- src/clientversion.h | 4 ++-- src/main.cpp | 4 +++- src/rpcmisc.cpp | 17 +++++++++++++++++ src/version.h | 5 ++++- 7 files changed, 33 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 4a6ce0a696..0e0d339b0f 100644 --- a/README.md +++ b/README.md @@ -47,13 +47,13 @@ rpcpassword=YoUrSecreT-PaSsWoRd listen=1 -##Note: Daniel J. Bernstein's libsodium cryptographic library is requred by Bitmark v0.9.7 +##Note: libsodium cryptographic library is required by Bitmark v0.9.7 Ubuntu 16 and higher may simply do: sudo apt-get install libsodium-dev -otherwise, you may have to compile this library from scratch: +otherwise, you may compile this library from sources:: git clone git://github.com/jedisct1/libsodium.git cd libsodium diff --git a/configure.ac b/configure.ac index 2d53f3b3e3..1ed6f04c5b 100644 --- a/configure.ac +++ b/configure.ac @@ -3,9 +3,9 @@ AC_PREREQ([2.60]) define(_CLIENT_VERSION_MAJOR, 0) define(_CLIENT_VERSION_MINOR, 9) define(_CLIENT_VERSION_REVISION, 7) -define(_CLIENT_VERSION_BUILD, 0) +define(_CLIENT_VERSION_BUILD, 1) define(_CLIENT_VERSION_IS_RELEASE, true) -define(_COPYRIGHT_YEAR, 2017) +define(_COPYRIGHT_YEAR, 2018) AC_INIT([Bitmark Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[info@bitmark.org],[bitmark]) AC_CONFIG_AUX_DIR([src/build-aux]) AC_CONFIG_MACRO_DIR([src/m4]) diff --git a/doc/README.md b/doc/README.md index e8d943b8a1..4132937728 100644 --- a/doc/README.md +++ b/doc/README.md @@ -1,4 +1,4 @@ -Bitmark 0.9.5 BETA +Bitmark 0.9.7.1 BETA ===================== Copyright (c) 2009-2018 Bitmark Developers @@ -6,7 +6,7 @@ Copyright (c) 2009-2018 Bitmark Developers Setup --------------------- -[Bitmark Core](http://bitmark.io/en/download) is the original Bitmark client and it builds the backbone of the network. It downloads and stores the entire history of Bitmark transactions (as of December 2017, less than 1 GiB of data); depending on the speed of your computer and network connection, the synchronization process can take anywhere from a few hours to a day or more. Thankfully you only have to do this once. If you would like the process to go faster you can [download the blockchain directly](bootstrap.md). +[Bitmark Core](http://bitmark.io/en/download) is the original Bitmark client and it builds the backbone of the network. It downloads and stores the entire history of Bitmark transactions (as of June 2018, less than 1 GiB of data); depending on the speed of your computer and network connection, the synchronization process can take anywhere from a few hours to a day or more. Thankfully you only have to do this once. If you would like the process to go faster you can [download the blockchain directly](bootstrap.md). Running --------------------- @@ -71,5 +71,4 @@ The Bitmark repo's [root README](https://github.com/project-bitmark/bitmark/blob License --------------------- Distributed under the [MIT/X11 software license](http://www.opensource.org/licenses/mit-license.php). -This product includes software developed by the OpenSSL Project for use in the [OpenSSL Toolkit](http://www.openssl.org/). This product includes -cryptographic software written by Eric Young ([eay@cryptsoft.com](mailto:eay@cryptsoft.com)), and UPnP software written by Thomas Bernard. +This product includes software developed by the OpenSSL Project for use in the [OpenSSL Toolkit](http://www.openssl.org/). This product includes cryptographic software written by Eric Young ([eay@cryptsoft.com](mailto:eay@cryptsoft.com)), and UPnP software written by Thomas Bernard. diff --git a/src/clientversion.h b/src/clientversion.h index bdb911d2b0..2f62104010 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -12,14 +12,14 @@ #define CLIENT_VERSION_MAJOR 0 #define CLIENT_VERSION_MINOR 9 #define CLIENT_VERSION_REVISION 7 -#define CLIENT_VERSION_BUILD 1 +#define CLIENT_VERSION_BUILD 2 // Set to true for release, false for prerelease (rc: release candidate) or test build #define CLIENT_VERSION_IS_RELEASE false // Copyright year (2009-this) -#define COPYRIGHT_YEAR 2017 +#define COPYRIGHT_YEAR 2018 #endif //HAVE_CONFIG_H diff --git a/src/main.cpp b/src/main.cpp index ea23d49f26..edf584a01b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1405,7 +1405,7 @@ unsigned int ComputeMinWork(unsigned int nBase, int64_t nTime) unsigned int static DarkGravityWave(const CBlockIndex* pindexLast, int algo) { - /* current difficulty formula, dash - DarkGravity v3, written by Evan Duffield - evan@dashpay.io */ + /* current difficulty formula, DASH - DarkGravity v3, written by Evan Duffield - evan@dashpay.io */ const CBlockIndex *BlockLastSolved = pindexLast; const CBlockIndex *BlockReading = pindexLast; int64_t nActualTimespan = 0; @@ -1609,6 +1609,7 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, int algo) workAlgo = 1; } + // workAlgo functions here as post_fork boolean; 0: pre-fork, 1: post-fork if (workAlgo == 0) { unsigned int nProofOfWorkLimit = Params().ProofOfWorkLimit().GetCompact(); @@ -1673,6 +1674,7 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, int algo) return bnNew.GetCompact(); } else { + // Post 8mPoW fork return DarkGravityWave(pindexLast,algo); } } diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index eedc758606..203cdd1443 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -581,6 +581,7 @@ Value chaindynamics(const Array& params, bool fHelp) "}\n" "\nResult:\n" "{\n" + " \"sdifficulty \": xxxxx (numeric),\n" " \"difficulty \": xxxxx (numeric),\n" " \"peak hashrate \": xxxxx (numeric),\n" " \"current hashrate \": xxxxx (numeric),\n" @@ -602,6 +603,22 @@ Value chaindynamics(const Array& params, bool fHelp) } Object obj; + obj.push_back(Pair("pow_algo_id", miningAlgo)); + obj.push_back(Pair("pow_algo",GetAlgoName(miningAlgo))); +// difficulty is weighted in Bitmark to more meaningfully compare relative values of competing chains +// boolean for weighted / unweighted -------v + obj.push_back(Pair("difficulty", (double)GetDifficulty(NULL,miningAlgo,true,true))); +// sdifficulty: the "simple", unweighted difficulty + obj.push_back(Pair("sdifficulty", (double)GetDifficulty(NULL,miningAlgo,false,true))); + obj.push_back(Pair("sdifficulty SCRYPT", (double)GetDifficulty(NULL,ALGO_SCRYPT,false,true))); + obj.push_back(Pair("sdifficulty SHA256D", (double)GetDifficulty(NULL,ALGO_SHA256D,false,true))); + obj.push_back(Pair("sdifficulty YESCRYPT", (double)GetDifficulty(NULL,ALGO_YESCRYPT,false,true))); + obj.push_back(Pair("sdifficulty ARGON2", (double)GetDifficulty(NULL,ALGO_ARGON2,false,true))); + obj.push_back(Pair("sdifficulty X17", (double)GetDifficulty(NULL,ALGO_X17,false,true))); + obj.push_back(Pair("sdifficulty LYRA2REv2", (double)GetDifficulty(NULL,ALGO_LYRA2REv2,false,true))); + obj.push_back(Pair("sdifficulty EQUIHASH", (double)GetDifficulty(NULL,ALGO_EQUIHASH,false,true))); + obj.push_back(Pair("sdifficulty CRYPTONIGHT", (double)GetDifficulty(NULL,ALGO_CRYPTONIGHT,false,true))); + obj.push_back(Pair("difficulty SCRYPT", (double)GetDifficulty(pindex,ALGO_SCRYPT))); obj.push_back(Pair("difficulty SHA256D", (double)GetDifficulty(pindex,ALGO_SHA256D))); obj.push_back(Pair("difficulty YESCRYPT", (double)GetDifficulty(pindex,ALGO_YESCRYPT))); diff --git a/src/version.h b/src/version.h index a80b594ce2..7d3e6b11c9 100644 --- a/src/version.h +++ b/src/version.h @@ -13,6 +13,8 @@ // client versioning // +// 90700 +// 90701x static const int CLIENT_VERSION = 1000000 * CLIENT_VERSION_MAJOR + 10000 * CLIENT_VERSION_MINOR @@ -27,7 +29,8 @@ extern const std::string CLIENT_DATE; // network protocol versioning // -static const int PROTOCOL_VERSION = 70002; +// Bump up to 70003 to easily discriminate earlier versions via DNS Seeder +static const int PROTOCOL_VERSION = 70003; // intial proto version, to be increased after version/verack negotiation static const int INIT_PROTO_VERSION = 209; From d4f2919fb990b138dd7cd8f9b4ac142482fe4a73 Mon Sep 17 00:00:00 2001 From: dbkeys Date: Sun, 24 Jun 2018 17:24:31 -0700 Subject: [PATCH 09/14] Additional Fixed Seed Node (uk.bitmark.one) 139.162.232.242 0x8BA2E8F2 --- src/chainparams.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 415822652f..7fccc17b0a 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -32,7 +32,8 @@ unsigned int pnSeed[] = 0x2D2141A1, // us.bitmark.io IP = 45.33.65.161 joe 0xCC447A12, // tx.bitmark.io IP = 204.68.122.18 tex 0xCC447A07, // seed.bitmark.mx IP = 204.68.122.7 jules - 0xCC447A0B // one.zmark.org IP = 204.68.122.11 per + 0xCC447A0B, // one.zmark.org IP = 204.68.122.11 per + 0x8BA2E8F2 // uk.bitmark.one IP = 139.162.232.242 jim }; class CMainParams : public CChainParams { From 1e930248391c24e7ca468233b221f0901ec5c7f6 Mon Sep 17 00:00:00 2001 From: Andrew K Date: Wed, 27 Jun 2018 16:11:04 +0000 Subject: [PATCH 10/14] fix rpc mining info --- README.md | 1 + src/main.cpp | 4 ++-- src/miner.cpp | 8 ++++---- src/rpcblockchain.cpp | 4 ++-- src/rpcmining.cpp | 6 ++---- src/rpcmisc.cpp | 2 +- src/rpcserver.h | 2 +- 7 files changed, 13 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 06b252a7cd..296fbde0b1 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ Bitmark aims to be a relatively stable, user focused crypto currency, which refi * [Documentation and Plan](https://github.com/project-bitmark/bitmark/wiki) * [Discussion and Updates](https://bitcointalk.org/index.php?topic=660544.0) * [Block Explorer](http://explorer.bitmark.co) +* [Testnet Explorer](http://explorer.bitmark.co/testnet) ## Getting Bitmark diff --git a/src/main.cpp b/src/main.cpp index 78f3a14d03..b50979dd41 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2258,12 +2258,12 @@ bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, C } } - int64_t block_value_needed = GetBlockValue(pindex, nFees); + int64_t block_value_needed = GetBlockValue(pindex, nFees, false); if (block.vtx[0].GetValueOut() > block_value_needed) return state.DoS(100, error("ConnectBlock() : coinbase pays too much (actual=%d vs limit=%d)", - block.vtx[0].GetValueOut(), GetBlockValue(pindex, nFees)), + block.vtx[0].GetValueOut(), GetBlockValue(pindex, nFees, false)), REJECT_INVALID, "bad-cb-amount"); if (block.vtx[0].GetValueOut() < block_value_needed) { diff --git a/src/miner.cpp b/src/miner.cpp index e039ac7d89..5bad5585f9 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -391,7 +391,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) indexDummy.pprev = pindexPrev; indexDummy.nHeight = pindexPrev->nHeight + 1; - pblock->vtx[0].vout[0].nValue = GetBlockValue(&indexDummy, nFees); + pblock->vtx[0].vout[0].nValue = GetBlockValue(&indexDummy, nFees, false); CCoinsViewCache viewNew(*pcoinsTip, true); @@ -686,6 +686,9 @@ void static BitmarkMiner(CWallet *pwallet) break; } } + + pblock->nNonce256 = (CBigNum(pblock->nNonce256) + 1).getuint256(); + nHashesDone += 1; } else while(true) { @@ -760,9 +763,6 @@ void static BitmarkMiner(CWallet *pwallet) if (pindexPrev != chainActive.Tip()) break; - if (miningAlgo==ALGO_EQUIHASH) { - pblock->nNonce256 = (CBigNum(pblock->nNonce256) + 1).getuint256(); - } // Update nTime every few seconds UpdateTime(*pblock, pindexPrev); nBlockTime = ByteReverse(pblock->nTime); diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 60ca606dd8..99884f132b 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -241,7 +241,7 @@ double GetMoneySupply (const CBlockIndex* blockindex, int algo) { return ((double)blockindex->nMoneySupply)/100000000.; } -double GetBlockReward (CBlockIndex * blockindex, int algo) { +double GetBlockReward (CBlockIndex * blockindex, int algo, bool noScale) { if (blockindex == NULL) { if (chainActive.Tip() == NULL) return 0.; @@ -260,7 +260,7 @@ double GetBlockReward (CBlockIndex * blockindex, int algo) { CBlockIndex indexDummy(*pblock); indexDummy.pprev = blockindex; indexDummy.nHeight = blockindex->nHeight + 1; - return ((double)GetBlockValue(&indexDummy,0))/100000000.; + return ((double)GetBlockValue(&indexDummy,0,noScale))/100000000.; } diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index 6899a62e05..4f83b17fda 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -331,13 +331,11 @@ Value getmininginfo(const Array& params, bool fHelp) obj.push_back(Pair("blocks", (int)chainActive.Height())); obj.push_back(Pair("currentblocksize", (uint64_t)nLastBlockSize)); obj.push_back(Pair("currentblocktx", (uint64_t)nLastBlockTx)); - obj.push_back(Pair("reward_next", ValueFromAmount(GetBlockReward(chainActive.Tip(),miningAlgo)*100000000.))); - obj.push_back(Pair("reward_max", ValueFromAmount(GetBlockValue(chainActive.Tip(),miningAlgo,true)))); + obj.push_back(Pair("reward_next", ValueFromAmount(GetBlockReward(chainActive.Tip(),miningAlgo,false)*100000000.))); + obj.push_back(Pair("reward_max", ValueFromAmount(GetBlockReward(chainActive.Tip(),miningAlgo,true)*100000000.))); obj.push_back(Pair("pow_algo_id", miningAlgo)); obj.push_back(Pair("pow_algo",GetAlgoName(miningAlgo))); //obj.push_back(Pair("hashrate_4max_reward", (uint64_t)35000000000)); - obj.push_back(Pair("pow_algo_id", miningAlgo)); - obj.push_back(Pair("pow_algo",GetAlgoName(miningAlgo))); // difficulty is weighted in Bitmark to more meaningfully compare relative values of competing chains // boolean for weighted / unweighted -------v obj.push_back(Pair("difficulty", (double)GetDifficulty(NULL,miningAlgo,true,true))); diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 203cdd1443..908a3af219 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -502,7 +502,7 @@ Value getblockreward(const Array& params, bool fHelp) { } Object obj; - obj.push_back(Pair("block reward",(double)GetBlockReward(blockindex,algo))); + obj.push_back(Pair("block reward",(double)GetBlockReward(blockindex,algo,false))); return obj; } diff --git a/src/rpcserver.h b/src/rpcserver.h index dc647935c5..547ecc725c 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -106,7 +106,7 @@ extern double GetDifficulty(const CBlockIndex* blockindex = NULL, const int algo extern double GetPeakHashrate(const CBlockIndex* blockindex = NULL, const int algo = 0); extern double GetCurrentHashrate(const CBlockIndex* blockindex = NULL, const int algo = 0); extern double GetMoneySupply(const CBlockIndex* blockindex = NULL, const int algo = -1); -extern double GetBlockReward(CBlockIndex* blockindex = NULL, const int algo = 0); +extern double GetBlockReward(CBlockIndex* blockindex = NULL, const int algo = 0, const bool noScale = false); extern int GetNBlocksUpdateSSF(const CBlockIndex* blockindex = NULL, const int algo = 0); extern double GetAverageBlockSpacing(const CBlockIndex * blockindex = NULL, const int algo = -1, const int averagingInterval = 24); extern std::string HexBits(unsigned int nBits); From 589a618f2238a129e2ae022c3d4087a8ef971bab Mon Sep 17 00:00:00 2001 From: Andrew K Date: Wed, 27 Jun 2018 17:04:19 +0000 Subject: [PATCH 11/14] change default spacing interval --- src/rpcserver.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcserver.h b/src/rpcserver.h index 547ecc725c..caff029422 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -108,7 +108,7 @@ extern double GetCurrentHashrate(const CBlockIndex* blockindex = NULL, const int extern double GetMoneySupply(const CBlockIndex* blockindex = NULL, const int algo = -1); extern double GetBlockReward(CBlockIndex* blockindex = NULL, const int algo = 0, const bool noScale = false); extern int GetNBlocksUpdateSSF(const CBlockIndex* blockindex = NULL, const int algo = 0); -extern double GetAverageBlockSpacing(const CBlockIndex * blockindex = NULL, const int algo = -1, const int averagingInterval = 24); +extern double GetAverageBlockSpacing(const CBlockIndex * blockindex = NULL, const int algo = -1, const int averagingInterval = 25); extern std::string HexBits(unsigned int nBits); extern std::string HelpRequiringPassphrase(); extern std::string HelpExampleCli(std::string methodname, std::string args); From 38efeaebb23f5fef6ee60f13f99f788c44fdc941 Mon Sep 17 00:00:00 2001 From: John Fremlin Date: Tue, 28 Nov 2017 23:54:20 -0500 Subject: [PATCH 12/14] change fd limit --- src/test/fork_tests/init.sh | 6 +++--- src/util.cpp | 27 ++++++++++++++++++++++----- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/test/fork_tests/init.sh b/src/test/fork_tests/init.sh index 0f2a913ff0..ebd3d200b6 100755 --- a/src/test/fork_tests/init.sh +++ b/src/test/fork_tests/init.sh @@ -2,12 +2,12 @@ set -e +datadir="$(pwd)/.bitmark" + set +e -bitmark-cli stop +bitmark-cli -datadir="$datadir" stop set -e -datadir="$(pwd)/.bitmark" -echo "Using datadir $datadir" rm -rf "$datadir" mkdir -p "$datadir" cp bitmark.conf "$datadir" diff --git a/src/util.cpp b/src/util.cpp index 04dd344d10..5bca5db562 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -1115,24 +1115,41 @@ bool TruncateFile(FILE *file, unsigned int length) { #endif } -// this function tries to raise the file descriptor limit to the requested number. -// It returns the actual file descriptor limit (which may be more or less than nMinFD) +/** + * this function tries to raise the file descriptor limit to the most that we can support. + * It returns the actual file descriptor limit (which may be more or less than nMinFD). + */ int RaiseFileDescriptorLimit(int nMinFD) { #if defined(WIN32) return 2048; #else struct rlimit limitFD; if (getrlimit(RLIMIT_NOFILE, &limitFD) != -1) { + // first request at least the amount passed in if (limitFD.rlim_cur < (rlim_t)nMinFD) { limitFD.rlim_cur = nMinFD; if (limitFD.rlim_cur > limitFD.rlim_max) limitFD.rlim_cur = limitFD.rlim_max; setrlimit(RLIMIT_NOFILE, &limitFD); - getrlimit(RLIMIT_NOFILE, &limitFD); } - return limitFD.rlim_cur; + // then try to raise to the max we can + if (limitFD.rlim_cur < limitFD.rlim_max) { + limitFD.rlim_cur = limitFD.rlim_max; + setrlimit(RLIMIT_NOFILE, &limitFD); + } + + if (getrlimit(RLIMIT_NOFILE, &limitFD) != -1) { + if (limitFD.rlim_cur < (rlim_t)nMinFD) { + LogPrintf("RaiseFileDescriptorLimit: could not raise limit to %lu fds, only %lu\n", + (unsigned long)nMinFD, + (unsigned long)limitFD.rlim_cur); + } + return limitFD.rlim_cur; + } } - return nMinFD; // getrlimit failed, assume it's fine + LogPrintf("RaiseFileDescriptorLimit error: getrlimit(RLIMIT_NOFILE) returned %s\n", strerror(errno)); + + return nMinFD; // getrlimit failed, try to proceed #endif } From dc45b137ddb908eab5bdfd6761b1ca714940abe9 Mon Sep 17 00:00:00 2001 From: akrmn Date: Sun, 1 Jul 2018 19:19:55 +0200 Subject: [PATCH 13/14] prepare for minor release --- src/clientversion.h | 2 +- src/rpcmining.cpp | 4 ++-- src/rpcserver.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/clientversion.h b/src/clientversion.h index 2f62104010..e9201819c3 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -12,7 +12,7 @@ #define CLIENT_VERSION_MAJOR 0 #define CLIENT_VERSION_MINOR 9 #define CLIENT_VERSION_REVISION 7 -#define CLIENT_VERSION_BUILD 2 +#define CLIENT_VERSION_BUILD 1 // Set to true for release, false for prerelease (rc: release candidate) or test build #define CLIENT_VERSION_IS_RELEASE false diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index 4f83b17fda..26b90538a4 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -843,14 +843,14 @@ Value getauxblock(const Array& params, bool fHelp) assert(params.size() == 2); uint256 hash; const char * hash_str = params[0].get_str().c_str(); - LogPrintf("getauxblock hash_str = %s\n",hash_str); + if (fDebug) LogPrintf("getauxblock hash_str = %s\n",hash_str); hash.SetHex(params[0].get_str()); const std::map::iterator mit = mapNewBlock.find(hash); if (strlen(hash_str)>0 && mit == mapNewBlock.end()) throw JSONRPCError(RPC_INVALID_PARAMETER, "block hash unknown"); CBlock& block = *mit->second; const char * block_str = params[1].get_str().c_str(); - LogPrintf("getauxblock block_str = %s\n",block_str); + if (fDebug) LogPrintf("getauxblock block_str = %s\n",block_str); const std::vector vchAuxPow = ParseHex(params[1].get_str()); CDataStream ss(vchAuxPow, SER_GETHASH, PROTOCOL_VERSION); CAuxPow pow; diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index 134305aaff..615b682dcf 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -886,8 +886,8 @@ void ServiceConnection(AcceptedConnection *conn) conn->stream() << HTTPReply(HTTP_UNAUTHORIZED, "", false) << std::flush; break; } - if (mapHeaders["connection"] == "close") - fRun = false; + if (mapHeaders["connection"] == "close" || (!GetBoolArg("-rpckeepalive", true))) + fRun = false; JSONRequest jreq; try From e9cf8003d8b288da7ccbf78636a1279e2fa5e8df Mon Sep 17 00:00:00 2001 From: akrmn Date: Tue, 3 Jul 2018 22:47:33 +0200 Subject: [PATCH 14/14] algo as miningalgo alias for conf --- configure.ac | 2 +- src/clientversion.h | 2 +- src/equihash.cpp | 2 +- src/rpcmisc.cpp | 5 +++++ src/util.cpp | 18 ++++++++++++++---- 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index 64e184bcab..9214c251bf 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.60]) define(_CLIENT_VERSION_MAJOR, 0) define(_CLIENT_VERSION_MINOR, 9) define(_CLIENT_VERSION_REVISION, 7) -define(_CLIENT_VERSION_BUILD, 1) +define(_CLIENT_VERSION_BUILD, 2) define(_CLIENT_VERSION_IS_RELEASE, true) define(_COPYRIGHT_YEAR, 2018) AC_INIT([Bitmark Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[info@bitmark.org],[bitmark]) diff --git a/src/clientversion.h b/src/clientversion.h index e9201819c3..2f62104010 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -12,7 +12,7 @@ #define CLIENT_VERSION_MAJOR 0 #define CLIENT_VERSION_MINOR 9 #define CLIENT_VERSION_REVISION 7 -#define CLIENT_VERSION_BUILD 1 +#define CLIENT_VERSION_BUILD 2 // Set to true for release, false for prerelease (rc: release candidate) or test build #define CLIENT_VERSION_IS_RELEASE false diff --git a/src/equihash.cpp b/src/equihash.cpp index cb5c521442..3f5192e43d 100644 --- a/src/equihash.cpp +++ b/src/equihash.cpp @@ -705,7 +705,7 @@ bool Equihash::IsValidSolution(const eh_HashState& base_state, std::vector< return false; } - LogPrintf("good solution size\n"); + //LogPrintf("good solution size\n"); std::vector> X; X.reserve(1 << K); diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 908a3af219..870c47af04 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -73,6 +73,11 @@ Value getinfo(const Array& params, bool fHelp) proxyType proxy; GetProxy(NET_IPV4, proxy); + if (!confAlgoIsSet) { + miningAlgo = GetArg("-miningalgo", miningAlgo); + confAlgoIsSet = true; + } + Object obj; obj.push_back(Pair("version", (int)CLIENT_VERSION)); obj.push_back(Pair("protocolversion",(int)PROTOCOL_VERSION)); diff --git a/src/util.cpp b/src/util.cpp index 5bca5db562..0f7a275cf0 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -472,6 +472,7 @@ void ParseParameters(int argc, const char* const argv[]) strValue = str.substr(is_index+1); str = str.substr(0, is_index); } + if (fDebug) LogPrintf("str = %s\n",str.c_str()); #ifdef WIN32 boost::to_lower(str); if (boost::algorithm::starts_with(str, "/")) @@ -479,7 +480,12 @@ void ParseParameters(int argc, const char* const argv[]) #endif if (str[0] != '-') break; - + + if (!str.compare(std::string("-algo"))) { + if (fDebug) LogPrintf("set algo to miningalgo"); + str = std::string("-miningalgo"); + } + mapArgs[str] = strValue; mapMultiArgs[str].push_back(strValue); } @@ -1033,9 +1039,13 @@ void ReadConfigFile(map& mapSettingsRet, string strKey = string("-") + it->string_key; if (mapSettingsRet.count(strKey) == 0) { - mapSettingsRet[strKey] = it->value[0]; - // interpret nofoo=1 as foo=0 (and nofoo=0 as foo=1) as long as foo not set) - InterpretNegativeSetting(strKey, mapSettingsRet); + if (!strKey.compare(string("-algo"))) { + if (fDebug) LogPrintf("set algo to miningalgo"); + strKey = string("-miningalgo"); + } + mapSettingsRet[strKey] = it->value[0]; + // interpret nofoo=1 as foo=0 (and nofoo=0 as foo=1) as long as foo not set) + InterpretNegativeSetting(strKey, mapSettingsRet); } mapMultiSettingsRet[strKey].push_back(it->value[0]); }