mirror of
https://github.com/cculianu/Fulcrum.git
synced 2026-08-13 12:33:27 +02:00
Minor nit: Allow CBlock.ToString() to take an optional "verbose" arg.
Also in the deserializer, we print the number of junk bytes left at the end if there are junk bytes.
This commit is contained in:
parent
89bcc47222
commit
be56dd204f
3 changed files with 5 additions and 4 deletions
|
|
@ -102,7 +102,8 @@ namespace BTC
|
|||
bitcoin::GenericVectorReader<QByteArray> vr(bitcoin::SER_NETWORK, version, bytes, pos);
|
||||
thing.Unserialize(vr);
|
||||
if (throwIfJunkAtEnd && !vr.empty())
|
||||
throw std::ios_base::failure("Got unprocessed bytes at the end when deserializeing a bitcoin object");
|
||||
throw std::ios_base::failure(strprintf("Got %u unprocessed bytes at the end when deserializeing a bitcoin object",
|
||||
vr.size()));
|
||||
}
|
||||
/// Convenience for above. Create an instance of object and deserialize to it
|
||||
template <typename BitcoinObject>
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ uint256 CBlockHeader::GetHash() const {
|
|||
return SerializeHash(*this);
|
||||
}
|
||||
|
||||
std::string CBlock::ToString() const {
|
||||
std::string CBlock::ToString(bool fVerbose) const {
|
||||
std::stringstream s;
|
||||
s << strprintf("CBlock(hash=%s, ver=0x%08x, hashPrevBlock=%s, "
|
||||
"hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, "
|
||||
|
|
@ -24,7 +24,7 @@ std::string CBlock::ToString() const {
|
|||
GetHash().ToString(), nVersion, hashPrevBlock.ToString(),
|
||||
hashMerkleRoot.ToString(), nTime, nBits, nNonce, vtx.size());
|
||||
for (const auto &tx : vtx) {
|
||||
s << " " << tx->ToString() << "\n";
|
||||
s << " " << tx->ToString(fVerbose) << "\n";
|
||||
}
|
||||
return s.str();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ public:
|
|||
return block;
|
||||
}
|
||||
|
||||
std::string ToString() const;
|
||||
std::string ToString(bool fVerbose = false) const;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue