Bitcoin Core
0.21.1
P2P Digital Currency
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
src
primitives
block.cpp
Go to the documentation of this file.
1
// Copyright (c) 2009-2010 Satoshi Nakamoto
2
// Copyright (c) 2009-2019 The Bitcoin Core developers
3
// Distributed under the MIT software license, see the accompanying
4
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6
#include <
primitives/block.h
>
7
8
#include <hash.h>
9
#include <
tinyformat.h
>
10
11
uint256
CBlockHeader::GetHash
()
const
12
{
13
return
SerializeHash
(*
this
);
14
}
15
16
std::string
CBlock::ToString
()
const
17
{
18
std::stringstream s;
19
s <<
strprintf
(
"CBlock(hash=%s, ver=0x%08x, hashPrevBlock=%s, hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, vtx=%u)\n"
,
20
GetHash
().
ToString
(),
21
nVersion
,
22
hashPrevBlock
.
ToString
(),
23
hashMerkleRoot
.
ToString
(),
24
nTime
,
nBits
,
nNonce
,
25
vtx.size());
26
for
(
const
auto
& tx : vtx) {
27
s <<
" "
<< tx->ToString() <<
"\n"
;
28
}
29
return
s.str();
30
}
CBlockHeader::nNonce
uint32_t nNonce
Definition:
block.h:29
strprintf
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition:
tinyformat.h:1164
CBlockHeader::nTime
uint32_t nTime
Definition:
block.h:27
base_blob::ToString
std::string ToString() const
Definition:
uint256.cpp:64
SerializeHash
uint256 SerializeHash(const T &obj, int nType=SER_GETHASH, int nVersion=PROTOCOL_VERSION)
Compute the 256-bit hash of an object's serialization.
Definition:
hash.h:192
ToString
std::string ToString(const T &t)
Locale-independent version of std::to_string.
Definition:
string.h:71
CBlockHeader::hashMerkleRoot
uint256 hashMerkleRoot
Definition:
block.h:26
CBlockHeader::hashPrevBlock
uint256 hashPrevBlock
Definition:
block.h:25
tinyformat.h
CBlock::ToString
std::string ToString() const
Definition:
block.cpp:16
uint256
256-bit opaque blob.
Definition:
uint256.h:124
CBlockHeader::GetHash
uint256 GetHash() const
Definition:
block.cpp:11
CBlockHeader::nVersion
int32_t nVersion
Definition:
block.h:24
block.h
CBlockHeader::nBits
uint32_t nBits
Definition:
block.h:28
Generated on Fri Apr 30 2021 15:02:54 for Bitcoin Core by
1.8.11