Browse Source

Merge pull request #1488 from sipa/noowner

Remove CTxDB::ReadOwnerTxes.
miguelfreitas
Jeff Garzik 13 years ago
parent
commit
219abac227
  1. 60
      src/db.cpp
  2. 1
      src/db.h

60
src/db.cpp

@ -404,66 +404,6 @@ bool CTxDB::ContainsTx(uint256 hash)
return Exists(make_pair(string("tx"), hash)); return Exists(make_pair(string("tx"), hash));
} }
bool CTxDB::ReadOwnerTxes(uint160 hash160, int nMinHeight, vector<CTransaction>& vtx)
{
assert(!fClient);
vtx.clear();
// Get cursor
Dbc* pcursor = GetCursor();
if (!pcursor)
return false;
unsigned int fFlags = DB_SET_RANGE;
loop
{
// Read next record
CDataStream ssKey(SER_DISK, CLIENT_VERSION);
if (fFlags == DB_SET_RANGE)
ssKey << string("owner") << hash160 << CDiskTxPos(0, 0, 0);
CDataStream ssValue(SER_DISK, CLIENT_VERSION);
int ret = ReadAtCursor(pcursor, ssKey, ssValue, fFlags);
fFlags = DB_NEXT;
if (ret == DB_NOTFOUND)
break;
else if (ret != 0)
{
pcursor->close();
return false;
}
// Unserialize
string strType;
uint160 hashItem;
CDiskTxPos pos;
int nItemHeight;
try {
ssKey >> strType >> hashItem >> pos;
ssValue >> nItemHeight;
}
catch (std::exception &e) {
return error("%s() : deserialize error", __PRETTY_FUNCTION__);
}
// Read transaction
if (strType != "owner" || hashItem != hash160)
break;
if (nItemHeight >= nMinHeight)
{
vtx.resize(vtx.size()+1);
if (!vtx.back().ReadFromDisk(pos))
{
pcursor->close();
return false;
}
}
}
pcursor->close();
return true;
}
bool CTxDB::ReadDiskTx(uint256 hash, CTransaction& tx, CTxIndex& txindex) bool CTxDB::ReadDiskTx(uint256 hash, CTransaction& tx, CTxIndex& txindex)
{ {
assert(!fClient); assert(!fClient);

1
src/db.h

@ -307,7 +307,6 @@ public:
bool AddTxIndex(const CTransaction& tx, const CDiskTxPos& pos, int nHeight); bool AddTxIndex(const CTransaction& tx, const CDiskTxPos& pos, int nHeight);
bool EraseTxIndex(const CTransaction& tx); bool EraseTxIndex(const CTransaction& tx);
bool ContainsTx(uint256 hash); bool ContainsTx(uint256 hash);
bool ReadOwnerTxes(uint160 hash160, int nHeight, std::vector<CTransaction>& vtx);
bool ReadDiskTx(uint256 hash, CTransaction& tx, CTxIndex& txindex); bool ReadDiskTx(uint256 hash, CTransaction& tx, CTxIndex& txindex);
bool ReadDiskTx(uint256 hash, CTransaction& tx); bool ReadDiskTx(uint256 hash, CTransaction& tx);
bool ReadDiskTx(COutPoint outpoint, CTransaction& tx, CTxIndex& txindex); bool ReadDiskTx(COutPoint outpoint, CTransaction& tx, CTxIndex& txindex);

Loading…
Cancel
Save