Skip to content

Commit 227e894

Browse files
committed
mdf tron msg
1 parent 301c42f commit 227e894

3 files changed

Lines changed: 4 additions & 11 deletions

File tree

‎src/main/java/org/tron/common/overlay/message/MessageFactory.java‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616

1717
public abstract class MessageFactory {
1818

19-
public static String ERR_NO_SUCH_MSG = "No such message";
20-
public static String ERR_PARSE_FAILED = "parse message failed";
21-
2219
protected abstract Message create(byte[] data) throws Exception;
2320

2421
}

‎src/main/java/org/tron/core/net/message/TransactionsMessage.java‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,9 @@ public TransactionsMessage(List<Transaction> trxs) {
1919
}
2020

2121
public TransactionsMessage(byte[] data) throws Exception{
22-
try {
23-
this.type = MessageTypes.TRXS.asByte();
24-
this.data = data;
25-
this.transactions = Protocol.Transactions.parseFrom(data);
26-
}catch (Exception e){
27-
throw new P2pException(P2pException.TypeEnum.PARSE_MESSAGE_FAILED);
28-
}
22+
this.type = MessageTypes.TRXS.asByte();
23+
this.data = data;
24+
this.transactions = Protocol.Transactions.parseFrom(data);
2925
}
3026

3127
public Protocol.Transactions getTransactions() {

‎src/main/java/org/tron/core/net/message/TronMessageFactory.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public TronMessage create(byte[] data) throws Exception{
2727
private TronMessage create(byte type, byte[] packed) throws Exception{
2828
MessageTypes receivedTypes = MessageTypes.fromByte(type);
2929
if (receivedTypes == null){
30-
throw new RuntimeException(MessageFactory.ERR_NO_SUCH_MSG + ", type=" + type);
30+
throw new P2pException(P2pException.TypeEnum.NO_SUCH_MESSAGE, "type=" + type);
3131
}
3232
switch (receivedTypes) {
3333
case TRX:

0 commit comments

Comments
 (0)