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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user