From: Scott Nadal Date: Sat, 31 Mar 2012 18:42:13 +0000 (+0100) Subject: PPCoin: Move vchBlockSig to after vtx and fix CDiskTxPos calculation X-Git-Tag: v0.4.0-unstable~197 X-Git-Url: https://git.novaco.in/?a=commitdiff_plain;h=1f7753aaf22bd287a5e2dd6e6d1c86738177c61c;hp=17382b40fae13629d0a7c77806bd9e73972f061d;p=novacoin.git PPCoin: Move vchBlockSig to after vtx and fix CDiskTxPos calculation --- diff --git a/src/main.cpp b/src/main.cpp index a6cdccb..388f1db 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1062,7 +1062,7 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex) return false; //// issue here: it doesn't know the version - unsigned int nTxPos = pindex->nBlockPos + ::GetSerializeSize(CBlock(), SER_DISK) - 1 + GetSizeOfCompactSize(vtx.size()); + unsigned int nTxPos = pindex->nBlockPos + ::GetSerializeSize(CBlock(), SER_DISK) - (2 * GetSizeOfCompactSize(0)) + GetSizeOfCompactSize(vtx.size()); map mapQueuedChanges; int64 nFees = 0; diff --git a/src/main.h b/src/main.h index 59b88ce..cad0069 100644 --- a/src/main.h +++ b/src/main.h @@ -807,13 +807,12 @@ public: unsigned int nBits; unsigned int nNonce; - // ppcoin: block signature (not considered part of header) - // signed by coin base txout[0]'s owner - std::vector vchBlockSig; - // network and disk std::vector vtx; + // ppcoin: block signature - signed by coin base txout[0]'s owner + std::vector vchBlockSig; + // memory only mutable std::vector vMerkleTree; @@ -836,16 +835,16 @@ public: READWRITE(nBits); READWRITE(nNonce); - // ConnectBlock depends on vtx being last so it can calculate offset + // ConnectBlock depends on vtx following header to generate CDiskTxPos if (!(nType & (SER_GETHASH|SER_BLOCKHEADERONLY))) { - READWRITE(vchBlockSig); READWRITE(vtx); + READWRITE(vchBlockSig); } else if (fRead) { - const_cast(this)->vchBlockSig.clear(); const_cast(this)->vtx.clear(); + const_cast(this)->vchBlockSig.clear(); } ) @@ -857,8 +856,8 @@ public: nTime = 0; nBits = 0; nNonce = 0; - vchBlockSig.clear(); vtx.clear(); + vchBlockSig.clear(); vMerkleTree.clear(); nDoS = 0; } @@ -1003,14 +1002,14 @@ public: void print() const { - printf("CBlock(hash=%s, ver=%d, hashPrevBlock=%s, hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, vchBlockSig=%s, vtx=%d)\n", + printf("CBlock(hash=%s, ver=%d, hashPrevBlock=%s, hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, vtx=%d, vchBlockSig=%s)\n", GetHash().ToString().substr(0,20).c_str(), nVersion, hashPrevBlock.ToString().substr(0,20).c_str(), hashMerkleRoot.ToString().substr(0,10).c_str(), nTime, nBits, nNonce, - HexStr(vchBlockSig.begin(), vchBlockSig.end()).c_str(), - vtx.size()); + vtx.size(), + HexStr(vchBlockSig.begin(), vchBlockSig.end()).c_str()); for (int i = 0; i < vtx.size(); i++) { printf(" ");