Files
thehub/libs/interfaces/validationinterface.cpp
T

97 lines
3.0 KiB
C++
Raw Permalink Normal View History

2018-02-15 18:06:38 +01:00
/*
* This file is part of the Flowee project
* Copyright (C) 2009-2010 Satoshi Nakamoto
* Copyright (C) 2009-2014 The Bitcoin Core developers
* Copyright (C) 2017-2021 Tom Zander <tom@flowee.org>
2018-02-15 18:06:38 +01:00
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "validationinterface.h"
ValidationInterfaceBroadcaster &ValidationNotifier() {
static ValidationInterfaceBroadcaster s_instance;
return s_instance;
}
2021-02-18 16:03:01 +01:00
void ValidationInterfaceBroadcaster::syncTransaction(const CTransaction &tx)
2018-02-15 18:06:38 +01:00
{
2021-02-18 16:03:01 +01:00
for (auto i : m_listeners) i->syncTransaction(tx);
2018-02-15 18:06:38 +01:00
}
2021-02-18 16:03:01 +01:00
void ValidationInterfaceBroadcaster::syncTx(const Tx &tx)
2018-02-15 18:06:38 +01:00
{
2021-02-18 16:03:01 +01:00
for (auto i : m_listeners) i->syncTx(tx);
2018-02-15 18:06:38 +01:00
}
2021-11-02 09:36:09 +01:00
void ValidationInterfaceBroadcaster::syncAllTransactionsInBlock(const MutableBlock *pblock)
2018-02-15 18:06:38 +01:00
{
2021-02-18 16:03:01 +01:00
for (auto i : m_listeners) i->syncAllTransactionsInBlock(pblock);
2018-02-15 18:06:38 +01:00
}
2021-11-02 10:18:24 +01:00
void ValidationInterfaceBroadcaster::syncAllTransactionsInBlock(const Block &block, CBlockIndex *index)
2018-02-15 18:06:38 +01:00
{
2021-02-18 16:03:01 +01:00
for (auto i : m_listeners) i->syncAllTransactionsInBlock(block, index);
2018-02-15 18:06:38 +01:00
}
2021-02-18 16:03:01 +01:00
void ValidationInterfaceBroadcaster::setBestChain(const CBlockLocator &locator)
2018-02-15 18:06:38 +01:00
{
2021-02-18 16:03:01 +01:00
for (auto i : m_listeners) i->setBestChain(locator);
2018-02-15 18:06:38 +01:00
}
2021-02-18 16:03:01 +01:00
void ValidationInterfaceBroadcaster::updatedTransaction(const uint256 &hash)
2018-02-15 18:06:38 +01:00
{
2021-02-18 16:03:01 +01:00
for (auto i : m_listeners) i->updatedTransaction(hash);
2018-02-15 18:06:38 +01:00
}
2021-02-18 16:03:01 +01:00
void ValidationInterfaceBroadcaster::inventory(const uint256 &hash)
2018-02-15 18:06:38 +01:00
{
2021-02-18 16:03:01 +01:00
for (auto i : m_listeners) i->inventory(hash);
2018-02-15 18:06:38 +01:00
}
2021-02-18 16:03:01 +01:00
void ValidationInterfaceBroadcaster::resendWalletTransactions(int64_t nBestBlockTime)
2018-02-15 18:06:38 +01:00
{
2021-02-18 16:03:01 +01:00
for (auto i : m_listeners) i->resendWalletTransactions(nBestBlockTime);
2018-02-15 18:06:38 +01:00
}
2021-02-18 16:03:01 +01:00
void ValidationInterfaceBroadcaster::doubleSpendFound(const Tx &first, const Tx &duplicate)
2018-03-25 13:55:48 +02:00
{
2021-02-18 16:03:01 +01:00
for (auto i : m_listeners) i->doubleSpendFound(first, duplicate);
2018-03-25 13:55:48 +02:00
}
2021-02-18 16:03:01 +01:00
void ValidationInterfaceBroadcaster::doubleSpendFound(const Tx &txInMempool, const DoubleSpendProof &proof)
2019-09-02 23:33:33 +02:00
{
2021-02-18 16:03:01 +01:00
for (auto i : m_listeners) i->doubleSpendFound(txInMempool, proof);
2019-09-02 23:33:33 +02:00
}
2021-11-02 10:18:24 +01:00
void ValidationInterfaceBroadcaster::chainReorged(CBlockIndex *oldTip, const std::vector<Block> &revertedBlocks)
{
for (auto i : m_listeners) i->chainReorged(oldTip, revertedBlocks);
}
2018-02-15 18:06:38 +01:00
void ValidationInterfaceBroadcaster::addListener(ValidationInterface *impl)
{
m_listeners.push_back(impl);
}
void ValidationInterfaceBroadcaster::removeListener(ValidationInterface *impl)
{
m_listeners.remove(impl);
}
void ValidationInterfaceBroadcaster::removeAll()
{
m_listeners.clear();
}