Bitcoin Core
32.1.0
P2P Digital Currency
Toggle main menu visibility
Loading...
Searching...
No Matches
src
primitives
block.cpp
Go to the documentation of this file.
1
// Copyright (c) 2009-2010 Satoshi Nakamoto
2
// Copyright (c) 2009-present 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
#include <memory>
12
#include <sstream>
13
14
uint256
CBlockHeader::GetHash
()
const
15
{
16
return
(
HashWriter
{} << *
this
).
GetHash
();
17
}
18
19
std::string
CBlock::ToString
()
const
20
{
21
std::stringstream s;
22
s <<
strprintf
(
"CBlock(hash=%s, ver=0x%08x, hashPrevBlock=%s, hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, vtx=%u)\n"
,
23
GetHash
().
ToString
(),
24
nVersion
,
25
hashPrevBlock
.
ToString
(),
26
hashMerkleRoot
.
ToString
(),
27
nTime
,
nBits
,
nNonce
,
28
vtx
.size());
29
for
(
const
auto
& tx :
vtx
) {
30
s <<
" "
<< tx->ToString() <<
"\n"
;
31
}
32
return
s.str();
33
}
block.h
CBlockHeader::nNonce
uint32_t nNonce
Definition
block.h:35
CBlockHeader::nBits
uint32_t nBits
Definition
block.h:34
CBlockHeader::nTime
uint32_t nTime
Definition
block.h:33
CBlockHeader::nVersion
int32_t nVersion
Definition
block.h:30
CBlockHeader::hashPrevBlock
uint256 hashPrevBlock
Definition
block.h:31
CBlockHeader::hashMerkleRoot
uint256 hashMerkleRoot
Definition
block.h:32
CBlockHeader::GetHash
uint256 GetHash() const
Definition
block.cpp:14
CBlock::ToString
std::string ToString() const
Definition
block.cpp:19
CBlock::vtx
std::vector< CTransactionRef > vtx
Definition
block.h:77
HashWriter
A writer stream (for serialization) that computes a 256-bit hash.
Definition
hash.h:109
base_blob::ToString
std::string ToString() const
Definition
uint256.cpp:21
uint256
256-bit opaque blob.
Definition
uint256.h:196
tinyformat.h
strprintf
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition
tinyformat.h:1172
Generated on
for Bitcoin Core by
1.18.0