validation: pass ChainstateRole for validationinterface calls

This allows consumers to decide how to handle events from background or
assumedvalid chainstates.
This commit is contained in:
James O'Beirne
2019-09-23 13:54:21 -04:00
committed by James O'Beirne
parent 1e59acdf17
commit 4d8f4dcb45
19 changed files with 66 additions and 42 deletions

View File

@@ -250,7 +250,7 @@ bool BaseIndex::Rewind(const CBlockIndex* current_tip, const CBlockIndex* new_ti
return true;
}
void BaseIndex::BlockConnected(const std::shared_ptr<const CBlock>& block, const CBlockIndex* pindex)
void BaseIndex::BlockConnected(ChainstateRole role, const std::shared_ptr<const CBlock>& block, const CBlockIndex* pindex)
{
if (!m_synced) {
return;
@@ -296,7 +296,7 @@ void BaseIndex::BlockConnected(const std::shared_ptr<const CBlock>& block, const
}
}
void BaseIndex::ChainStateFlushed(const CBlockLocator& locator)
void BaseIndex::ChainStateFlushed(ChainstateRole role, const CBlockLocator& locator)
{
if (!m_synced) {
return;

View File

@@ -102,9 +102,9 @@ protected:
Chainstate* m_chainstate{nullptr};
const std::string m_name;
void BlockConnected(const std::shared_ptr<const CBlock>& block, const CBlockIndex* pindex) override;
void BlockConnected(ChainstateRole role, const std::shared_ptr<const CBlock>& block, const CBlockIndex* pindex) override;
void ChainStateFlushed(const CBlockLocator& locator) override;
void ChainStateFlushed(ChainstateRole role, const CBlockLocator& locator) override;
/// Initialize internal state from the database and block index.
[[nodiscard]] virtual bool CustomInit(const std::optional<interfaces::BlockKey>& block) { return true; }