main: get address deltas between range of block heights
This commit is contained in:
committed by
Braydon Fuller
parent
206882cd4b
commit
cad092aebb
13
src/txdb.cpp
13
src/txdb.cpp
@@ -172,16 +172,25 @@ bool CBlockTreeDB::WriteAddressIndex(const std::vector<std::pair<CAddressIndexKe
|
||||
return WriteBatch(batch);
|
||||
}
|
||||
|
||||
bool CBlockTreeDB::ReadAddressIndex(uint160 addressHash, int type, std::vector<std::pair<CAddressIndexKey, CAmount> > &addressIndex) {
|
||||
bool CBlockTreeDB::ReadAddressIndex(uint160 addressHash, int type,
|
||||
std::vector<std::pair<CAddressIndexKey, CAmount> > &addressIndex,
|
||||
int start, int end) {
|
||||
|
||||
boost::scoped_ptr<CDBIterator> pcursor(NewIterator());
|
||||
|
||||
pcursor->Seek(make_pair(DB_ADDRESSINDEX, CAddressIndexIteratorKey(type, addressHash)));
|
||||
if (start > 0 && end > 0) {
|
||||
pcursor->Seek(make_pair(DB_ADDRESSINDEX, CAddressIndexIteratorKey(type, addressHash, start)));
|
||||
} else {
|
||||
pcursor->Seek(make_pair(DB_ADDRESSINDEX, CAddressIndexIteratorKey(type, addressHash)));
|
||||
}
|
||||
|
||||
while (pcursor->Valid()) {
|
||||
boost::this_thread::interruption_point();
|
||||
std::pair<char,CAddressIndexKey> key;
|
||||
if (pcursor->GetKey(key) && key.first == DB_ADDRESSINDEX && key.second.hashBytes == addressHash) {
|
||||
if (end > 0 && key.second.blockHeight > end) {
|
||||
break;
|
||||
}
|
||||
CAmount nValue;
|
||||
if (pcursor->GetValue(nValue)) {
|
||||
addressIndex.push_back(make_pair(key.second, nValue));
|
||||
|
||||
Reference in New Issue
Block a user