You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

block.cpp 936B

123456789101112131415161718192021222324252627282930313233
  1. // Copyright (c) 2009-2010 Satoshi Nakamoto
  2. // Copyright (c) 2009-2015 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. #include "primitives/block.h"
  6. #include "hash.h"
  7. #include "tinyformat.h"
  8. #include "utilstrencodings.h"
  9. #include "crypto/common.h"
  10. uint256 CBlockHeader::GetHash() const
  11. {
  12. return SerializeHash(*this);
  13. }
  14. std::string CBlock::ToString() const
  15. {
  16. std::stringstream s;
  17. s << strprintf("CBlock(hash=%s, ver=%d, hashPrevBlock=%s, hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, vtx=%u)\n",
  18. GetHash().ToString(),
  19. nVersion,
  20. hashPrevBlock.ToString(),
  21. hashMerkleRoot.ToString(),
  22. nTime, nBits, nNonce,
  23. vtx.size());
  24. for (unsigned int i = 0; i < vtx.size(); i++)
  25. {
  26. s << " " << vtx[i].ToString() << "\n";
  27. }
  28. return s.str();
  29. }