-
Notifications
You must be signed in to change notification settings - Fork 30
[ECR-2746] Transaction Preconditions #1351
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
Conversation
* check(amount <= balance, (byte)3, | ||
* "Not enough money. Operation amount is %s, but actual balance was %s", | ||
* amount, balance); | ||
* }</pre> |
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.
+ a back link from ExecutionException.
* @see ExecutionException
* amount, balance); | ||
* }</pre> | ||
*/ | ||
public final class Preconditions { |
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.
ExecutionPreconditions (as they are tied to ExecException)? That will allow
to use both Guava's and ours as simple names.
Also, I'd ponder on the name of 'check' methods. 'check' seems too vague. Shall
we use 'checkExecution' (because Execution Exception, also, it is similar to Guava's naming 'checkArgument' -> Illegal Argument Exception)? Do you have any other names in mind?
* | ||
* <p>See {@link #check(boolean, byte, String, Object...)} for details. | ||
*/ | ||
public static void check(boolean expression, byte errorCode, |
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.
How the set of overloads was choosen?
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.
A fascinating talk on how they do it at Google, helping design not only APIs but languages: https://www.youtube.com/watch?v=sPW2Pz2dI9E&list=LLXsc0bWTsranC6H8z1IOoXg&index=10&t=0s (@vitvakatu , @slowli )
That's what we often miss — data on the actual usages to make informed decisions, instead of speculations 🙃
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.
just tried to cover most frequently used cases + inspired by guava lib 🙃
* @param expression a boolean expression | ||
* @param errorCode execution error code | ||
* @param errorMessageTemplate execution error description template to use if the check fails. | ||
* The template could have placeholders {@code %s} which will be replaces by arguments |
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.
replaced
exonum-java-binding/CHANGELOG.md
Outdated
`ProofListIndexProxy.getProof`, `ProofListIndexProxy.getRangeProof` and | ||
`ListProof`. | ||
- `ProofEntryIndexProxy` collection. | ||
- Transaction precondition utility methods. |
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.
Specify class name?
MapIndex<PublicKey, Wallet> wallets = schema.wallets(); | ||
|
||
checkExecution(!wallets.containsKey(ownerPublicKey), WALLET_ALREADY_EXISTS.errorCode); | ||
ExecutionPreconditions |
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.
Shan't we use static imports for it?
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.
And QA service, please 🙃
Overview
See: https://jira.bf.local/browse/ECR-2746
Definition of Done