MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / UpdateBlockInfo

Method UpdateBlockInfo

src/node/blockstorage.cpp:939–958  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

937}
938
939void 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
960bool BlockManager::FindUndoPos(BlockValidationState& state, int nFile, FlatFilePos& pos, unsigned int nAddSize)
961{

Callers 2

AcceptBlockMethod · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80

Calls 6

GetSerializeSizeFunction · 0.85
AddBlockMethod · 0.80
sizeMethod · 0.45
resizeMethod · 0.45
GetBlockTimeMethod · 0.45
insertMethod · 0.45

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.64