Changeset View
Changeset View
Standalone View
Standalone View
src/primitives/block.cpp
// Copyright (c) 2009-2010 Satoshi Nakamoto | // Copyright (c) 2009-2010 Satoshi Nakamoto | ||||
// Copyright (c) 2009-2016 The Bitcoin Core developers | // Copyright (c) 2009-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <primitives/block.h> | #include <primitives/block.h> | ||||
#include <crypto/common.h> | #include <crypto/common.h> | ||||
#include <hash.h> | #include <hash.h> | ||||
#include <tinyformat.h> | #include <tinyformat.h> | ||||
#include <util/strencodings.h> | #include <util/strencodings.h> | ||||
uint256 CBlockHeader::GetHash() const { | BlockHash CBlockHeader::GetHash() const { | ||||
return SerializeHash(*this); | return BlockHash(SerializeHash(*this)); | ||||
} | } | ||||
std::string CBlock::ToString() const { | std::string CBlock::ToString() const { | ||||
std::stringstream s; | std::stringstream s; | ||||
s << strprintf("CBlock(hash=%s, ver=0x%08x, hashPrevBlock=%s, " | s << strprintf("CBlock(hash=%s, ver=0x%08x, hashPrevBlock=%s, " | ||||
"hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, " | "hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, " | ||||
"vtx=%u)\n", | "vtx=%u)\n", | ||||
GetHash().ToString(), nVersion, hashPrevBlock.ToString(), | GetHash().ToString(), nVersion, hashPrevBlock.ToString(), | ||||
hashMerkleRoot.ToString(), nTime, nBits, nNonce, vtx.size()); | hashMerkleRoot.ToString(), nTime, nBits, nNonce, vtx.size()); | ||||
for (const auto &tx : vtx) { | for (const auto &tx : vtx) { | ||||
s << " " << tx->ToString() << "\n"; | s << " " << tx->ToString() << "\n"; | ||||
} | } | ||||
return s.str(); | return s.str(); | ||||
} | } |