diff options
author | Ryan Ofsky <ryan@ofsky.org> | 2022-01-13 07:55:18 -0500 |
---|---|---|
committer | Ryan Ofsky <ryan@ofsky.org> | 2022-07-18 13:39:55 -0500 |
commit | a0b5b4ae5a24536d333cbce2ea584f2d935c651f (patch) | |
tree | 71fbd31c68142216d20ff3414d9360feee5baa3e /src/kernel/chain.cpp | |
parent | 8d4a058ac421da838422da127aac71abf83a49f6 (diff) | |
download | bitcoin-a0b5b4ae5a24536d333cbce2ea584f2d935c651f.tar.xz |
interfaces, refactor: Add more block information to block connected notifications
Add new interfaces::BlockInfo struct to be able to pass extra block
information (file and undo information) to indexes which they are
updated to use high level interfaces::Chain notifications.
This commit does not change behavior in any way.
Diffstat (limited to 'src/kernel/chain.cpp')
-rw-r--r-- | src/kernel/chain.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/kernel/chain.cpp b/src/kernel/chain.cpp new file mode 100644 index 0000000000..82e77125d7 --- /dev/null +++ b/src/kernel/chain.cpp @@ -0,0 +1,26 @@ +// Copyright (c) 2022 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include <chain.h> +#include <interfaces/chain.h> +#include <sync.h> +#include <uint256.h> + +class CBlock; + +namespace kernel { +interfaces::BlockInfo MakeBlockInfo(const CBlockIndex* index, const CBlock* data) +{ + interfaces::BlockInfo info{index ? *index->phashBlock : uint256::ZERO}; + if (index) { + info.prev_hash = index->pprev ? index->pprev->phashBlock : nullptr; + info.height = index->nHeight; + LOCK(::cs_main); + info.file_number = index->nFile; + info.data_pos = index->nDataPos; + } + info.data = data; + return info; +} +} // namespace kernel |