Skip to content

Commit fdba19a

Browse files
authored
Merge pull request tronprotocol#1076 from tronprotocol/m_p2p3
p2p: modify trust node cfg
2 parents ec226ba + 367837b commit fdba19a

File tree

8 files changed

+15
-44
lines changed

8 files changed

+15
-44
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ private ChannelManager(final PeerServer peerServer, final PeerClient peerClient)
6666
"PeerServerThread").start();
6767
}
6868

69-
for (Node node : args.getTrustNodes()){
69+
for (Node node : args.getPassiveNodes()){
7070
trustPeers.put(new InetSocketAddress(node.getHost(), node.getPort()).getAddress() , node);
7171
}
7272
logger.info("Trust peer size {}", trustPeers.size());

src/main/java/org/tron/common/utils/Sha256Hash.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ public class Sha256Hash implements Serializable, Comparable<Sha256Hash> {
4545

4646
private final byte[] bytes;
4747

48-
private long blockNum;
49-
50-
5148
private byte[] generateBlockId(long blockNum, Sha256Hash blockHash) {
5249
byte[] numBytes = Longs.toByteArray(blockNum);
5350
byte[] hash = blockHash.getBytes();
@@ -62,22 +59,16 @@ private byte[] generateBlockId(long blockNum, byte[] blockHash) {
6259
return hash;
6360
}
6461

65-
public long getBlockNum(){
66-
return blockNum;
67-
}
68-
6962
public Sha256Hash(long num, byte[] hash) {
7063
byte[] rawHashBytes = this.generateBlockId(num, hash);
7164
checkArgument(rawHashBytes.length == LENGTH);
7265
this.bytes = rawHashBytes;
73-
this.blockNum = num;
7466
}
7567

7668
public Sha256Hash(long num, Sha256Hash hash) {
7769
byte[] rawHashBytes = this.generateBlockId(num, hash);
7870
checkArgument(rawHashBytes.length == LENGTH);
7971
this.bytes = rawHashBytes;
80-
this.blockNum = num;
8172
}
8273

8374
/**

src/main/java/org/tron/core/config/args/Args.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public class Args {
125125

126126
@Getter
127127
@Setter
128-
private List<Node> trustNodes;
128+
private List<Node> passiveNodes;
129129

130130
@Getter
131131
@Setter
@@ -277,7 +277,7 @@ public static void clearParam() {
277277
INSTANCE.nodeDiscoveryPersist = false;
278278
INSTANCE.nodeConnectionTimeout = 0;
279279
INSTANCE.activeNodes = Collections.emptyList();
280-
INSTANCE.trustNodes = Collections.emptyList();
280+
INSTANCE.passiveNodes = Collections.emptyList();
281281
INSTANCE.nodeChannelReadTimeout = 0;
282282
INSTANCE.nodeMaxActiveNodes = 30;
283283
INSTANCE.nodeMaxActiveNodesWithSameIp = 2;
@@ -414,7 +414,7 @@ public static void setParam(final String[] args, final String confFileName) {
414414

415415
INSTANCE.activeNodes = getNodes(config, "active.node");
416416

417-
INSTANCE.trustNodes = getNodes(config, "trust.node");
417+
INSTANCE.passiveNodes = getNodes(config, "passive.node");
418418

419419
INSTANCE.nodeChannelReadTimeout =
420420
config.hasPath("node.channel.read.timeout") ? config.getInt("node.channel.read.timeout")

src/main/java/org/tron/core/net/node/NodeImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ void sendInv() {
180180
send.forEach((peer, ids) ->
181181
ids.forEach((key, value) -> {
182182
if (key.equals(InventoryType.BLOCK)) {
183-
value.sort(Comparator.comparingDouble(value1 -> value1.getBlockNum()));
183+
value.sort(Comparator.comparingLong(value1 -> new BlockId(value1).getNum()));
184184
}
185185
peer.sendMessage(new InventoryMessage(value, key));
186186
}));
@@ -190,7 +190,7 @@ void sendFetch() {
190190
send.forEach((peer, ids) ->
191191
ids.forEach((key, value) -> {
192192
if (key.equals(InventoryType.BLOCK)) {
193-
value.sort(Comparator.comparingDouble(value1 -> value1.getBlockNum()));
193+
value.sort(Comparator.comparingLong(value1 -> new BlockId(value1).getNum()));
194194
}
195195
peer.sendMessage(new FetchInvDataMessage(value, key));
196196
}));

src/main/resources/config-backup.conf

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,6 @@ node {
8181
# Number of validate sign thread, default availableProcessors / 2
8282
# validateSignThreadNum = 16
8383

84-
active = [
85-
# Initial active peers
86-
# Sample entries:
87-
# "ip:port",
88-
# "ip:port"
89-
]
90-
9184
maxActiveNodes = 30
9285

9386
minParticipationRate = 33

src/main/resources/config-beta.conf

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,6 @@ node {
6363

6464
connection.timeout = 2
6565

66-
active = [
67-
# Sample entries:
68-
# { url = "enode://<hex nodeID>@hostname.com:30303" }
69-
# {
70-
# ip = hostname.com
71-
# port = 30303
72-
# nodeId = e437a4836b77ad9d9ffe73ee782ef2614e6d8370fcf62191a6e488276e23717147073a7ce0b444d485fff5a0c34c4577251a7a990cf80d8542e21b95aa8c5e6c
73-
# }
74-
"47.93.9.236:18888",
75-
"47.93.33.201:18888",
76-
"123.56.10.6:18888",
77-
"39.107.80.135:18888",
78-
"47.93.184.2:18888"
79-
]
8066

8167
maxActiveNodes = 30
8268

@@ -115,6 +101,14 @@ sync {
115101
node.count = 30
116102
}
117103

104+
active.node = [
105+
"47.93.9.236:18888",
106+
"47.93.33.201:18888",
107+
"123.56.10.6:18888",
108+
"39.107.80.135:18888",
109+
"47.93.184.2:18888"
110+
]
111+
118112
seed.node = {
119113
# List of the seed nodes
120114
# Seed nodes are stable full nodes

src/main/resources/config-localtest.conf

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,6 @@ node {
7070
# Number of validate sign thread, default availableProcessors / 2
7171
# validateSignThreadNum = 16
7272

73-
active = [
74-
# Initial active peers
75-
# Sample entries:
76-
# "ip:port",
77-
# "ip:port"
78-
]
79-
8073
maxActiveNodes = 30
8174

8275
minParticipationRate = 33

src/main/resources/config.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ active.node = [
125125
# "ip:port"
126126
]
127127

128-
trust.node = [
128+
passive.node = [
129129
# Passive accept connection in any case
130130
# Sample entries:
131131
# "ip:port",

0 commit comments

Comments
 (0)