Skip to content

Commit 4cf343a

Browse files
authored
Merge pull request #323 from tronprotocol/p2p_hellp_msg
Solve message encapsulation and send message exception problems
2 parents 9832f89 + b67dead commit 4cf343a

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/main/java/org/tron/common/overlay/message/DisconnectMessage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ public DisconnectMessage(ReasonCode reasonCode) {
2525
.newBuilder()
2626
.setReason(Protocol.ReasonCode.forNumber(reasonCode.asByte()))
2727
.build();
28-
unpacked = true;
2928
this.type = MessageTypes.P2P_DISCONNECT.asByte();
29+
this.data = this.disconnectMessage.toByteArray();
3030
}
3131

3232
private void unPack() {

src/main/java/org/tron/common/overlay/message/HelloMessage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public byte[] getData() {
6767
/**
6868
* Get the version of p2p protocol.
6969
*/
70-
public byte getVersion() {
70+
public int getVersion() {
7171
return (byte) this.helloMessage.getVersion();
7272
}
7373

src/main/java/org/tron/common/overlay/server/HandshakeHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf buffer, List<Object> ou
8383
final HelloMessage helloMessage = (HelloMessage) msg;
8484

8585
if (helloMessage.getVersion() != Args.getInstance().getNodeP2pVersion()) {
86-
channelManager.disconnect(channel, ReasonCode.INCOMPATIBLE_PROTOCOL);
86+
ctx.close();
8787
return;
8888
}
8989

0 commit comments

Comments
 (0)