59 lines
1.7 KiB
C++
59 lines
1.7 KiB
C++
|
|
/*
|
||
|
|
* This file is part of the Flowee project
|
||
|
|
* Copyright (C) 2009-2010 Satoshi Nakamoto
|
||
|
|
* Copyright (C) 2009-2015 The Bitcoin Core developers
|
||
|
|
* Copyright (C) 2021 Tom Zander <tom@flowee.org>
|
||
|
|
*
|
||
|
|
* 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_BLOCKLOCATOR_H
|
||
|
|
#define FLOWEE_BLOCKLOCATOR_H
|
||
|
|
|
||
|
|
#include "serialize.h"
|
||
|
|
|
||
|
|
/** Describes a place in the block chain to another node such that if the
|
||
|
|
* other node doesn't have the same branch, it can find a recent common trunk.
|
||
|
|
* The further back it is, the further before the fork it may be.
|
||
|
|
*/
|
||
|
|
struct CBlockLocator
|
||
|
|
{
|
||
|
|
CBlockLocator() = default;
|
||
|
|
|
||
|
|
CBlockLocator(const std::vector<uint256> &vHaveIn) {
|
||
|
|
vHave = vHaveIn;
|
||
|
|
}
|
||
|
|
|
||
|
|
ADD_SERIALIZE_METHODS
|
||
|
|
|
||
|
|
template <typename Stream, typename Operation>
|
||
|
|
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
|
||
|
|
if (!(nType & SER_GETHASH))
|
||
|
|
READWRITE(nVersion);
|
||
|
|
READWRITE(vHave);
|
||
|
|
}
|
||
|
|
|
||
|
|
inline void SetNull() {
|
||
|
|
vHave.clear();
|
||
|
|
}
|
||
|
|
|
||
|
|
inline bool IsNull() const {
|
||
|
|
return vHave.empty();
|
||
|
|
}
|
||
|
|
|
||
|
|
std::vector<uint256> vHave;
|
||
|
|
};
|
||
|
|
|
||
|
|
#endif
|