feat(mechanism): optimize address parsing of stake interfaces#5419
Conversation
| transactionLogTrigger.setFromAddress(StringUtil | ||
| .encode58Check(unfreezeBalanceContract.getOwnerAddress().toByteArray())); | ||
| } | ||
| if (Objects.nonNull(unfreezeBalanceContract.getReceiverAddress())) { |
There was a problem hiding this comment.
The frequency of these if statements is too high, you can encapsulate a function.
There was a problem hiding this comment.
OK, Ok, I encapsulate the code
framework/src/main/java/org/tron/common/logsfilter/capsule/TransactionLogTriggerCapsule.java
Outdated
Show resolved
Hide resolved
| transactionLogTrigger.setFromAddress(StringUtil | ||
| .encode58Check(freezeBalanceV2Contract.getOwnerAddress().toByteArray())); | ||
| } | ||
| transactionLogTrigger.setAssetAmount(freezeBalanceV2Contract.getFrozenBalance()); |
There was a problem hiding this comment.
transactionLogTrigger.setAssetName("trx"); ?
| transactionLogTrigger.setToAddress(StringUtil | ||
| .encode58Check(delegateResourceContract.getReceiverAddress().toByteArray())); | ||
| } | ||
| transactionLogTrigger.setAssetAmount( |
There was a problem hiding this comment.
transactionLogTrigger.setAssetName("trx");?
…nto feature/optimize_transaction_address_parsing_v2
| if (Objects.nonNull(withdrawExpireUnfreezeContract)) { | ||
| transactionLogTrigger.setFromAddress(StringUtil.encode58Check( | ||
| withdrawExpireUnfreezeContract.getOwnerAddress().toByteArray())); | ||
| transactionLogTrigger.setAssetAmount(transactionInfo.getWithdrawExpireAmount()); |
There was a problem hiding this comment.
transactionLogTrigger.setAssetName("trx");
| WithdrawExpireUnfreezeContract withdrawExpireUnfreezeContract = contractParameter | ||
| .unpack(WithdrawExpireUnfreezeContract.class); | ||
|
|
||
| if (Objects.nonNull(withdrawExpireUnfreezeContract)) { |
There was a problem hiding this comment.
contract cannot be null.
| UnfreezeBalanceContract unfreezeBalanceContract = contractParameter | ||
| .unpack(UnfreezeBalanceContract.class); | ||
|
|
||
| if (Objects.nonNull(unfreezeBalanceContract)) { |
There was a problem hiding this comment.
contract cannot be null.
| FreezeBalanceV2Contract freezeBalanceV2Contract = contractParameter | ||
| .unpack(FreezeBalanceV2Contract.class); | ||
|
|
||
| if (Objects.nonNull(freezeBalanceV2Contract)) { |
There was a problem hiding this comment.
contract cannot be null.
| UnfreezeBalanceV2Contract unfreezeBalanceV2Contract = contractParameter | ||
| .unpack(UnfreezeBalanceV2Contract.class); | ||
|
|
||
| if (Objects.nonNull(unfreezeBalanceV2Contract)) { |
There was a problem hiding this comment.
contract cannot be null.
| DelegateResourceContract delegateResourceContract = contractParameter | ||
| .unpack(DelegateResourceContract.class); | ||
|
|
||
| if (Objects.nonNull(delegateResourceContract)) { |
There was a problem hiding this comment.
contract cannot be null.
| UnDelegateResourceContract unDelegateResourceContract = contractParameter | ||
| .unpack(UnDelegateResourceContract.class); | ||
|
|
||
| if (Objects.nonNull(unDelegateResourceContract)) { |
There was a problem hiding this comment.
contract cannot be null.
| CancelAllUnfreezeV2Contract cancelAllUnfreezeV2Contract = contractParameter | ||
| .unpack(CancelAllUnfreezeV2Contract.class); | ||
|
|
||
| if (Objects.nonNull(cancelAllUnfreezeV2Contract)) { |
There was a problem hiding this comment.
contract cannot be null.
…_address_parsing_v2
…_address_parsing_v2
| if (!ByteString.EMPTY.equals(unfreezeBalanceContract.getReceiverAddress())) { | ||
| transactionLogTrigger.setToAddress(StringUtil | ||
| .encode58Check(unfreezeBalanceContract.getReceiverAddress().toByteArray())); | ||
| } |
There was a problem hiding this comment.
Does this need to be added?
transactionLogTrigger.setAssetName("trx");
transactionLogTrigger.setAssetAmount(transactionInfo.getUnfreezeAmount());|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #5419 +/- ##
=============================================
+ Coverage 61.35% 61.41% +0.05%
- Complexity 9348 9351 +3
=============================================
Files 846 846
Lines 50211 50273 +62
Branches 5583 5584 +1
=============================================
+ Hits 30805 30873 +68
+ Misses 17002 16981 -21
- Partials 2404 2419 +15 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…_address_parsing_v2
What does this PR do?
optimize address parsing of stake interfaces, close #5411
Why are these changes required?
This PR has been tested by:
Follow up
Extra details