}
static CMemoryPool mp(bytesForChainWalkSet, debug, maxMem);
- RainbowChainO* pChain = (RainbowChainO*)mp.Allocate(nFileLen, nAllocatedSize);
+ RainbowChainO* pChain = NULL;
+ if(doRti2Format) {
+ pChain = (RainbowChainO*)mp.Allocate(pReader->GetChainsLeft() * 16, nAllocatedSize);
+ } else {
+ pChain = (RainbowChainO*)mp.Allocate(nFileLen, nAllocatedSize);
+ }
#ifdef _WIN32
if (debug) printf("Allocated %I64u bytes, filelen %lu\n", nAllocatedSize, (unsigned long)nFileLen);
#else
// Load table chunk
if (debug) printf("reading...\n");
- unsigned int nDataRead = 0, nDataToRead = 0;
+ unsigned int nDataRead = 0;
gettimeofday( &tv, NULL );
if ( doRti2Format )
{
- nDataToRead = nAllocatedSize / 16;
- nDataRead = nDataToRead;
- pReader->ReadChains(nDataRead, pChain);
+ nDataRead = nAllocatedSize / 16;
+ if(pReader->GetChainsLeft() <= 0) // No more data
+ break;
+ pReader->ReadChains(nDataRead, (RainbowChain*)pChain);
+
nDataRead *= 8; // Convert from chains read to bytes
}
else
int nRainbowChainCountRead = nDataRead / 16;
+ if(doRti2Format) {
+ nRainbowChainCountRead = nDataRead / 8;
+ }
+
// Verify table chunk
if (!fVerified)
{
// Already finished?
if (!hs.AnyHashLeftWithLen(CChainWalkContext::GetHashLen()))
break;
-
- // finished the current table
- if( doRti2Format && nDataToRead > (nDataRead / 8) )
- {
- delete pReader;
- break;
- }
}
}
else