11package org .tron .core .net .message ;
22
3+ import org .tron .common .utils .Sha256Hash ;
34import org .tron .core .capsule .TransactionCapsule ;
45import org .tron .protos .Protocol ;
56import org .tron .protos .Protocol .Transaction ;
67
78public class TransactionMessage extends TronMessage {
89
910 private Transaction trx ;
11+ private TransactionCapsule transactionCapsule ;
1012
1113 public TransactionMessage (byte [] data ) throws Exception {
1214 this .type = MessageTypes .TRX .asByte ();
1315 this .data = data ;
1416 this .trx = Protocol .Transaction .parseFrom (data );
17+ this .transactionCapsule = new TransactionCapsule (this .trx );
1518 }
1619
1720 public TransactionMessage (Transaction trx ) {
1821 this .trx = trx ;
22+ this .transactionCapsule = new TransactionCapsule (this .trx );
1923 this .type = MessageTypes .TRX .asByte ();
2024 this .data = trx .toByteArray ();
2125 }
@@ -26,6 +30,11 @@ public String toString() {
2630 .append ("messageId: " ).append (super .getMessageId ()).toString ();
2731 }
2832
33+ @ Override
34+ public Sha256Hash getMessageId () {
35+ return this .transactionCapsule .getTransactionId ();
36+ }
37+
2938 @ Override
3039 public Class <?> getAnswerMessage () {
3140 return null ;
@@ -36,7 +45,7 @@ public Transaction getTransaction() {
3645 }
3746
3847 public TransactionCapsule getTransactionCapsule () {
39- return new TransactionCapsule ( getTransaction ()) ;
48+ return this . transactionCapsule ;
4049 }
4150
4251}
0 commit comments