testing the share feature
parent
6b7c02d773
commit
c285366113
|
@ -4680,7 +4680,7 @@ void BitcoinMiner(CWallet *pwallet, CBlockProvider *block_provider)
|
|||
|
||||
// Primecoin: mine for prime chain
|
||||
unsigned int nProbableChainLength;
|
||||
if (MineProbablePrimeChain(*pblock, mpzFixedMultiplier, fNewBlock, nTriedMultiplier, nProbableChainLength, nTests, nPrimesHit, nChainsHit, mpzHash, nPrimorialMultiplier, nSieveGenTime, pindexPrev))
|
||||
if (MineProbablePrimeChain(*pblock, mpzFixedMultiplier, fNewBlock, nTriedMultiplier, nProbableChainLength, nTests, nPrimesHit, nChainsHit, mpzHash, nPrimorialMultiplier, nSieveGenTime, pindexPrev, block_provider != NULL))
|
||||
{
|
||||
SetThreadPriority(THREAD_PRIORITY_NORMAL);
|
||||
if (block_provider == NULL)
|
||||
|
|
|
@ -196,8 +196,8 @@ public:
|
|||
strParams.push_back(data_hex);
|
||||
json_spirit::Array params = RPCConvertValues(strMethod, strParams);
|
||||
json_spirit::Object reply_obj = CallRPC(strMethod, params, _server, _port); //submit
|
||||
const json_spirit::Value& result_val = find_value(reply_obj, "result");
|
||||
std::cout << "[WORKER" << _thread_id << "] share submitted -> " << (result_val.get_bool() ? "ACCEPTED" : "REJECTED") << " with MerkleRoot: " << pblock->hashMerkleRoot.ToString().c_str() << std::endl;
|
||||
int retval = find_value(reply_obj, "result").get_int();
|
||||
std::cout << "[WORKER" << _thread_id << "] share submitted -> " << (retval == 0 ? "REJECTED" : retval < 0 ? "STALE" : retval == 1 ? "BLOCK" : "SHARE") << " with MerkleRoot: " << pblock->hashMerkleRoot.ToString().c_str() << std::endl;
|
||||
}
|
||||
private:
|
||||
CBlock* _pblock;
|
||||
|
|
|
@ -700,7 +700,7 @@ static bool ProbableCunninghamChainTestFast(const mpz_class& n, bool fSophieGerm
|
|||
// Return value:
|
||||
// true - Probable prime chain found (one of nChainLength meeting target)
|
||||
// false - prime chain too short (none of nChainLength meeting target)
|
||||
static bool ProbablePrimeChainTestFast(const mpz_class& mpzPrimeChainOrigin, CPrimalityTestParams& testParams)
|
||||
static bool ProbablePrimeChainTestFast(const mpz_class& mpzPrimeChainOrigin, CPrimalityTestParams& testParams, bool poolmining)
|
||||
{
|
||||
const unsigned int nBits = testParams.nBits;
|
||||
const unsigned int nCandidateType = testParams.nCandidateType;
|
||||
|
@ -739,14 +739,14 @@ static bool ProbablePrimeChainTestFast(const mpz_class& mpzPrimeChainOrigin, CPr
|
|||
}
|
||||
}
|
||||
|
||||
return (nChainLength >= nBits);
|
||||
return (!poolmining && (nChainLength >= nBits)) || (poolmining && (TargetGetLength(nChainLength) >= POOL_SHARE_MINIMUM));
|
||||
}
|
||||
|
||||
// Sieve for mining
|
||||
boost::thread_specific_ptr<CSieveOfEratosthenes> psieve;
|
||||
|
||||
// Mine probable prime chain of form: n = h * p# +/- 1
|
||||
bool MineProbablePrimeChain(CBlock& block, mpz_class& mpzFixedMultiplier, bool& fNewBlock, unsigned int& nTriedMultiplier, unsigned int& nProbableChainLength, unsigned int& nTests, unsigned int& nPrimesHit, unsigned int& nChainsHit, mpz_class& mpzHash, unsigned int nPrimorialMultiplier, int64& nSieveGenTime, CBlockIndex* pindexPrev)
|
||||
bool MineProbablePrimeChain(CBlock& block, mpz_class& mpzFixedMultiplier, bool& fNewBlock, unsigned int& nTriedMultiplier, unsigned int& nProbableChainLength, unsigned int& nTests, unsigned int& nPrimesHit, unsigned int& nChainsHit, mpz_class& mpzHash, unsigned int nPrimorialMultiplier, int64& nSieveGenTime, CBlockIndex* pindexPrev, bool poolmining)
|
||||
{
|
||||
CSieveOfEratosthenes *lpsieve;
|
||||
nProbableChainLength = 0;
|
||||
|
@ -840,7 +840,7 @@ bool MineProbablePrimeChain(CBlock& block, mpz_class& mpzFixedMultiplier, bool&
|
|||
}
|
||||
mpzChainOrigin = mpzHashMultiplier * nTriedMultiplier;
|
||||
nChainLength = 0;
|
||||
if (ProbablePrimeChainTestFast(mpzChainOrigin, testParams))
|
||||
if (ProbablePrimeChainTestFast(mpzChainOrigin, testParams, poolmining))
|
||||
{
|
||||
mpz_class mpzPrimeChainMultiplier = mpzFixedMultiplier * nTriedMultiplier;
|
||||
CBigNum bnPrimeChainMultiplier;
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
/* POOL ADDON */
|
||||
/**************/
|
||||
|
||||
static const unsigned int POOL_SHARE_MINIMUM = 6;
|
||||
|
||||
class CBlockProvider {
|
||||
public:
|
||||
CBlockProvider() { }
|
||||
|
@ -122,7 +124,7 @@ std::string GetPrimeOriginPrimorialForm(CBigNum& bnPrimeChainOrigin);
|
|||
/********************/
|
||||
|
||||
// Mine probable prime chain of form: n = h * p# +/- 1
|
||||
bool MineProbablePrimeChain(CBlock& block, mpz_class& mpzFixedMultiplier, bool& fNewBlock, unsigned int& nTriedMultiplier, unsigned int& nProbableChainLength, unsigned int& nTests, unsigned int& nPrimesHit, unsigned int& nChainsHit, mpz_class& mpzHash, unsigned int nPrimorialMultiplier, int64& nSieveGenTime, CBlockIndex* pindexPrev);
|
||||
bool MineProbablePrimeChain(CBlock& block, mpz_class& mpzFixedMultiplier, bool& fNewBlock, unsigned int& nTriedMultiplier, unsigned int& nProbableChainLength, unsigned int& nTests, unsigned int& nPrimesHit, unsigned int& nChainsHit, mpz_class& mpzHash, unsigned int nPrimorialMultiplier, int64& nSieveGenTime, CBlockIndex* pindexPrev, bool poolmining);
|
||||
|
||||
// Estimate the probability of primality for a number in a candidate chain
|
||||
double EstimateCandidatePrimeProbability(unsigned int nPrimorialMultiplier, unsigned int nChainPrimeNum);
|
||||
|
|
Loading…
Reference in New Issue