Files

59 lines
1.8 KiB
C++
Raw Permalink Normal View History

2019-06-11 17:28:16 +02:00
/*
* This file is part of the Flowee project
2021-06-20 22:44:44 +02:00
* Copyright (C) 2019 Tom Zander <tom@flowee.org>
2019-06-11 17:28:16 +02: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/>.
*/
2019-06-26 21:39:07 +02:00
#ifndef SPENTOUTPUTINDEXER_H
#define SPENTOUTPUTINDEXER_H
2019-06-11 17:28:16 +02:00
2019-06-26 21:39:07 +02:00
#include <QThread>
2019-06-11 17:28:16 +02:00
#include <UnspentOutputDatabase.h>
2019-06-26 21:39:07 +02:00
class Indexer;
class SpentOutputIndexer : public QThread
2019-06-11 17:28:16 +02:00
{
2019-06-26 21:39:07 +02:00
Q_OBJECT
2019-06-11 17:28:16 +02:00
public:
2025-02-08 19:05:26 +01:00
SpentOutputIndexer(boost::asio::io_context &context, const boost::filesystem::path &basedir, Indexer *indexer);
2019-06-11 17:28:16 +02:00
int blockheight() const;
uint256 blockId() const;
void blockFinished(int blockheight, const uint256 &blockId);
/**
* Insert transaction that spent an output.
* Inputs spent old transaction's outputs. To find those spending a certain
* output we insert them here when they get spend.
*/
void insertSpentTransaction(const uint256 &prevTxId, int prevOutIndex, int blockHeight, int offsetInBlock);
/// The transaction that spent an output.
struct TxData {
int blockHeight = -1;
int offsetInBlock = 0;
};
TxData findSpendingTx(const uint256 &txid, int output) const;
2019-06-26 21:39:07 +02:00
void run() override;
2019-06-11 17:28:16 +02:00
private:
UnspentOutputDatabase m_txdb;
2019-06-26 21:39:07 +02:00
Indexer *m_dataSource;
2019-06-11 17:28:16 +02:00
};
#endif