searching tx in a given minute added corrected

This commit is contained in:
moneroexamples 2016-11-25 14:15:54 +08:00
parent 1460bc0c29
commit 53a7b381b8
2 changed files with 13 additions and 10 deletions

View File

@ -478,11 +478,8 @@ namespace xmreg
sizeof(key_timestamp)};
lmdb::val info_val;
lmdb::cursor cr = lmdb::cursor::open(rtxn, rdbi);
// set cursor the the first item
if (cr.get(key_to_find, info_val, MDB_SET_RANGE))
{
@ -523,7 +520,6 @@ namespace xmreg
try
{
lmdb::txn rtxn = lmdb::txn::begin(m_env, nullptr, MDB_RDONLY);
lmdb::dbi rdbi = lmdb::dbi::open(rtxn, db_name.c_str(), flags);
@ -531,13 +527,10 @@ namespace xmreg
sizeof(key_timestamp_start)};
lmdb::val info_val;
lmdb::cursor cr = lmdb::cursor::open(rtxn, rdbi);
uint64_t current_timestamp = key_timestamp_start;
// set cursor the the first item
if (cr.get(key_to_find, info_val, MDB_SET_RANGE))
{
@ -547,12 +540,13 @@ namespace xmreg
while (cr.get(key_to_find, info_val, MDB_NEXT))
{
current_timestamp = *key_to_find.data<uint64_t>();
//cout << current_timestamp << endl;
out_infos.push_back(*(info_val.data<output_info>()));
if (current_timestamp > key_timestamp_end)
{
break;
}
out_infos.push_back(*(info_val.data<output_info>()));
}
}
else

View File

@ -2394,6 +2394,8 @@ public:
= parse(search_text, "%Y-%m-%d %H:%M")
.time_since_epoch().count();
cout << "blk_timestamp_utc_start: " << blk_timestamp_utc_start << endl;
if (blk_timestamp_utc_start)
{
// seems we have a correct date!
@ -2413,11 +2415,19 @@ public:
// we found something. add all unique tx found to
// the vector we are going to show results with
// auto sort_by_timestamp =
// [](const pair<uint64_t, crypto::hash>& l,
// const pair<uint64_t, crypto::hash>& r)
// {
// l.first < l.second;
// };
set<string> unique_tx_found;
for (const auto &out_info: out_infos)
{
//cout << " - " << out_info << endl;
//unique_tx_found.insert(pod_to_hex(out_info.tx_hash));
unique_tx_found.insert(pod_to_hex(out_info.tx_hash));
}
@ -2426,7 +2436,6 @@ public:
vector<string>(unique_tx_found.begin(),
unique_tx_found.end()))
);
}
}
}