retry if we get the method X is not available

This commit is contained in:
Bryan Stitt 2023-01-12 22:40:47 -08:00
parent 256cb5bd5d
commit 9f7d28b538
2 changed files with 25 additions and 12 deletions

View File

@ -298,6 +298,7 @@ These are not yet ordered. There might be duplicates. We might not actually need
- [x] ip detection needs work so that everything doesnt show up as 172.x.x.x
- i think this was done, but am not positive.
- [x] if private txs are disabled, only send trasactions to some of our servers. we were DOSing ourselves with transactions and slowing down sync
- [x] retry if we get "the method X is not available"
- [-] let users choose a % of reverts to log (or maybe x/second). someone like curve logging all reverts will be a BIG database very quickly
- this must be opt-in and spawned in the background since it will slow things down and will make their calls less private
- [ ] automatic pruning of old revert logs once too many are collected

View File

@ -725,22 +725,34 @@ impl Web3Connections {
}
// some errors should be retried on other nodes
if error.code == -32000 {
let error_msg = error.message.as_str();
match error.code {
-32000 => {
let error_msg = error.message.as_str();
// TODO: regex?
let retry_prefixes = [
"header not found",
"header for hash not found",
"missing trie node",
"node not started",
"RPC timeout",
];
for retry_prefix in retry_prefixes {
if error_msg.starts_with(retry_prefix) {
// TODO: regex?
let retry_prefixes = [
"header not found",
"header for hash not found",
"missing trie node",
"node not started",
"RPC timeout",
];
for retry_prefix in retry_prefixes {
if error_msg.starts_with(retry_prefix) {
continue;
}
}
}
-32601 => {
let error_msg = error.message.as_str();
if error_msg.starts_with("the method")
&& error_msg.ends_with("is not available")
{
continue;
}
}
_ => {}
}
} else {
// trace!(?response, "rpc success");