Skip to content

Commit 649f28d

Browse files
authored
Merge pull request Blockstream#54 from mempool/junderw/limit-error-fix
Fix: Make error messages clearer
2 parents 9d6e266 + ab7cb3d commit 649f28d

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

src/electrum/server.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,10 @@ fn get_history(
636636
) -> Result<Vec<(Txid, Option<BlockId>)>> {
637637
// to avoid silently trunacting history entries, ask for one extra more than the limit and fail if it exists
638638
let history_txids = query.history_txids(scripthash, txs_limit + 1);
639-
ensure!(history_txids.len() <= txs_limit, ErrorKind::TooPopular);
639+
ensure!(
640+
history_txids.len() <= txs_limit,
641+
ErrorKind::TooManyTxs(txs_limit)
642+
);
640643
Ok(history_txids)
641644
}
642645

src/errors.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,14 @@ error_chain! {
1414
display("Iterrupted by signal {}", sig)
1515
}
1616

17-
TooPopular {
18-
description("Too many history entries")
19-
display("Too many history entries")
17+
TooManyUtxos(limit: usize) {
18+
description("Too many unspent transaction outputs. Contact support to raise limits.")
19+
display("Too many unspent transaction outputs (>{}). Contact support to raise limits.", limit)
20+
}
21+
22+
TooManyTxs(limit: usize) {
23+
description("Too many history transactions. Contact support to raise limits.")
24+
display("Too many history transactions (>{}). Contact support to raise limits.", limit)
2025
}
2126

2227
#[cfg(feature = "electrum-discovery")]

src/new_index/schema.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ impl ChainQuery {
671671

672672
// abort if the utxo set size excedees the limit at any point in time
673673
if utxos.len() > limit {
674-
bail!(ErrorKind::TooPopular)
674+
bail!(ErrorKind::TooManyUtxos(limit))
675675
}
676676
}
677677

0 commit comments

Comments
 (0)