Skip to content

Commit f8e9b35

Browse files
authored
Merge pull request #696 from evoskuil/master
Electrum blockchain.outpoint.get.status, default interval_depth to 11.
2 parents 7fa8050 + 34e8d23 commit f8e9b35

2 files changed

Lines changed: 18 additions & 26 deletions

File tree

src/parser.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ parser::parser(system::chain::selection context,
9494

9595
// SCALE: LF2.2 @ 850K.
9696

97+
// Only used for electrum queries (255 is optimal otherwise).
98+
configured.database.interval_depth = 11;
99+
97100
// database (archive)
98101

99102
configured.database.header_buckets = 386'364;
@@ -1391,7 +1394,7 @@ options_metadata parser::load_settings() THROWS
13911394
(
13921395
"database.interval_depth",
13931396
value<uint16_t>(&configured.database.interval_depth),
1394-
"The interval depth for merkle proof optimization, defaults to '255' (disabled)."
1397+
"The interval depth for merkle proof optimization, defaults to '11'."
13951398
)
13961399

13971400
/* header */

src/protocols/electrum/protocol_electrum_outputs.cpp

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -181,41 +181,30 @@ bool protocol_electrum::send_get_status(const std::string& tx_hash,
181181
}
182182

183183
const auto& query = archive();
184-
const auto tx = query.to_tx(hash);
185-
const auto output = query.to_output(tx, index);
186-
if (output.is_terminal())
184+
const auto out = query.get_tx_history(hash);
185+
if (!out.tx.is_valid())
187186
{
188187
send_code(error::not_found);
189188
return false;
190189
}
191190

192-
// TODO: database query.///////////////////////////////////////////////////
193-
size_t height{ database::history::rooted_height };
194-
if (const auto block = query.find_confirmed_block(tx); block.is_terminal())
195-
{
196-
if (!query.is_confirmed_all_prevouts(tx))
197-
height = database::history::unrooted_height;
198-
}
199-
else if (!query.get_height(height, block))
191+
if (const auto ins = query.get_spenders_history(hash, index); ins.empty())
200192
{
201-
send_code(error::server_error);
202-
return false;
193+
send_result(object_t
194+
{
195+
{ "height", to_unsigned(out.tx.height()) }
196+
} , 64, BIND(complete, _1));
203197
}
204-
///////////////////////////////////////////////////////////////////////////
205-
206-
// TODO: query tx spenders sorted history./////////////////////////////////
207-
const database::histories spenders{};
208-
///////////////////////////////////////////////////////////////////////////
209-
210-
auto result = object_t{ { "height", to_unsigned(height) } };
211-
if (!spenders.empty())
198+
else
212199
{
213-
const auto& spender = spenders.front().tx;
214-
result["spender_txhash"] = encode_hash(spender.hash());
215-
result["spender_height"] = to_unsigned(spender.height());
200+
send_result(object_t
201+
{
202+
{ "height", to_unsigned(out.tx.height()) },
203+
{ "spender_txhash", encode_hash(ins.front().tx.hash()) },
204+
{ "spender_height", to_unsigned(ins.front().tx.height()) }
205+
}, 128, BIND(complete, _1));
216206
}
217207

218-
send_result(std::move(result), 128, BIND(complete, _1));
219208
return true;
220209
}
221210

0 commit comments

Comments
 (0)