-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: check if coin already in cache #1549
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC the plus here is that we prevent the user from hitting the network with a tx that's bound to fail, which is great.
I have two concerns, correct me if I'm wrong:
- We might get inconsistent results because of the time based eviction. E.g. user stalls submitting the second transaction long enough for the cache to drop the entry.
- We don't evict when txs are dropped by the node which means we might prevent the user from executing a valid transaction at some point.
CoinTypeId::Nonce(nonce) => format!("message with nonce: `{nonce}`"), | ||
}; | ||
Err(Error::Transaction(transaction::Reason::Validation( | ||
format!("{msg} already in cache. Wallet address: `{addr}`, asset id: `{asset_id}`"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the user lacks some context on how the cache or UTXO based systems work, this message might not be enough.
Saying something like:
"a transaction with this input was submitted recently, attempting to spend it again will result in an error".
should give a better idea of what the issue is.
^ Had meeting with @segfault-magnet and @MujkicA where we went through the uses cases and we came to the above conclusions. |
Summary
Checks if any of the inputs is already cached before sending/submitting the tx.