Bitcoin Core  0.18.99
P2P Digital Currency
block.cpp
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2018 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 #include <crypto/common.h>
11 
13 {
14  return SerializeHash(*this);
15 }
16 
17 std::string CBlock::ToString() const
18 {
19  std::stringstream s;
20  s << strprintf("CBlock(hash=%s, ver=0x%08x, hashPrevBlock=%s, hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, vtx=%u)\n",
21  GetHash().ToString(),
22  nVersion,
25  nTime, nBits, nNonce,
26  vtx.size());
27  for (const auto& tx : vtx) {
28  s << " " << tx->ToString() << "\n";
29  }
30  return s.str();
31 }
uint32_t nNonce
Definition: block.h:29
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition: tinyformat.h:1067
std::string ToString() const
Definition: block.cpp:17
uint32_t nTime
Definition: block.h:27
uint256 SerializeHash(const T &obj, int nType=SER_GETHASH, int nVersion=PROTOCOL_VERSION)
Compute the 256-bit hash of an object&#39;s serialization.
Definition: hash.h:196
uint256 hashMerkleRoot
Definition: block.h:26
uint256 hashPrevBlock
Definition: block.h:25
std::string ToString() const
Definition: uint256.cpp:61
uint256 GetHash() const
Definition: block.cpp:12
256-bit opaque blob.
Definition: uint256.h:121
int32_t nVersion
Definition: block.h:24
uint32_t nBits
Definition: block.h:28