It was the Bitcointalk forum that inspired us to create Bitcointalksearch.org - Bitcointalk is an excellent site that should be the default page for anybody dealing in cryptocurrency, since it is a virtual gold-mine of data. However, our experience and user feedback led us create our site; Bitcointalk's search is slow, and difficult to get the results you need, because you need to log in first to find anything useful - furthermore, there are rate limiters for their search functionality.
The aim of our project is to create a faster website that yields more results and faster without having to create an account and eliminate the need to log in - your personal data, therefore, will never be in jeopardy since we are not asking for any of your data and you don't need to provide them to use our site with all of its capabilities.
We created this website with the sole purpose of users being able to search quickly and efficiently in the field of cryptocurrency so they will have access to the latest and most accurate information and thereby assisting the crypto-community at large.
unsigned int static GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock)
{
static unsigned int nProofOfWorkLimit = bnProofOfWorkLimit.GetCompact();
#define WINDOW 144
static double kOne = 1.0;
static double kTwoToTheThirtyOne = double(2147483648);
static double kGain = 0.025;
static double kLimiterUp = 1.055;
static double kLimiterDown = double(200) / double(211);
static double kTargetInterval = double(nTargetSpacing);
static int32_t kFilterCoeff[WINDOW] = {
-845859, -459003, -573589, -703227, -848199, -1008841,
-1183669, -1372046, -1573247, -1787578, -2011503, -2243311,
-2482346, -2723079, -2964681, -3202200, -3432186, -3650186,
-3851924, -4032122, -4185340, -4306430, -4389146, -4427786,
-4416716, -4349289, -4220031, -4022692, -3751740, -3401468,
-2966915, -2443070, -1825548, -1110759, -295281, 623307,
1646668, 2775970, 4011152, 5351560, 6795424, 8340274,
9982332, 11717130, 13539111, 15441640, 17417389, 19457954,
21554056, 23695744, 25872220, 28072119, 30283431, 32493814,
34690317, 36859911, 38989360, 41065293, 43074548, 45004087,
46841170, 48573558, 50189545, 51678076, 53028839, 54232505,
55280554, 56165609, 56881415, 57422788, 57785876, 57968085,
57968084, 57785876, 57422788, 56881415, 56165609, 55280554,
54232505, 53028839, 51678076, 50189545, 48573558, 46841170,
45004087, 43074548, 41065293, 38989360, 36859911, 34690317,
32493814, 30283431, 28072119, 25872220, 23695744, 21554057,
19457953, 17417389, 15441640, 13539111, 11717130, 9982332,
8340274, 6795424, 5351560, 4011152, 2775970, 1646668,
623307, -295281, -1110759, -1825548, -2443070, -2966915,
-3401468, -3751740, -4022692, -4220031, -4349289, -4416715,
-4427787, -4389146, -4306430, -4185340, -4032122, -3851924,
-3650186, -3432186, -3202200, -2964681, -2723079, -2482346,
-2243311, -2011503, -1787578, -1573247, -1372046, -1183669,
-1008841, -848199, -703227, -573589, -459003, -845858
};
// Genesis block
if (pindexLast == NULL)
return nProofOfWorkLimit;
bool fUseFilter =
(fTestNet && pindexLast->nHeight>=(DIFF_FILTER_THRESHOLD_TESTNET-1)) ||
(!fTestNet && pindexLast->nHeight>=(DIFF_FILTER_THRESHOLD-1));
int64 nInterval = nFilteredInterval;
int64 nTargetTimespan = nFilteredTargetTimespan;
if ( !fUseFilter ) {
nInterval = nOriginalInterval;
nTargetTimespan = nOriginalTargetTimespan;
}
// Only change once per interval
if ( (fUseFilter && (pindexLast->nHeight+1) % nInterval != 0) ||
(!fUseFilter && (pindexLast->nHeight+1) % 2016 != 0))
{
// Special difficulty rule for testnet:
if (fTestNet)
{
// If the new block's timestamp is more than 2* 10 minutes
// then allow mining of a min-difficulty block.
if (pblock->nTime > pindexLast->nTime + nTargetSpacing*2)
return nProofOfWorkLimit;
else
{
// Return the last non-special-min-difficulty-rules-block
const CBlockIndex* pindex = pindexLast;
while (pindex->pprev && pindex->nHeight % nInterval != 0 && pindex->nBits == nProofOfWorkLimit)
pindex = pindex->pprev;
return pindex->nBits;
}
}
return pindexLast->nBits;
}
double dAdjustmentFactor;
if ( fUseFilter ) {
int32_t vTimeDelta[WINDOW];
size_t idx = 0;
const CBlockIndex *pitr = pindexLast;
for ( ; idx!=WINDOW && pitr && pitr->pprev; ++idx, pitr=pitr->pprev )
vTimeDelta[idx] = (int32_t)(pitr->GetBlockTime() - pitr->pprev->GetBlockTime());
for ( ; idx!=WINDOW; ++idx )
vTimeDelta[idx] = (int32_t)nTargetSpacing;
int64_t vFilteredTime = 0;
for ( idx=0; idxvFilteredTime += (int64_t)kFilterCoeff[idx] * (int64_t)vTimeDelta[idx];
double dFilteredInterval = double(vFilteredTime) / kTwoToTheThirtyOne;
dAdjustmentFactor = kOne - kGain * (dFilteredInterval - kTargetInterval) / kTargetInterval;
if ( dAdjustmentFactor > kLimiterUp ) {
dAdjustmentFactor = kLimiterUp;
}
else if ( dAdjustmentFactor < kLimiterDown ) {
dAdjustmentFactor = kLimiterDown;
}
} else {
// This fixes an issue where a 51% attack can change difficulty at will.
// Go back the full period unless it's the first retarget after genesis.
// Code courtesy of Art Forz
int blockstogoback = nInterval-1;
if ((pindexLast->nHeight+1) != nInterval)
blockstogoback = nInterval;
// Go back by what we want to be 14 days worth of blocks
const CBlockIndex* pindexFirst = pindexLast;
for (int i = 0; pindexFirst && i < blockstogoback; i++)
pindexFirst = pindexFirst->pprev;
assert(pindexFirst);
// Limit adjustment step
int64 nActualTimespan = pindexLast->GetBlockTime() - pindexFirst->GetBlockTime();
printf(" nActualTimespan = %"PRI64d" before bounds\n", nActualTimespan);
if (nActualTimespan < nTargetTimespan/4)
nActualTimespan = nTargetTimespan/4;
if (nActualTimespan > nTargetTimespan*4)
nActualTimespan = nTargetTimespan*4;
dAdjustmentFactor = double(nTargetTimespan) /
double(nActualTimespan);
}
// Retarget
CBigNum bnNew;
bnNew.SetCompact(pindexLast->nBits);
int64 dAdjustmentFactorNumerator;
int64 dAdjustmentFactorDenominator;
DoubleToNumeratorDenominator(dAdjustmentFactor, &dAdjustmentFactorNumerator, &dAdjustmentFactorDenominator);
bnNew *= dAdjustmentFactorDenominator;
bnNew /= dAdjustmentFactorNumerator;
if (bnNew > bnProofOfWorkLimit)
bnNew = bnProofOfWorkLimit;
/// debug print
printf("GetNextWorkRequired RETARGET\n");
printf("dAdjustmentFactor = %g\n", dAdjustmentFactor);
printf("Before: %08x %s\n", pindexLast->nBits, CBigNum().SetCompact(pindexLast->nBits).getuint256().ToString().c_str());
printf("After: %08x %s\n", bnNew.GetCompact(), bnNew.getuint256().ToString().c_str());
return bnNew.GetCompact();
}