Skip to content

Commit d05202a

Browse files
authored
Merge pull request #848 from tronprotocol/p2p_msg
modify trx msg
2 parents 3342e96 + a4037ee commit d05202a

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/main/java/org/tron/core/net/message/TransactionMessage.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,33 @@
88
public class TransactionMessage extends TronMessage {
99

1010
private Transaction trx;
11+
private TransactionCapsule transactionCapsule;
1112

1213
public TransactionMessage(byte[] data) throws Exception {
1314
this.type = MessageTypes.TRX.asByte();
1415
this.data = data;
1516
this.trx = Protocol.Transaction.parseFrom(data);
17+
this.transactionCapsule = new TransactionCapsule(this.trx);
1618
}
1719

1820
public TransactionMessage(Transaction trx) {
1921
this.trx = trx;
22+
this.transactionCapsule = new TransactionCapsule(this.trx);
2023
this.type = MessageTypes.TRX.asByte();
2124
this.data = trx.toByteArray();
2225
}
2326

24-
@Override
25-
public Sha256Hash getMessageId() {
26-
return getTransactionCapsule().getTransactionId();
27-
}
28-
2927
@Override
3028
public String toString() {
3129
return new StringBuilder().append(super.toString())
3230
.append("messageId: ").append(super.getMessageId()).toString();
3331
}
3432

33+
@Override
34+
public Sha256Hash getMessageId() {
35+
return this.transactionCapsule.getTransactionId();
36+
}
37+
3538
@Override
3639
public Class<?> getAnswerMessage() {
3740
return null;
@@ -42,7 +45,7 @@ public Transaction getTransaction() {
4245
}
4346

4447
public TransactionCapsule getTransactionCapsule() {
45-
return new TransactionCapsule(getTransaction());
48+
return this.transactionCapsule;
4649
}
4750

4851
}

0 commit comments

Comments
 (0)