rpc: sort txids by height for multiple addresses

This commit is contained in:
Braydon Fuller
2016-03-15 16:24:55 -04:00
committed by Braydon Fuller
parent f4d11ffc7c
commit 5b5f3f7d00
2 changed files with 22 additions and 3 deletions

View File

@@ -453,17 +453,24 @@ UniValue getaddresstxids(const UniValue& params, bool fHelp)
}
}
// TODO sort by height
std::set<std::string> txids;
std::vector<std::pair<int, std::string> > vtxids;
UniValue result(UniValue::VARR);
for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) {
int height = it->first.blockHeight;
std::string txid = it->first.txhash.GetHex();
if (txids.insert(txid).second) {
result.push_back(txid);
vtxids.push_back(std::make_pair(height, txid));
}
}
std::sort(vtxids.begin(), vtxids.end());
UniValue result(UniValue::VARR);
for (std::vector<std::pair<int, std::string> >::const_iterator it=vtxids.begin(); it!=vtxids.end(); it++) {
result.push_back(it->second);
}
return result;
}