Branch data Line data Source code
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 <span>
13 : : #include <sstream>
14 : :
15 : 5552597 : uint256 CBlockHeader::GetHash() const
16 : : {
17 : 5552597 : return (HashWriter{} << *this).GetHash();
18 : : }
19 : :
20 : 1261 : std::string CBlock::ToString() const
21 : : {
22 : 1261 : std::stringstream s;
23 [ + - ]: 2522 : s << strprintf("CBlock(hash=%s, ver=0x%08x, hashPrevBlock=%s, hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, vtx=%u)\n",
24 [ + - ]: 2522 : GetHash().ToString(),
25 [ + - ]: 1261 : nVersion,
26 [ + - ]: 2522 : hashPrevBlock.ToString(),
27 : 0 : hashMerkleRoot.ToString(),
28 : 1261 : nTime, nBits, nNonce,
29 [ - + + - ]: 2522 : vtx.size());
30 [ + + ]: 1474783 : for (const auto& tx : vtx) {
31 [ + - + - : 4420566 : s << " " << tx->ToString() << "\n";
+ - ]
32 : : }
33 [ + - ]: 2522 : return s.str();
34 : 1261 : }
|