-
Notifications
You must be signed in to change notification settings - Fork 30
Add protobuf type as a transaction method parameter [ECR-3991] #1304
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
checkArgument(transactionMethods.containsKey(transactionId), | ||
"No method with transaction id (%s)", transactionId); | ||
TransactionMethodObject transactionMethodObject = transactionMethods.get(transactionId); | ||
Optional<Serializer> argumentsSerializer = transactionMethodObject.getArgumentsSerializer(); |
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.
TransactionMethodObject just exposes all of its properties. I suggest moving
the serialization logic into that class to separate responsibilities (routing vs
parameter resolution, mapping and invocation).
* transaction, possibly modifying the blockchain state. The method should: | ||
* <ul> | ||
* <li>be public | ||
* <li>have exactly two parameters - the |
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.
This sentence has become too complex, I suggest rewriting as the following:
"<p>The method should be {@code public} and have the following parameters: [as a list] 1. ... 2. ..."
* <ul> | ||
* <li>be public | ||
* <li>have exactly two parameters - the | ||
* {@linkplain TransactionMessage#getPayload() serialized transaction arguments} of type |
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 the 'transaction arguments', either as byte[]
or as a protobuf message. Please also add that the protobuf messages will be deserialized using a public static {@code #parseFrom(byte[])} method
|
||
private static MethodHandle toMethodHandle(Method method, Lookup lookup) { | ||
private static TransactionMethodObject toTransactionMethodObject(Method method, Lookup lookup) { | ||
Serializer argumentsSerializer = null; |
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.
I suggest specifying explicitly that the Serializer is unbounded <?> — in our case,
may produce any Object in its fromBytes
(in TransactionMethodObject API and in the variables declarations)
so that the intent is clear and there are no warnings.
|
||
private static MethodHandle toMethodHandle(Method method, Lookup lookup) { | ||
private static TransactionMethodObject toTransactionMethodObject(Method method, Lookup lookup) { | ||
Serializer argumentsSerializer = null; |
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 no-op serializer would be better than null: StandardSerializers.bytes
Method transactionMethod = | ||
ValidServiceProtobufArgument.class.getMethod("transactionMethod", | ||
TestProtoMessages.Point.class, TransactionContext.class); | ||
assertThat(singletonList(transactionMethod)) |
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.
The assertion is the other way around: assertthat(actualValue).matchesSomeCondition(conditionParams)
private final MethodHandle methodHandle; | ||
private final Serializer argumentsSerializer; | ||
|
||
TransactionMethodObject(MethodHandle methodHandle, @Nullable Serializer argumentsSerializer) { |
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.
Serializer<?>
and not null — see above.
Overview
Add protobuf type as a transaction method parameter.
See: https://jira.bf.local/browse/ECR-3991
Definition of Done