feat(mechanism): optimize address parsing of stake interfaces by CarlChaoCarl · Pull Request #5419 · tronprotocol/java-tron

Conversation

@CarlChaoCarl

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 CarlChaoCarl changed the title feat(mechanism): optimize new transaction address parsing feat(mechanism): optimize address parsing of stake-related interfaces

Aug 15, 2023

xxo1shine

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 CarlChaoCarl changed the title feat(mechanism): optimize address parsing of stake-related interfaces feat(mechanism): optimize address parsing of stake interfaces

Aug 15, 2023

tomatoishealthy

halibobo1205

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.

halibobo1205

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:05

chaozhu added 2 commits

August 23, 2023 15:31
…nto feature/optimize_transaction_address_parsing_v2

halibobo1205

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

halibobo1205

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

halibobo1205

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

halibobo1205

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

halibobo1205

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

halibobo1205

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

halibobo1205

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

halibobo1205

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

halibobo1205

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

@codecov-commenter

tomatoishealthy

kuny0707

kuny0707

xxo1shine

chaozhu added 2 commits

September 1, 2023 13:22

Labels