Store block on disk. If dbp is non-nullptr, the file is known to already reside on disk */
| 3678 | |
| 3679 | /** Store block on disk. If dbp is non-nullptr, the file is known to already reside on disk */ |
| 3680 | static CDiskBlockPos SaveBlockToDisk(const CBlock& block, int nHeight, const CChainParams& chainparams, const CDiskBlockPos* dbp) { |
| 3681 | unsigned int nBlockSize = ::GetSerializeSize(block, SER_DISK, CLIENT_VERSION); |
| 3682 | CDiskBlockPos blockPos; |
| 3683 | if (dbp != nullptr) |
| 3684 | blockPos = *dbp; |
| 3685 | if (!FindBlockPos(blockPos, nBlockSize+8, nHeight, block.GetBlockTime(), dbp != nullptr)) { |
| 3686 | error("%s: FindBlockPos failed", __func__); |
| 3687 | return CDiskBlockPos(); |
| 3688 | } |
| 3689 | if (dbp == nullptr) { |
| 3690 | if (!WriteBlockToDisk(block, blockPos, chainparams.MessageStart())) { |
| 3691 | AbortNode("Failed to write block"); |
| 3692 | return CDiskBlockPos(); |
| 3693 | } |
| 3694 | } |
| 3695 | return blockPos; |
| 3696 | } |
| 3697 | |
| 3698 | /** Store block on disk. If dbp is non-nullptr, the file is known to already reside on disk */ |
| 3699 | bool CChainState::AcceptBlock(const std::shared_ptr<const CBlock>& pblock, CValidationState& state, const CChainParams& chainparams, CBlockIndex** ppindex, bool fRequested, const CDiskBlockPos* dbp, bool* fNewBlock) |
no test coverage detected