Files
thehub/libs/p2p/BlockHeader.h
T

51 lines
1.5 KiB
C++
Raw Permalink Normal View History

2020-04-17 19:33:06 +02:00
/*
* This file is part of the Flowee project
2021-02-02 13:08:07 +01:00
* Copyright (C) 2020 Tom Zander <tom@flowee.org>
2020-04-17 19:33:06 +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/>.
*/
#ifndef BLOCKHEADER_H
#define BLOCKHEADER_H
2023-12-21 15:13:56 +01:00
#include <memory>
2020-04-17 19:33:06 +02:00
#include <uint256.h>
#include <cstdint>
#include <arith_uint256.h>
namespace Streaming {
class P2PParser;
class BufferPool;
class ConstBuffer;
2020-04-17 19:33:06 +02:00
}
struct BlockHeader
{
static BlockHeader fromMessage(Streaming::P2PParser &parser);
static BlockHeader fromMessage(const Streaming::ConstBuffer &buffer);
2020-04-17 19:33:06 +02:00
uint256 createHash() const;
arith_uint256 blockProof() const;
// write the header in P2P syntax (just like on the blockchain)
2023-12-21 15:13:56 +01:00
Streaming::ConstBuffer write(const std::shared_ptr<Streaming::BufferPool> &pool) const;
2020-04-17 19:33:06 +02:00
2020-11-12 14:32:14 +01:00
int32_t nVersion = 0;
2020-04-17 19:33:06 +02:00
uint256 hashPrevBlock;
uint256 hashMerkleRoot;
2020-11-12 14:32:14 +01:00
uint32_t nTime = 0;
uint32_t nBits = 0;
uint32_t nNonce = 0;
2020-04-17 19:33:06 +02:00
};
#endif