Reduce memory usage of CBlockIndex

Ported code from https://github.com/zcash/zcash/pull/6192 with various changes needed
for the Hush codebase.
This commit is contained in:
Duke
2023-04-13 23:30:23 -04:00
parent 053e9156a7
commit e8dc755f06
9 changed files with 187 additions and 52 deletions

View File

@@ -124,7 +124,19 @@ int32_t NSPV_setequihdr(struct NSPV_equihdr *hdr,int32_t height)
hdr->nTime = pindex->nTime;
hdr->nBits = pindex->nBits;
hdr->nNonce = pindex->nNonce;
memcpy(hdr->nSolution,&pindex->nSolution[0],sizeof(hdr->nSolution));
auto header = pindex->GetBlockHeader();
// if (pindex->HasSolution()) {
// header.nSolution = nSolution;
// } else {
CDiskBlockIndex dbindex;
if (!pblocktree->ReadDiskBlockIndex(pindex->GetBlockHash(), dbindex)) {
LogPrintf("%s: Failed to read index entry", __func__);
throw std::runtime_error("Failed to read index entry");
}
header.nSolution = dbindex.GetSolution();
// }
memcpy(hdr->nSolution,&header.nSolution[0],sizeof(hdr->nSolution));
return(sizeof(*hdr));
}
return(-1);