feat(mechanism): optimize address parsing of stake interfaces by CarlChaoCarl · Pull Request #5419 · tronprotocol/java-tron
Conversation
What does this PR do?
optimize address parsing of stake interfaces, close #5411
Why are these changes required?
This PR has been tested by:
- Unit Tests
- Manual Testing
Follow up
Extra details
CarlChaoCarl
changed the title
feat(mechanism): optimize new transaction address parsing
feat(mechanism): optimize address parsing of stake-related interfaces
| transactionLogTrigger.setFromAddress(StringUtil | ||
| .encode58Check(unfreezeBalanceContract.getOwnerAddress().toByteArray())); | ||
| } | ||
| if (Objects.nonNull(unfreezeBalanceContract.getReceiverAddress())) { |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The frequency of these if statements is too high, you can encapsulate a function.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, Ok, I encapsulate the code
CarlChaoCarl
changed the title
feat(mechanism): optimize address parsing of stake-related interfaces
feat(mechanism): optimize address parsing of stake interfaces
| transactionLogTrigger.setFromAddress(StringUtil | ||
| .encode58Check(freezeBalanceV2Contract.getOwnerAddress().toByteArray())); | ||
| } | ||
| transactionLogTrigger.setAssetAmount(freezeBalanceV2Contract.getFrozenBalance()); |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
transactionLogTrigger.setAssetName("trx"); ?
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK,I get it.
| transactionLogTrigger.setToAddress(StringUtil | ||
| .encode58Check(delegateResourceContract.getReceiverAddress().toByteArray())); | ||
| } | ||
| transactionLogTrigger.setAssetAmount( |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
transactionLogTrigger.setAssetName("trx");?
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK,I get it.
chaozhu added 2 commits
August 23, 2023 11:05chaozhu added 2 commits
August 23, 2023 15:31…nto feature/optimize_transaction_address_parsing_v2
| if (Objects.nonNull(withdrawExpireUnfreezeContract)) { | ||
| transactionLogTrigger.setFromAddress(StringUtil.encode58Check( | ||
| withdrawExpireUnfreezeContract.getOwnerAddress().toByteArray())); | ||
| transactionLogTrigger.setAssetAmount(transactionInfo.getWithdrawExpireAmount()); |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
transactionLogTrigger.setAssetName("trx");
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I get it
| WithdrawExpireUnfreezeContract withdrawExpireUnfreezeContract = contractParameter | ||
| .unpack(WithdrawExpireUnfreezeContract.class); | ||
|
|
||
| if (Objects.nonNull(withdrawExpireUnfreezeContract)) { |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contract cannot be null.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I get it
| UnfreezeBalanceContract unfreezeBalanceContract = contractParameter | ||
| .unpack(UnfreezeBalanceContract.class); | ||
|
|
||
| if (Objects.nonNull(unfreezeBalanceContract)) { |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contract cannot be null.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I get it
| FreezeBalanceV2Contract freezeBalanceV2Contract = contractParameter | ||
| .unpack(FreezeBalanceV2Contract.class); | ||
|
|
||
| if (Objects.nonNull(freezeBalanceV2Contract)) { |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contract cannot be null.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I get it
| UnfreezeBalanceV2Contract unfreezeBalanceV2Contract = contractParameter | ||
| .unpack(UnfreezeBalanceV2Contract.class); | ||
|
|
||
| if (Objects.nonNull(unfreezeBalanceV2Contract)) { |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contract cannot be null.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I get it
| DelegateResourceContract delegateResourceContract = contractParameter | ||
| .unpack(DelegateResourceContract.class); | ||
|
|
||
| if (Objects.nonNull(delegateResourceContract)) { |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contract cannot be null.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I get it
| UnDelegateResourceContract unDelegateResourceContract = contractParameter | ||
| .unpack(UnDelegateResourceContract.class); | ||
|
|
||
| if (Objects.nonNull(unDelegateResourceContract)) { |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contract cannot be null.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I get it
| CancelAllUnfreezeV2Contract cancelAllUnfreezeV2Contract = contractParameter | ||
| .unpack(CancelAllUnfreezeV2Contract.class); | ||
|
|
||
| if (Objects.nonNull(cancelAllUnfreezeV2Contract)) { |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contract cannot be null.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I get it
chaozhu and others added 5 commits
August 24, 2023 20:16| if (!ByteString.EMPTY.equals(unfreezeBalanceContract.getReceiverAddress())) { | ||
| transactionLogTrigger.setToAddress(StringUtil | ||
| .encode58Check(unfreezeBalanceContract.getReceiverAddress().toByteArray())); | ||
| } |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be added?
transactionLogTrigger.setAssetName("trx"); transactionLogTrigger.setAssetAmount(transactionInfo.getUnfreezeAmount());
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I get it
chaozhu added 2 commits
September 1, 2023 13:22This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters