0a2e552168
This introduces a new BlockHeader helper class which Block and MutableBlock can both produce, which helps a lot of methods to be ported to no longer be dependent on us using a MutableBlock object, which is too costly to use when we have no intention to alter the block.
55 lines
1.4 KiB
C++
55 lines
1.4 KiB
C++
/*
|
|
* This file is part of the Flowee project
|
|
* Copyright (C) 2026 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_PRIMITIVES_BLOCKHEADER_H
|
|
#define FLOWEE_PRIMITIVES_BLOCKHEADER_H
|
|
|
|
#include <uint256.h>
|
|
|
|
class Block;
|
|
|
|
class BlockHeader
|
|
{
|
|
public:
|
|
BlockHeader() = default;
|
|
BlockHeader(const Block &block);
|
|
BlockHeader(const BlockHeader &other) = default;
|
|
|
|
int32_t nVersion = 0;
|
|
uint256 hashPrevBlock;
|
|
uint256 hashMerkleRoot;
|
|
uint32_t nTime = 0;
|
|
uint32_t nBits = 0;
|
|
uint32_t nNonce = 0;
|
|
|
|
inline bool isNull() const {
|
|
return (nBits == 0);
|
|
}
|
|
|
|
uint256 createHash() const;
|
|
|
|
inline int64_t blockTime() const {
|
|
return static_cast<int64_t>(nTime);
|
|
}
|
|
|
|
BlockHeader &operator=(const BlockHeader &other) = default;
|
|
};
|
|
|
|
#endif
|