-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Rationale
TransactionLog combined with EventPlugin mechanism is an important way to analyze transaction data.
At present, it is found that when calling the query transaction interface of the tron-eventquery service,
one of the transaction's fields returned is as follows:
{"contractType": "UnDelegateResourceContract","fromAddress": null,"toAddress": null}
To the transaction type: UnDelegateResourceContract, the returned fields: fromAddress, toAddress are not correctly assigned.
Below are the stake-related transactions include:
- UnfreezeBalanceContract
- FreezeBalanceV2Contract
- UnfreezeBalanceV2Contract
- WithdrawExpireUnfreezeContract
- DelegateResourceContract
- UnDelegateResourceContract
- CancelAllUnfreezeV2Contract
The fromAddress and toAddress should be correctly parsed into the TransactionLog, and then the fields will be correct when the query transaction of the tron-eventquery service is called.
Why should this feature exist?
Before writing the new transaction into the transactionLog, the address needs to be parsed correctly
Implementation
For the new transactions, to correctly parse fromAddress and toAddress to TransactionLog, the following code must be modified: class TransactionLogTriggerCapsule, method TransactionLogTriggerCapsule
public TransactionLogTriggerCapsule(TransactionCapsule trxCapsule, BlockCapsule blockCapsule,
int txIndex, long preCumulativeEnergyUsed, long preCumulativeLogCount,
TransactionInfo transactionInfo, long energyUnitPrice) {
case UnfreezeBalanceContract:
...
break;
case FreezeBalanceV2Contract:
…
break;
case UnfreezeBalanceV2Contract:
…
break;
case WithdrawExpireUnfreezeContract:
…
break;
case DelegateResourceContract:
…
break;
case UnDelegateResourceContract:
…
break;
case CancelAllUnfreezeV2Contract:
…
break;
}In this way, for the newly added transactions, fromAddress and toAddress are able to be correctly parsed and then assigned to TransactionLogTrigger.
Furthermore, for the TransactionLog's message event, an "extMap" field has been added, originally designed as a general extension field.Currently, this field is only assigned a value for transaction logs of the "CancelAllUnfreezeV2Contract" type; other transactions do not receive a value.For "CancelAllUnfreezeV2Contract" type transactions, it represents the amount of resources (bandwidth energy) canceled by the operation of canceling "UnfreezeV2" type transactions.