Skip to content

Commit 071a15b

Browse files
committed
fix(net):modify BaseNet
1 parent 75fba7a commit 071a15b

4 files changed

Lines changed: 13 additions & 9 deletions

File tree

framework/src/main/java/org/tron/core/net/TronNetService.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ private static void setP2pConfig(P2pConfig config) {
8282
public void start() {
8383
try {
8484
init = true;
85-
P2pConfig config = new P2pConfig();
86-
setP2pConfig(getConfig(config));
85+
setP2pConfig(getConfig());
8786
p2pService.start(p2pConfig);
8887
p2pService.register(p2pEventHandler);
8988
advService.init();
@@ -148,7 +147,12 @@ public static boolean hasIpv4Stack(Set<String> ipSet) {
148147
return false;
149148
}
150149

151-
private P2pConfig getConfig(P2pConfig config) {
150+
private P2pConfig getConfig(){
151+
P2pConfig config = new P2pConfig();
152+
return updateConfig(config);
153+
}
154+
155+
private P2pConfig updateConfig(P2pConfig config) {
152156
List<InetSocketAddress> seeds = parameter.getSeedNode().getAddressList();
153157
seeds.addAll(nodePersistService.dbRead());
154158
logger.debug("Seed InetSocketAddress: {}", seeds);

framework/src/test/java/org/tron/core/net/BaseNet.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ public void run() {
103103
}
104104
});
105105
int tryTimes = 0;
106-
while (++tryTimes < 100 && tronNetDelegate == null) {
107-
Thread.sleep(3000);
108-
}
106+
do {
107+
Thread.sleep(3000); //coverage consumerInvToSpread,consumerInvToFetch in AdvService.init
108+
} while (++tryTimes < 100 && tronNetDelegate == null);
109109
}
110110

111111
@After
@@ -115,7 +115,7 @@ public void destroy() {
115115
for (PeerConnection peer : peerConnections) {
116116
peer.getChannel().close();
117117
}
118-
118+
Args.clearParam();
119119
context.destroy();
120120
FileUtil.deleteDir(new File(dbPath));
121121
}

framework/src/test/java/org/tron/core/net/services/EffectiveCheckServiceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public void destroy() {
4242
public void testNoIpv4() throws Exception {
4343
TronNetService tronNetService = context.getBean(TronNetService.class);
4444
Method privateMethod = tronNetService.getClass()
45-
.getDeclaredMethod("getConfig", P2pConfig.class);
45+
.getDeclaredMethod("updateConfig", P2pConfig.class);
4646
privateMethod.setAccessible(true);
4747
P2pConfig config = new P2pConfig();
4848
config.setIp(null);

framework/src/test/resources/config-test.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ node {
108108
# use your ipv6 address for node discovery and tcp connection, default false
109109
enableIpv6 = false
110110

111-
# if your node's highest block num is below than all your pees', try to acquire new connection
111+
# if your node's highest block num is below than all your pees', try to acquire new connection, default false
112112
effectiveCheckEnable = false
113113

114114
dns {

0 commit comments

Comments
 (0)