aboutsummaryrefslogtreecommitdiff
path: root/main.h
diff options
context:
space:
mode:
Diffstat (limited to 'main.h')
-rw-r--r--main.h41
1 files changed, 36 insertions, 5 deletions
diff --git a/main.h b/main.h
index c5a0127c41..f6993691ed 100644
--- a/main.h
+++ b/main.h
@@ -195,7 +195,7 @@ public:
string ToString() const
{
- return strprintf("COutPoint(%s, %d)", hash.ToString().substr(0,6).c_str(), n);
+ return strprintf("COutPoint(%s, %d)", hash.ToString().substr(0,10).c_str(), n);
}
void print() const
@@ -599,7 +599,7 @@ public:
{
string str;
str += strprintf("CTransaction(hash=%s, ver=%d, vin.size=%d, vout.size=%d, nLockTime=%d)\n",
- GetHash().ToString().substr(0,6).c_str(),
+ GetHash().ToString().substr(0,10).c_str(),
nVersion,
vin.size(),
vout.size(),
@@ -787,6 +787,37 @@ public:
return nCreditCached;
}
+ bool IsConfirmed() const
+ {
+ map<uint256, const CMerkleTx*> mapPrev;
+ vector<const CMerkleTx*> vWorkQueue;
+ vWorkQueue.reserve(vtxPrev.size()+1);
+ vWorkQueue.push_back(this);
+ for (int i = 0; i < vWorkQueue.size(); i++)
+ {
+ const CMerkleTx* ptx = vWorkQueue[i];
+
+ if (!ptx->IsFinal())
+ return false;
+ if (ptx->GetDepthInMainChain() >= 1)
+ return true;
+ if (ptx->GetDebit() <= 0)
+ return false;
+
+ if (mapPrev.empty())
+ foreach(const CMerkleTx& tx, vtxPrev)
+ mapPrev[tx.GetHash()] = &tx;
+
+ foreach(const CTxIn& txin, ptx->vin)
+ {
+ if (!mapPrev.count(txin.prevout.hash))
+ return false;
+ vWorkQueue.push_back(mapPrev[txin.prevout.hash]);
+ }
+ }
+ return true;
+ }
+
bool WriteToDisk()
{
return CWalletDB().WriteTx(GetHash(), *this);
@@ -1065,7 +1096,7 @@ public:
GetHash().ToString().substr(0,20).c_str(),
nVersion,
hashPrevBlock.ToString().substr(0,20).c_str(),
- hashMerkleRoot.ToString().substr(0,6).c_str(),
+ hashMerkleRoot.ToString().substr(0,10).c_str(),
nTime, nBits, nNonce,
vtx.size());
for (int i = 0; i < vtx.size(); i++)
@@ -1075,7 +1106,7 @@ public:
}
printf(" vMerkleTree: ");
for (int i = 0; i < vMerkleTree.size(); i++)
- printf("%s ", vMerkleTree[i].ToString().substr(0,6).c_str());
+ printf("%s ", vMerkleTree[i].ToString().substr(0,10).c_str());
printf("\n");
}
@@ -1233,7 +1264,7 @@ public:
{
return strprintf("CBlockIndex(nprev=%08x, pnext=%08x, nFile=%d, nBlockPos=%-6d nHeight=%d, merkle=%s, hashBlock=%s)",
pprev, pnext, nFile, nBlockPos, nHeight,
- hashMerkleRoot.ToString().substr(0,6).c_str(),
+ hashMerkleRoot.ToString().substr(0,10).c_str(),
GetBlockHash().ToString().substr(0,20).c_str());
}