| 937 | } |
| 938 | |
| 939 | void BlockManager::UpdateBlockInfo(const CBlock& block, unsigned int nHeight, const FlatFilePos& pos) |
| 940 | { |
| 941 | AssertLockHeld(::cs_main); |
| 942 | // Update the cursor so it points to the last file. |
| 943 | const BlockfileType chain_type{BlockfileTypeForHeight(nHeight)}; |
| 944 | auto& cursor{m_blockfile_cursors[chain_type]}; |
| 945 | if (!cursor || cursor->file_num < pos.nFile) { |
| 946 | m_blockfile_cursors[chain_type] = BlockfileCursor{pos.nFile}; |
| 947 | } |
| 948 | |
| 949 | // Update the file information with the current block. |
| 950 | const unsigned int added_size = ::GetSerializeSize(TX_WITH_WITNESS(block)); |
| 951 | const int nFile = pos.nFile; |
| 952 | if (static_cast<int>(m_blockfile_info.size()) <= nFile) { |
| 953 | m_blockfile_info.resize(nFile + 1); |
| 954 | } |
| 955 | m_blockfile_info[nFile].AddBlock(nHeight, block.GetBlockTime()); |
| 956 | m_blockfile_info[nFile].nSize = std::max(pos.nPos + added_size, m_blockfile_info[nFile].nSize); |
| 957 | m_dirty_fileinfo.insert(nFile); |
| 958 | } |
| 959 | |
| 960 | bool BlockManager::FindUndoPos(BlockValidationState& state, int nFile, FlatFilePos& pos, unsigned int nAddSize) |
| 961 | { |