mirror of
https://codeberg.org/wownero/wownero-lws
synced 2026-01-08 22:55:15 -08:00
A few odds and ends after lookahead patch (#215)
This commit is contained in:
committed by
Lee *!* Clagett
parent
16111cae2c
commit
770e3b0ca4
@@ -1100,7 +1100,9 @@ namespace db
|
||||
|
||||
MDB_val key = lmdb::to_val(type);
|
||||
MDB_val value = lmdb::to_val(address);
|
||||
MLWS_LMDB_CHECK(mdb_cursor_get(cur.get(), &key, &value, MDB_GET_BOTH));
|
||||
const int err = mdb_cursor_get(cur.get(), &key, &value, MDB_GET_BOTH);
|
||||
if (err)
|
||||
return log_lmdb_error(err, __LINE__, __FILE__, MDB_NOTFOUND);
|
||||
return requests.get_value<request_info>(value);
|
||||
}
|
||||
|
||||
@@ -1148,11 +1150,7 @@ namespace db
|
||||
|
||||
const int err = mdb_cursor_get(cur.get(), &key, &value, MDB_GET_BOTH);
|
||||
if (err)
|
||||
{
|
||||
if (err != MDB_NOTFOUND)
|
||||
return log_lmdb_error(err, __LINE__, __FILE__);
|
||||
return {lmdb::error(err)}; // do not log MDB_NOTFOUND; expected
|
||||
}
|
||||
return log_lmdb_error(err, __LINE__, __FILE__, MDB_NOTFOUND);
|
||||
return subaddress_indexes.get_value<MONERO_FIELD(subaddress_map, index)>(value);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,14 +30,18 @@
|
||||
#include "lmdb/error.h" // monero/src
|
||||
#include "misc_log_ex.h" // monero/src
|
||||
|
||||
std::error_code lws::log_lmdb_error(const int err, const int line, const char* file)
|
||||
std::error_code lws::log_lmdb_error(const int err, const int line, const char* file, int skip)
|
||||
{
|
||||
const std::error_code code{lmdb::error(err)};
|
||||
char const* const name_end = std::strrchr(file, '/');
|
||||
if (name_end)
|
||||
file = name_end + 1;
|
||||
|
||||
MERROR("lmdb error (" << file << ':' << line << "): " << code.message());
|
||||
if (err != skip)
|
||||
{
|
||||
char const* const name_end = std::strrchr(file, '/');
|
||||
if (name_end)
|
||||
file = name_end + 1;
|
||||
|
||||
MERROR("lmdb error (" << file << ':' << line << "): " << code.message());
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,5 +38,5 @@
|
||||
|
||||
namespace lws
|
||||
{
|
||||
std::error_code log_lmdb_error(int err, int line, const char* file);
|
||||
std::error_code log_lmdb_error(int err, int line, const char* file, int skip = 0);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace lws { namespace version
|
||||
constexpr const char branch[] = "@MLWS_COMMIT_BRANCH@";
|
||||
constexpr const char commit[] = "@MLWS_COMMIT_HASH@";
|
||||
constexpr const char date[] = "@MLWS_COMMIT_DATE@";
|
||||
constexpr const char id[] = "0.4-alpha";
|
||||
constexpr const char id[] = "1.0-alpha";
|
||||
constexpr const char name[] = "monero-lws";
|
||||
|
||||
// openmonero is currently on 1.6 and we have multiple additions since then
|
||||
|
||||
@@ -89,7 +89,8 @@ namespace
|
||||
{
|
||||
wire::object(dest,
|
||||
wire::field("address", lws::db::address_string(self.value.address)),
|
||||
wire::field("start_height", self.value.start_height)
|
||||
wire::field("start_height", self.value.start_height),
|
||||
wire::field("lookahead", self.value.lookahead)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1078,6 +1078,9 @@ namespace lws
|
||||
if (!lws_server_addr.empty())
|
||||
rpc::scanner::server::start_acceptor(server, lws_server_addr, std::move(lws_server_pass));
|
||||
|
||||
// This is a hack to prevent racy shutdown
|
||||
boost::asio::post(self.io_, [&self] () { if (!self.is_running()) self.stop(); });
|
||||
|
||||
// Blocks until sigint, local scanner issue, storage issue, or exception
|
||||
self.io_.restart();
|
||||
self.io_.run();
|
||||
|
||||
Reference in New Issue
Block a user