Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1391,7 +1394,7 @@ options_metadata parser::load_settings() THROWS
(
"database.interval_depth",
value<uint16_t>(&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 */
Expand Down
39 changes: 14 additions & 25 deletions src/protocols/electrum/protocol_electrum_outputs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Loading