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-2015 The Bitcoin Core developers
|
2021-02-19 13:31:11 +01:00
|
|
|
* 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/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef FLOWEE_VALIDATIONINTERFACE_H
|
|
|
|
|
#define FLOWEE_VALIDATIONINTERFACE_H
|
|
|
|
|
|
|
|
|
|
#include <boost/shared_ptr.hpp>
|
|
|
|
|
#include <list>
|
2021-02-19 13:31:11 +01:00
|
|
|
#include <vector>
|
2018-02-15 18:06:38 +01:00
|
|
|
|
2021-11-02 09:36:09 +01:00
|
|
|
class MutableBlock;
|
2018-02-15 18:06:38 +01:00
|
|
|
struct CBlockLocator;
|
|
|
|
|
class CBlockIndex;
|
|
|
|
|
class CTransaction;
|
|
|
|
|
class uint256;
|
|
|
|
|
class Tx;
|
2021-11-02 10:18:24 +01:00
|
|
|
class Block;
|
2019-09-02 23:33:33 +02:00
|
|
|
class DoubleSpendProof;
|
2018-02-15 18:06:38 +01:00
|
|
|
|
|
|
|
|
class ValidationInterface {
|
|
|
|
|
public:
|
|
|
|
|
/** Notifies listeners of updated transaction data, and optionally the block it is found in. */
|
2021-02-18 16:03:01 +01:00
|
|
|
virtual void syncTransaction(const CTransaction &tx) {}
|
2018-02-15 18:06:38 +01:00
|
|
|
|
|
|
|
|
/** Notifies listeners of updated transaction data, and optionally the block it is found in. */
|
2021-02-18 16:03:01 +01:00
|
|
|
virtual void syncTx(const Tx &) {}
|
2018-02-15 18:06:38 +01:00
|
|
|
|
|
|
|
|
/** Notifies listeners of updated transaction data, on a new accepted block. */
|
2021-11-02 09:36:09 +01:00
|
|
|
virtual void syncAllTransactionsInBlock(const MutableBlock *pblock) {}
|
2018-02-15 18:06:38 +01:00
|
|
|
|
|
|
|
|
/** Notifies listeners of updated transaction data, on a new accepted block. */
|
2021-11-02 10:18:24 +01:00
|
|
|
virtual void syncAllTransactionsInBlock(const Block &, CBlockIndex *) {}
|
2018-02-15 18:06:38 +01:00
|
|
|
|
|
|
|
|
/** Notifies listeners of a new active block chain. */
|
2021-02-18 16:03:01 +01:00
|
|
|
virtual void setBestChain(const CBlockLocator &locator) {}
|
2018-02-15 18:06:38 +01:00
|
|
|
|
|
|
|
|
/** Notifies listeners of an updated transaction without new data (for now: a coinbase potentially becoming visible). */
|
2021-02-18 16:03:01 +01:00
|
|
|
virtual void updatedTransaction(const uint256 &hash) {}
|
2018-02-15 18:06:38 +01:00
|
|
|
|
|
|
|
|
/** Notifies listeners about an inventory item being seen on the network. */
|
2021-02-18 16:03:01 +01:00
|
|
|
virtual void inventory(const uint256 &hash) {}
|
2018-02-15 18:06:38 +01:00
|
|
|
|
|
|
|
|
/** Tells listeners to broadcast their data. */
|
2021-02-18 16:03:01 +01:00
|
|
|
virtual void resendWalletTransactions(int64_t nBestBlockTime) {}
|
2018-02-15 18:06:38 +01:00
|
|
|
|
2019-09-02 23:33:33 +02:00
|
|
|
/**
|
|
|
|
|
* Notifies listeners that we received a double-spend.
|
2018-03-25 13:55:48 +02:00
|
|
|
* First is the tx that is in our mempool, duplicate is the one we received and reject
|
|
|
|
|
*/
|
2021-02-18 16:03:01 +01:00
|
|
|
virtual void doubleSpendFound(const Tx &first, const Tx &duplicate) {}
|
2019-09-02 23:33:33 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Notifies listeners that we received a double-spend proof.
|
|
|
|
|
* First is the tx that is in our mempool, proof is the actual proof.
|
|
|
|
|
*/
|
2021-02-18 16:03:01 +01:00
|
|
|
virtual void doubleSpendFound(const Tx &txInMempool, const DoubleSpendProof &proof) {}
|
2021-02-19 13:31:11 +01:00
|
|
|
|
2021-11-02 10:18:24 +01:00
|
|
|
virtual void chainReorged(CBlockIndex *oldTip, const std::vector<Block> &revertedBlocks) {}
|
2018-02-15 18:06:38 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ValidationInterfaceBroadcaster : public ValidationInterface
|
|
|
|
|
{
|
|
|
|
|
public:
|
2021-02-18 16:03:01 +01:00
|
|
|
void syncTransaction(const CTransaction &tx) override;
|
|
|
|
|
void syncTx(const Tx &) override;
|
2021-11-02 09:36:09 +01:00
|
|
|
void syncAllTransactionsInBlock(const MutableBlock *pblock) override;
|
2021-11-02 10:18:24 +01:00
|
|
|
void syncAllTransactionsInBlock(const Block &block, CBlockIndex *index) override;
|
2021-02-18 16:03:01 +01:00
|
|
|
void setBestChain(const CBlockLocator &locator) override;
|
|
|
|
|
void updatedTransaction(const uint256 &hash) override;
|
|
|
|
|
void inventory(const uint256 &hash) override;
|
|
|
|
|
void resendWalletTransactions(int64_t nBestBlockTime) override;
|
|
|
|
|
void doubleSpendFound(const Tx &first, const Tx &duplicate) override;
|
|
|
|
|
void doubleSpendFound(const Tx &txInMempool, const DoubleSpendProof &proof) override;
|
2021-11-02 10:18:24 +01:00
|
|
|
void chainReorged(CBlockIndex *oldTip, const std::vector<Block> &revertedBlocks) override;
|
2018-02-15 18:06:38 +01:00
|
|
|
|
|
|
|
|
void addListener(ValidationInterface *impl);
|
|
|
|
|
void removeListener(ValidationInterface *impl);
|
|
|
|
|
void removeAll();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
std::list<ValidationInterface*> m_listeners;
|
|
|
|
|
};
|
|
|
|
|
|
2018-11-14 22:59:28 +01:00
|
|
|
ValidationInterfaceBroadcaster &ValidationNotifier();
|
2018-02-15 18:06:38 +01:00
|
|
|
|
|
|
|
|
#endif
|