-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(net): add column codeVersion to HelloMessage #5584
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
import org.tron.core.net.message.MessageTypes; | ||
import org.tron.core.net.message.TronMessage; | ||
import org.tron.p2p.discover.Node; | ||
import org.tron.program.Version; | ||
import org.tron.protos.Discover.Endpoint; | ||
import org.tron.protos.Protocol; | ||
import org.tron.protos.Protocol.HelloMessage.Builder; | ||
|
@@ -61,6 +62,7 @@ public HelloMessage(Node from, long timestamp, ChainBaseManager chainBaseManager | |
builder.setNodeType(chainBaseManager.getNodeType().getType()); | ||
builder.setLowestBlockNum(chainBaseManager.isLiteNode() | ||
? chainBaseManager.getLowestBlockNum() : 0); | ||
builder.setCodeVersion(ByteString.copyFrom(Version.getVersion().getBytes())); | ||
|
||
this.helloMessage = builder.build(); | ||
this.type = MessageTypes.P2P_HELLO.asByte(); | ||
|
@@ -127,17 +129,23 @@ public String toString() { | |
.append("lowestBlockNum: ").append(helloMessage.getLowestBlockNum()).append("\n"); | ||
|
||
ByteString address = helloMessage.getAddress(); | ||
if (address != null && !address.isEmpty()) { | ||
if (!address.isEmpty()) { | ||
builder.append("address:") | ||
.append(StringUtil.encode58Check(address.toByteArray())).append("\n"); | ||
} | ||
|
||
ByteString signature = helloMessage.getSignature(); | ||
if (signature != null && !signature.isEmpty()) { | ||
if (!signature.isEmpty()) { | ||
builder.append("signature:") | ||
.append(signature.toByteArray().length).append("\n"); | ||
} | ||
|
||
ByteString codeVersion = helloMessage.getCodeVersion(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this codeVersion be null when received a HelloMessage from a node with previous version ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Every column in proto has default value. |
||
if (!codeVersion.isEmpty()) { | ||
builder.append("codeVersion:") | ||
.append(new String(codeVersion.toByteArray())).append("\n"); | ||
} | ||
|
||
return builder.toString(); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ | |
import org.tron.p2p.connection.Channel; | ||
import org.tron.p2p.discover.Node; | ||
import org.tron.p2p.utils.NetUtil; | ||
import org.tron.program.Version; | ||
import org.tron.protos.Discover.Endpoint; | ||
import org.tron.protos.Protocol; | ||
import org.tron.protos.Protocol.HelloMessage.Builder; | ||
|
@@ -99,6 +100,9 @@ public void testOkHelloMessage() | |
Node node = new Node(NetUtil.getNodeId(), a1.getAddress().getHostAddress(), null, a1.getPort()); | ||
HelloMessage helloMessage = new HelloMessage(node, System.currentTimeMillis(), | ||
ChainBaseManager.getChainBaseManager()); | ||
|
||
Assert.assertEquals(Version.getVersion(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
new String(helloMessage.getHelloMessage().getCodeVersion().toByteArray())); | ||
method.invoke(p2pEventHandler, peer, helloMessage.getSendBytes()); | ||
|
||
//dup hello message | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this field has some relationship with the codeVersion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, only code optimization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
933756
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ma ja sam na neki način i u teretani i ja Pa Pa
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://t.me/notpixel/app?startapp=f7012815595_s654946https://t.me/notgames_bot/squads?startapp=cmVmPTcwMTI4MTU1OTU=
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Zakačite stavke ostave kako ne bi istekle nakon 1 časa
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://t.me/notgames_bot/squads?startapp=cmVmPTcwMTI4MTU1OTU=0x1cfa5e643a3436d94732f65561f8c86e2ea910be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prevucite stavke iz međuspremnika da biste ih izbrisali
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🇦🇸🇦🇩🇦🇩Fg0x1cfa5e643a3436d94732f65561f8c86e2ea910beZakačite stavke ostave kako ne bi istekle nakon 1 časa