Merge pull request #616 from patricklodder/1.8-dev-auxpow-version
check block version for aux blocks properly for version warning
This commit is contained in:
commit
5a186d356e
|
@ -1158,6 +1158,11 @@ void CBlockHeader::SetAuxPow(CAuxPow* pow)
|
||||||
auxpow.reset(pow);
|
auxpow.reset(pow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsAuxPowVersion(int nVersion)
|
||||||
|
{
|
||||||
|
return (nVersion == BLOCK_VERSION_AUXPOW_WITH_AUX || nVersion == BLOCK_VERSION_AUXPOW_WITHOUT_AUX);
|
||||||
|
}
|
||||||
|
|
||||||
uint256 static GetOrphanRoot(const uint256& hash)
|
uint256 static GetOrphanRoot(const uint256& hash)
|
||||||
{
|
{
|
||||||
map<uint256, COrphanBlock*>::iterator it = mapOrphanBlocks.find(hash);
|
map<uint256, COrphanBlock*>::iterator it = mapOrphanBlocks.find(hash);
|
||||||
|
@ -2066,10 +2071,9 @@ void static UpdateTip(CBlockIndex *pindexNew) {
|
||||||
{
|
{
|
||||||
int nUpgraded = 0;
|
int nUpgraded = 0;
|
||||||
const CBlockIndex* pindex = chainActive.Tip();
|
const CBlockIndex* pindex = chainActive.Tip();
|
||||||
int nAuxVersion = CBlockHeader::CURRENT_VERSION | (AUXPOW_CHAIN_ID * BLOCK_VERSION_CHAIN_START);
|
|
||||||
for (int i = 0; i < 100 && pindex != NULL; i++)
|
for (int i = 0; i < 100 && pindex != NULL; i++)
|
||||||
{
|
{
|
||||||
if (pindex->nVersion > CBlock::CURRENT_VERSION && pindex->nVersion != nAuxVersion)
|
if (pindex->nVersion > CBlock::CURRENT_VERSION && !IsAuxPowVersion(pindex->nVersion))
|
||||||
++nUpgraded;
|
++nUpgraded;
|
||||||
pindex = pindex->pprev;
|
pindex = pindex->pprev;
|
||||||
}
|
}
|
||||||
|
|
11
src/main.h
11
src/main.h
|
@ -79,6 +79,14 @@ static const int MAX_BLOCKS_IN_TRANSIT_PER_PEER = 128;
|
||||||
/** Timeout in seconds before considering a block download peer unresponsive. */
|
/** Timeout in seconds before considering a block download peer unresponsive. */
|
||||||
static const unsigned int BLOCK_DOWNLOAD_TIMEOUT = 60;
|
static const unsigned int BLOCK_DOWNLOAD_TIMEOUT = 60;
|
||||||
|
|
||||||
|
/** AuxPow Block versions for sanity checks. */
|
||||||
|
/** bare AuxPoW block version which will be modulated further. */
|
||||||
|
static const int BLOCK_VERSION_AUXPOW_BARE = CBlockHeader::CURRENT_VERSION | (AUXPOW_CHAIN_ID * BLOCK_VERSION_CHAIN_START);
|
||||||
|
/** version when AuxPoW exists on the block */
|
||||||
|
static const int BLOCK_VERSION_AUXPOW_WITH_AUX = BLOCK_VERSION_AUXPOW_BARE | BLOCK_VERSION_AUXPOW;
|
||||||
|
/** version when no AuxPoW exists on the block */
|
||||||
|
static const int BLOCK_VERSION_AUXPOW_WITHOUT_AUX = BLOCK_VERSION_AUXPOW_BARE & ~BLOCK_VERSION_AUXPOW;
|
||||||
|
|
||||||
#ifdef USE_UPNP
|
#ifdef USE_UPNP
|
||||||
static const int fHaveUPnP = true;
|
static const int fHaveUPnP = true;
|
||||||
#else
|
#else
|
||||||
|
@ -185,6 +193,9 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
|
||||||
|
|
||||||
void UpdateTime(CBlockHeader& block, const CBlockIndex* pindexPrev);
|
void UpdateTime(CBlockHeader& block, const CBlockIndex* pindexPrev);
|
||||||
|
|
||||||
|
/** Determine whether the block version is modulated with auxpow logic */
|
||||||
|
bool IsAuxPowVersion(int nVersion);
|
||||||
|
|
||||||
/** Create a new block index entry for a given block hash */
|
/** Create a new block index entry for a given block hash */
|
||||||
CBlockIndex * InsertBlockIndex(uint256 hash);
|
CBlockIndex * InsertBlockIndex(uint256 hash);
|
||||||
/** Verify a signature */
|
/** Verify a signature */
|
||||||
|
|
Loading…
Reference in a new issue