Changeset View
Changeset View
Standalone View
Standalone View
src/diskblockpos.h
- This file was added.
// Copyright (c) 2018 The Bitcoin Core developers | |||||
// Distributed under the MIT software license, see the accompanying | |||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | |||||
#ifndef BITCOIN_DISKBLOCKPOS_H | |||||
#define BITCOIN_DISKBLOCKPOS_H | |||||
#include "serialize.h" | |||||
#include "tinyformat.h" | |||||
#include <string> | |||||
struct CDiskBlockPos { | |||||
int nFile; | |||||
unsigned int nPos; | |||||
ADD_SERIALIZE_METHODS; | |||||
template <typename Stream, typename Operation> | |||||
inline void SerializationOp(Stream &s, Operation ser_action) { | |||||
READWRITE(VARINT(nFile)); | |||||
READWRITE(VARINT(nPos)); | |||||
} | |||||
CDiskBlockPos() { SetNull(); } | |||||
CDiskBlockPos(int nFileIn, unsigned int nPosIn) { | |||||
nFile = nFileIn; | |||||
nPos = nPosIn; | |||||
} | |||||
friend bool operator==(const CDiskBlockPos &a, const CDiskBlockPos &b) { | |||||
return (a.nFile == b.nFile && a.nPos == b.nPos); | |||||
} | |||||
friend bool operator!=(const CDiskBlockPos &a, const CDiskBlockPos &b) { | |||||
return !(a == b); | |||||
} | |||||
void SetNull() { | |||||
nFile = -1; | |||||
nPos = 0; | |||||
} | |||||
bool IsNull() const { return (nFile == -1); } | |||||
std::string ToString() const { | |||||
return strprintf("CBlockDiskPos(nFile=%i, nPos=%i)", nFile, nPos); | |||||
} | |||||
}; | |||||
#endif // BITCOIN_DISKBLOCKPOS_H |