2013-01-08 08:02:51 -03:00
|
|
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
2014-12-16 22:47:57 -03:00
|
|
|
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
2014-12-13 01:09:33 -03:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
2013-01-08 08:02:51 -03:00
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2014-11-18 18:03:02 -03:00
|
|
|
#include "primitives/block.h"
|
2013-04-13 02:13:08 -03:00
|
|
|
|
2014-09-25 00:32:36 -03:00
|
|
|
#include "hash.h"
|
2014-08-20 04:51:18 -04:00
|
|
|
#include "tinyformat.h"
|
2014-09-25 00:32:36 -03:00
|
|
|
#include "utilstrencodings.h"
|
2014-12-19 07:39:38 -03:00
|
|
|
#include "crypto/common.h"
|
2013-01-08 09:17:15 -03:00
|
|
|
|
2013-06-24 21:03:03 -04:00
|
|
|
uint256 CBlockHeader::GetHash() const
|
|
|
|
{
|
2015-01-18 15:23:05 -03:00
|
|
|
return SerializeHash(*this);
|
2013-06-24 21:03:03 -04:00
|
|
|
}
|
|
|
|
|
2014-08-20 04:26:27 -04:00
|
|
|
std::string CBlock::ToString() const
|
2013-06-24 21:03:03 -04:00
|
|
|
{
|
2014-08-20 04:26:27 -04:00
|
|
|
std::stringstream s;
|
|
|
|
s << strprintf("CBlock(hash=%s, ver=%d, hashPrevBlock=%s, hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, vtx=%u)\n",
|
2014-01-16 12:15:27 -03:00
|
|
|
GetHash().ToString(),
|
2013-06-24 21:03:03 -04:00
|
|
|
nVersion,
|
2014-01-16 12:15:27 -03:00
|
|
|
hashPrevBlock.ToString(),
|
|
|
|
hashMerkleRoot.ToString(),
|
2013-06-24 21:03:03 -04:00
|
|
|
nTime, nBits, nNonce,
|
|
|
|
vtx.size());
|
|
|
|
for (unsigned int i = 0; i < vtx.size(); i++)
|
|
|
|
{
|
2014-08-20 04:26:27 -04:00
|
|
|
s << " " << vtx[i].ToString() << "\n";
|
2013-06-24 21:03:03 -04:00
|
|
|
}
|
2014-08-20 04:26:27 -04:00
|
|
|
return s.str();
|
2013-06-24 21:03:03 -04:00
|
|
|
}
|