|
11 | 11 | import org.tron.core.net.message.MessageTypes; |
12 | 12 | import org.tron.core.net.message.TronMessage; |
13 | 13 | import org.tron.p2p.discover.Node; |
| 14 | +import org.tron.program.Version; |
14 | 15 | import org.tron.protos.Discover.Endpoint; |
15 | 16 | import org.tron.protos.Protocol; |
16 | 17 | import org.tron.protos.Protocol.HelloMessage.Builder; |
@@ -61,6 +62,7 @@ public HelloMessage(Node from, long timestamp, ChainBaseManager chainBaseManager |
61 | 62 | builder.setNodeType(chainBaseManager.getNodeType().getType()); |
62 | 63 | builder.setLowestBlockNum(chainBaseManager.isLiteNode() |
63 | 64 | ? chainBaseManager.getLowestBlockNum() : 0); |
| 65 | + builder.setCodeVersion(ByteString.copyFrom(Version.getVersion().getBytes())); |
64 | 66 |
|
65 | 67 | this.helloMessage = builder.build(); |
66 | 68 | this.type = MessageTypes.P2P_HELLO.asByte(); |
@@ -127,17 +129,23 @@ public String toString() { |
127 | 129 | .append("lowestBlockNum: ").append(helloMessage.getLowestBlockNum()).append("\n"); |
128 | 130 |
|
129 | 131 | ByteString address = helloMessage.getAddress(); |
130 | | - if (address != null && !address.isEmpty()) { |
| 132 | + if (!address.isEmpty()) { |
131 | 133 | builder.append("address:") |
132 | 134 | .append(StringUtil.encode58Check(address.toByteArray())).append("\n"); |
133 | 135 | } |
134 | 136 |
|
135 | 137 | ByteString signature = helloMessage.getSignature(); |
136 | | - if (signature != null && !signature.isEmpty()) { |
| 138 | + if (!signature.isEmpty()) { |
137 | 139 | builder.append("signature:") |
138 | 140 | .append(signature.toByteArray().length).append("\n"); |
139 | 141 | } |
140 | 142 |
|
| 143 | + ByteString codeVersion = helloMessage.getCodeVersion(); |
| 144 | + if (!codeVersion.isEmpty()) { |
| 145 | + builder.append("codeVersion:") |
| 146 | + .append(new String(codeVersion.toByteArray())).append("\n"); |
| 147 | + } |
| 148 | + |
141 | 149 | return builder.toString(); |
142 | 150 | } |
143 | 151 |
|
|
0 commit comments