aboutsummaryrefslogtreecommitdiff
path: root/src/primitives/block.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/primitives/block.cpp')
-rw-r--r--src/primitives/block.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/primitives/block.cpp b/src/primitives/block.cpp
new file mode 100644
index 000000000..6fb33230a
--- /dev/null
+++ b/src/primitives/block.cpp
@@ -0,0 +1,33 @@
+// Copyright (c) 2009-2010 Satoshi Nakamoto
+// Copyright (c) 2009-2015 The Bitcoin Core developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#include "primitives/block.h"
+
+#include "hash.h"
+#include "tinyformat.h"
+#include "utilstrencodings.h"
+#include "crypto/common.h"
+
+uint256 CBlockHeader::GetHash() const
+{
+ return SerializeHash(*this);
+}
+
+std::string CBlock::ToString() const
+{
+ std::stringstream s;
+ s << strprintf("CBlock(hash=%s, ver=0x%08x, hashPrevBlock=%s, hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, vtx=%u)\n",
+ GetHash().ToString(),
+ nVersion,
+ hashPrevBlock.ToString(),
+ hashMerkleRoot.ToString(),
+ nTime, nBits, nNonce,
+ vtx.size());
+ for (unsigned int i = 0; i < vtx.size(); i++)
+ {
+ s << " " << vtx[i].ToString() << "\n";
+ }
+ return s.str();
+}