| 113 | } |
| 114 | |
| 115 | bool CBlockTreeDB::WriteBlockIndex(const CDiskBlockIndex& blockindex) |
| 116 | { |
| 117 | |
| 118 | auto const &hash = blockindex.GetBlockHash(); |
| 119 | if (blockindex.IsProofOfStake()) { |
| 120 | if (blockindex.hashProofOfStake == 0) { |
| 121 | uint256 hashProofOfStake; |
| 122 | if (stake->GetProof(hash, hashProofOfStake)) { |
| 123 | CDiskBlockIndex blockindexFixed(&blockindex); |
| 124 | blockindexFixed.hashProofOfStake = hashProofOfStake; |
| 125 | return Write(make_pair(DB_BLOCK_INDEX, hash), blockindexFixed); |
| 126 | } else { |
| 127 | # if 0 |
| 128 | LogPrint("debug", "%s: zero stake block %s", __func__, hash.GetHex()); |
| 129 | # else |
| 130 | return error("%s: zero stake (block %s)", __func__, hash.GetHex()); |
| 131 | # endif |
| 132 | } |
| 133 | } |
| 134 | # if 0 |
| 135 | } else if (!CheckProofOfWork(hash, blockindex.nBits, Params().GetConsensus())) { |
| 136 | LogPrint("debug", "%s: bad work block %d %d %s", __func__, blockindex.nBits, blockindex.nHeight, hash.GetHex()); //return error("%s: invalid proof of work: %d %d %s", __func__, blockindex.nBits, blockindex.nHeight, hash.GetHex()); |
| 137 | # endif |
| 138 | } |
| 139 | return Write(make_pair(DB_BLOCK_INDEX, hash), blockindex); |
| 140 | } |
| 141 | |
| 142 | bool CBlockTreeDB::WriteBlockFileInfo(int nFile, const CBlockFileInfo& info) |
| 143 | { |
no test coverage detected