This commit is contained in:
jl777
2018-04-13 16:22:27 +03:00
parent 071f1be1f6
commit 2b00bd236c
2 changed files with 17 additions and 11 deletions

View File

@@ -725,23 +725,26 @@ uint32_t komodo_heightstamp(int32_t height)
void komodo_pindex_init(CBlockIndex *pindex,int32_t height)
{
int32_t i,num; uint8_t pubkeys[64][33]; CBlock block;
printf("pindex.%d komodo_pindex_init notary.%d from height.%d\n",pindex->nHeight,pindex->notaryid,height);
if ( pindex->notaryid >= 0 )
return;
pindex->notaryid = -1;
memset(pindex->pubkey33,0,33);
if ( komodo_blockload(block,pindex) == 0 )
if ( pindex->pubkey33[0] != 2 && pindex->pubkey33[0] != 3 )
{
komodo_block2pubkey33(pindex->pubkey33,block);
if ( (pindex->pubkey33[0] == 2 || pindex->pubkey33[0] == 3) && pindex->nHeight >= 0 && (num= komodo_notaries(pubkeys,(int32_t)pindex->nHeight,(uint32_t)pindex->nTime)) > 0 )
memset(pindex->pubkey33,0,33);
if ( komodo_blockload(block,pindex) == 0 )
komodo_block2pubkey33(pindex->pubkey33,block);
}
if ( (pindex->pubkey33[0] == 2 || pindex->pubkey33[0] == 3) && pindex->nHeight >= 0 && (num= komodo_notaries(pubkeys,(int32_t)pindex->nHeight,(uint32_t)pindex->nTime)) > 0 )
{
for (i=0; i<num; i++)
{
for (i=0; i<num; i++)
if ( memcmp(pubkeys[i],pindex->pubkey33,33) == 0 )
{
if ( memcmp(pubkeys[i],pindex->pubkey33,33) == 0 )
{
pindex->notaryid = i;
break;
}
pindex->notaryid = i;
break;
}
}
printf("pindex.%d initialized notary.%d from height.%d\n",pindex->nHeight,pindex->notaryid,height);
}
}

View File

@@ -4157,6 +4157,7 @@ bool static LoadBlockIndexDB()
pindex->BuildSkip();
if (pindex->IsValid(BLOCK_VALID_TREE) && (pindexBestHeader == NULL || CBlockIndexWorkComparator()(pindexBestHeader, pindex)))
pindexBestHeader = pindex;
komodo_pindex_init(pindex,(int32_t)pindex->nHeight);
}
// Load block file info
@@ -4185,6 +4186,7 @@ bool static LoadBlockIndexDB()
if (pindex->nStatus & BLOCK_HAVE_DATA) {
setBlkDataFiles.insert(pindex->nFile);
}
komodo_pindex_init(pindex,(int32_t)pindex->nHeight);
}
for (std::set<int>::iterator it = setBlkDataFiles.begin(); it != setBlkDataFiles.end(); it++)
{
@@ -4220,6 +4222,7 @@ bool static LoadBlockIndexDB()
if (pindex->pprev) {
pindex->pprev->hashAnchorEnd = pindex->hashAnchor;
}
komodo_pindex_init(pindex,(int32_t)pindex->nHeight);
}
// Load pointer to end of best chain