diff --git a/src/parser.cpp b/src/parser.cpp index 996a9b3c..a322801d 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -94,6 +94,9 @@ parser::parser(system::chain::selection context, // SCALE: LF2.2 @ 850K. + // Only used for electrum queries (255 is optimal otherwise). + configured.database.interval_depth = 11; + // database (archive) configured.database.header_buckets = 386'364; @@ -1391,7 +1394,7 @@ options_metadata parser::load_settings() THROWS ( "database.interval_depth", value(&configured.database.interval_depth), - "The interval depth for merkle proof optimization, defaults to '255' (disabled)." + "The interval depth for merkle proof optimization, defaults to '11'." ) /* header */ diff --git a/src/protocols/electrum/protocol_electrum_outputs.cpp b/src/protocols/electrum/protocol_electrum_outputs.cpp index 84078246..77c5b4d4 100644 --- a/src/protocols/electrum/protocol_electrum_outputs.cpp +++ b/src/protocols/electrum/protocol_electrum_outputs.cpp @@ -181,41 +181,30 @@ bool protocol_electrum::send_get_status(const std::string& tx_hash, } const auto& query = archive(); - const auto tx = query.to_tx(hash); - const auto output = query.to_output(tx, index); - if (output.is_terminal()) + const auto out = query.get_tx_history(hash); + if (!out.tx.is_valid()) { send_code(error::not_found); return false; } - // TODO: database query./////////////////////////////////////////////////// - size_t height{ database::history::rooted_height }; - if (const auto block = query.find_confirmed_block(tx); block.is_terminal()) - { - if (!query.is_confirmed_all_prevouts(tx)) - height = database::history::unrooted_height; - } - else if (!query.get_height(height, block)) + if (const auto ins = query.get_spenders_history(hash, index); ins.empty()) { - send_code(error::server_error); - return false; + send_result(object_t + { + { "height", to_unsigned(out.tx.height()) } + } , 64, BIND(complete, _1)); } - /////////////////////////////////////////////////////////////////////////// - - // TODO: query tx spenders sorted history.///////////////////////////////// - const database::histories spenders{}; - /////////////////////////////////////////////////////////////////////////// - - auto result = object_t{ { "height", to_unsigned(height) } }; - if (!spenders.empty()) + else { - const auto& spender = spenders.front().tx; - result["spender_txhash"] = encode_hash(spender.hash()); - result["spender_height"] = to_unsigned(spender.height()); + send_result(object_t + { + { "height", to_unsigned(out.tx.height()) }, + { "spender_txhash", encode_hash(ins.front().tx.hash()) }, + { "spender_height", to_unsigned(ins.front().tx.height()) } + }, 128, BIND(complete, _1)); } - send_result(std::move(result), 128, BIND(complete, _1)); return true; }