2017-11-09 19:34:51 +01:00
|
|
|
/*
|
|
|
|
|
* This file is part of the Flowee project
|
|
|
|
|
* Copyright (C) 2009-2010 Satoshi Nakamoto
|
|
|
|
|
* Copyright (C) 2009-2015 The Bitcoin Core developers
|
|
|
|
|
*
|
|
|
|
|
* 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/>.
|
|
|
|
|
*/
|
2014-10-30 15:50:15 -07:00
|
|
|
|
2018-01-16 10:47:52 +00:00
|
|
|
#ifndef FLOWEE_MERKLEBLOCK_H
|
|
|
|
|
#define FLOWEE_MERKLEBLOCK_H
|
2014-10-30 15:50:15 -07:00
|
|
|
|
2020-04-17 16:13:42 +02:00
|
|
|
#include <utils/PartialMerkleTree.h>
|
2021-11-02 10:08:27 +01:00
|
|
|
#include "primitives/MutableBlock.h"
|
2014-10-30 15:50:15 -07:00
|
|
|
#include "bloom.h"
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Used to relay blocks as header + vector<merkle branch>
|
|
|
|
|
* to filtered nodes.
|
|
|
|
|
*/
|
|
|
|
|
class CMerkleBlock
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
/** Public only for unit testing */
|
2021-11-02 10:49:17 +01:00
|
|
|
BlockHeaderFields header;
|
2014-10-30 15:50:15 -07:00
|
|
|
CPartialMerkleTree txn;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
/** Public only for unit testing and relay testing (not relayed) */
|
|
|
|
|
std::vector<std::pair<unsigned int, uint256> > vMatchedTxn;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create from a CBlock, filtering transactions according to filter
|
|
|
|
|
* Note that this will call IsRelevantAndUpdate on the filter for each transaction,
|
|
|
|
|
* thus the filter will likely be modified.
|
|
|
|
|
*/
|
2021-11-02 09:36:09 +01:00
|
|
|
CMerkleBlock(const MutableBlock& block, CBloomFilter& filter);
|
2014-10-30 15:50:15 -07:00
|
|
|
|
2014-11-01 23:53:55 -07:00
|
|
|
// Create from a CBlock, matching the txids in the set
|
2021-11-02 09:36:09 +01:00
|
|
|
CMerkleBlock(const MutableBlock& block, const std::set<uint256>& txids);
|
2014-11-01 23:53:55 -07:00
|
|
|
|
|
|
|
|
CMerkleBlock() {}
|
|
|
|
|
|
2017-01-19 21:40:34 +01:00
|
|
|
ADD_SERIALIZE_METHODS
|
2014-10-30 15:50:15 -07:00
|
|
|
|
|
|
|
|
template <typename Stream, typename Operation>
|
|
|
|
|
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
|
|
|
|
|
READWRITE(header);
|
|
|
|
|
READWRITE(txn);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2018-01-16 10:47:52 +00:00
|
|
|
#endif
|