refactor: Convert ChainstateRole enum to struct

Change ChainstateRole parameter passed to wallets and indexes. Wallets and
indexes need to know whether chainstate is historical and whether it is fully
validated. They should not be aware of the assumeutxo snapshot validation
process.
This commit is contained in:
Ryan Ofsky
2025-06-18 09:51:34 -04:00
parent 352ad27fc1
commit 4dfe383912
26 changed files with 130 additions and 79 deletions

View File

@@ -5,11 +5,14 @@
#include <chain.h>
#include <interfaces/chain.h>
#include <kernel/chain.h>
#include <kernel/types.h>
#include <sync.h>
#include <uint256.h>
class CBlock;
using kernel::ChainstateRole;
namespace kernel {
interfaces::BlockInfo MakeBlockInfo(const CBlockIndex* index, const CBlock* data)
{
@@ -25,14 +28,15 @@ interfaces::BlockInfo MakeBlockInfo(const CBlockIndex* index, const CBlock* data
info.data = data;
return info;
}
} // namespace kernel
std::ostream& operator<<(std::ostream& os, const ChainstateRole& role) {
switch(role) {
case ChainstateRole::NORMAL: os << "normal"; break;
case ChainstateRole::ASSUMEDVALID: os << "assumedvalid"; break;
case ChainstateRole::BACKGROUND: os << "background"; break;
default: os.setstate(std::ios_base::failbit);
if (!role.validated) {
os << "assumedvalid";
} else if (role.historical) {
os << "background";
} else {
os << "normal";
}
return os;
}
} // namespace kernel