diff options
| author | Gavin Andresen <[email protected]> | 2013-01-25 12:55:52 -0800 |
|---|---|---|
| committer | Gavin Andresen <[email protected]> | 2013-01-25 12:55:52 -0800 |
| commit | 63cc7661a5dc40479a4492a678c38b1021b9ce92 (patch) | |
| tree | 8b8bfc427581dc17774a9f30c379dc4c687ae063 /src/txdb.cpp | |
| parent | Merge pull request #2207 from gavinandresen/leveldb19 (diff) | |
| parent | Add optional transaction index to databases (diff) | |
| download | discoin-63cc7661a5dc40479a4492a678c38b1021b9ce92.tar.xz discoin-63cc7661a5dc40479a4492a678c38b1021b9ce92.zip | |
Merge pull request #2168 from sipa/txindex
Add optional transaction index to databases
Diffstat (limited to 'src/txdb.cpp')
| -rw-r--r-- | src/txdb.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/txdb.cpp b/src/txdb.cpp index 93c5f23d8..78fa0279b 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -145,6 +145,29 @@ bool CCoinsViewDB::GetStats(CCoinsStats &stats) { return true; } +bool CBlockTreeDB::ReadTxIndex(const uint256 &txid, CDiskTxPos &pos) { + return Read(make_pair('t', txid), pos); +} + +bool CBlockTreeDB::WriteTxIndex(const std::vector<std::pair<uint256, CDiskTxPos> >&vect) { + CLevelDBBatch batch; + for (std::vector<std::pair<uint256,CDiskTxPos> >::const_iterator it=vect.begin(); it!=vect.end(); it++) + batch.Write(make_pair('t', it->first), it->second); + return WriteBatch(batch); +} + +bool CBlockTreeDB::WriteFlag(const std::string &name, bool fValue) { + return Write(std::make_pair('F', name), fValue ? '1' : '0'); +} + +bool CBlockTreeDB::ReadFlag(const std::string &name, bool &fValue) { + char ch; + if (!Read(std::make_pair('F', name), ch)) + return false; + fValue = ch == '1'; + return true; +} + bool CBlockTreeDB::LoadBlockIndexGuts() { leveldb::Iterator *pcursor = NewIterator(); |