Skip to content

Commit af6daaf

Browse files
committed
Merge branch 'develop' into feature/debug_net_limit
# Conflicts: # src/main/java/org/tron/core/witness/WitnessController.java
2 parents 9307ce2 + d05202a commit af6daaf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+929
-629
lines changed

.travis.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
sudo: required
22
language: java
33
jdk: oraclejdk8
4-
script:
5-
- sh tron.sh
6-
- ./gradlew lint
7-
- ./gradlew test
84
addons:
95
ssh_known_hosts:
106
- 47.93.9.236:22008
7+
sonarcloud:
8+
organization: tron-zhaohong
9+
token:
10+
secure: "KXWEeQ1elAoQ0XfR54TQWfhrIdDP0+2CYPv2X9aWpU/YDl7hqZBAjcCOAUGvlbyM54jtG6YMaWwG48jlrOwwl5l/VjWSnUXF+7ixQy5ki0Ci9s7Y1pTQwV9SpL8TLIK2TYqabN8Mw+FJULASXLjYr9GerbbcUbCPTmcL6mQKw6ivxxpNPmz4eNoKAEuOzruO9fTXGAV3yr8Nn85c+mVxV8EUhkR17zpE9O8fvzOtSnYArWNOSCgDBn0EG45UNNPF2vn44s1c3h3gX1m3WK6PeCXPgy3hPqRn3wTG+xglnbqthGpo2wt1rJ83af+BwdYwvPEcUq84yLgXcE/aMkTKcVAfPWBP/6vblaoI90jxCeFji+MdMimKZAqIXt7oLqDZVmIq65de5YC5s7QTSbzJNY/tsAu3dqzSfbUJY6CRNFDcoenVpvgQkqb37TkDah4mJM8EUjbu2A9Q2HSFbyCVsQJtdasuu9cBOf6azK3U0XgFNBc0y2aziZrTnX30q7bi+5L/mbTnRdXrDqBOqyPeGtT77UZfcajHHmEWU/e6gYWiA/c+K25n13DD53Au6gpnnQ6ALeUl/1gDwz3fPBebJ5bVWrkIcLj7bbysjzfOvQmDS6G13RNz58Hm0/B7bVtZTr1E1q6Z1zEJwbuJYEJASNcezAfK5x/hIfZTGNqT3M8="
11+
cache:
12+
directories:
13+
- '$HOME/.sonar/cache'
14+
script:
15+
- sh tron.sh
16+
- "./gradlew build"
17+
- sonar-scanner
1118
skip_build:
1219
- README.md:
1320
- LICENSE
@@ -17,6 +24,5 @@ deploy:
1724
on:
1825
branch: develop
1926
after_deploy:
20-
- ./gradlew stest
21-
27+
- "./gradlew stest"
2228

build.gradle

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
buildscript {
2+
repositories {
3+
maven { url 'http://mvnrepository.com' }
4+
mavenCentral()
5+
jcenter()
6+
}
7+
dependencies {
8+
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.3'
9+
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.2'
10+
}
11+
}
12+
plugins {
13+
id "org.sonarqube" version "2.6"
14+
}
15+
116
group 'org.tron'
217
version '1.0.0'
318

@@ -8,7 +23,6 @@ apply plugin: 'checkstyle'
823
apply plugin: 'com.github.johnrengelman.shadow'
924
apply plugin: "jacoco"
1025

11-
1226
sourceCompatibility = 1.8
1327
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
1428
mainClassName = 'org.tron.program.FullNode'
@@ -18,19 +32,6 @@ repositories {
1832
mavenLocal()
1933
mavenCentral()
2034
}
21-
22-
buildscript {
23-
repositories {
24-
maven { url 'http://mvnrepository.com' }
25-
mavenCentral()
26-
jcenter()
27-
}
28-
dependencies {
29-
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.3'
30-
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.2'
31-
}
32-
}
33-
3435
def versions = [
3536
checkstyle: '8.7',
3637
]
@@ -143,17 +144,15 @@ checkstyle {
143144
}
144145

145146
checkstyleMain {
146-
source 'src'
147-
include '**/*.java'
148-
exclude '**/gen/**'
147+
source = 'src/main/java'
149148
}
150149

151150
task lint(type: Checkstyle) {
152151
// Cleaning the old log because of the creation of the new ones (not sure if totaly needed)
153152
delete fileTree(dir: "${project.rootDir}/app/build/reports")
154153
source 'src'
155154
include '**/*.java'
156-
exclude '**/gen/**'
155+
exclude 'main/gen/**'
157156
// empty classpath
158157
classpath = files()
159158
//Failing the build
@@ -186,6 +185,7 @@ protobuf {
186185
protoc {
187186
artifact = "com.google.protobuf:protoc:3.5.1-1"
188187
}
188+
189189
plugins {
190190
grpc {
191191
artifact = 'io.grpc:protoc-gen-grpc-java:1.9.0'
@@ -236,9 +236,9 @@ jacocoTestReport {
236236
}
237237
}
238238

239-
task stest(type:Test){
240-
useTestNG{
241-
suites( file('src/test/resources/testng.xml') )
239+
task stest(type: Test) {
240+
useTestNG {
241+
suites(file('src/test/resources/testng.xml'))
242242
}
243243

244244
testLogging {
@@ -247,7 +247,7 @@ task stest(type:Test){
247247
}
248248
}
249249

250-
def binaryRelease(taskName,jarName,mainClass) {
250+
def binaryRelease(taskName, jarName, mainClass) {
251251
return tasks.create("${taskName}", Jar) {
252252
baseName = jarName
253253
version = null
@@ -267,7 +267,8 @@ def binaryRelease(taskName,jarName,mainClass) {
267267
}
268268
}
269269

270+
270271
artifacts {
271-
archives(binaryRelease('buildSolidityNodeJar','SolidityNode','org.tron.program.SolidityNode'),
272-
binaryRelease('buildFullNodeJar','FullNode','org.tron.program.FullNode'))
272+
archives(binaryRelease('buildSolidityNodeJar', 'SolidityNode', 'org.tron.program.SolidityNode'),
273+
binaryRelease('buildFullNodeJar', 'FullNode', 'org.tron.program.FullNode'))
273274
}

sonar-project.properties

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
sonar.projectKey=java-tron
2+
sonar.projectName=java-tron
3+
sonar.projectVersion=2.1
4+
# =====================================================
5+
# Meta-data for the project
6+
# =====================================================
7+
sonar.links.homepage=https://github.com/tronprotocol/java-tron
8+
sonar.links.ci=https://travis-ci.org/tronprotocol/java-tron
9+
sonar.links.scm=https://github.com/tronprotocol/java-tron
10+
sonar.links.issue=https://github.com/tronprotocol/java-tron/issues
11+
# =====================================================
12+
# Properties that will be shared amongst all modules
13+
# =====================================================
14+
# SQ standard properties
15+
sonar.sources=src/main
16+
sonar.tests=src/test
17+
sonar.java.binaries=build/classes
18+
# =====================================================
19+
# Properties that will be shared amongst all modules

src/main/java/org/tron/common/overlay/client/PeerClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
import org.springframework.stereotype.Component;
1919
import org.tron.common.overlay.discover.Node;
2020
import org.tron.common.overlay.discover.NodeHandler;
21-
import org.tron.common.overlay.message.ReasonCode;
2221
import org.tron.common.overlay.server.TronChannelInitializer;
2322
import org.tron.core.config.args.Args;
2423
import org.tron.core.net.node.NodeImpl;
24+
import org.tron.protos.Protocol.ReasonCode;
2525

2626
@Component
2727
public class PeerClient {

src/main/java/org/tron/common/overlay/discover/NodeStatistics.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import static java.lang.Math.min;
2222

2323
import java.util.concurrent.atomic.AtomicLong;
24-
import org.tron.common.overlay.message.ReasonCode;
24+
import org.tron.protos.Protocol.ReasonCode;
2525

2626
public class NodeStatistics {
2727

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package org.tron.common.overlay.message;
22

3-
import com.google.protobuf.InvalidProtocolBufferException;
43
import org.tron.core.net.message.MessageTypes;
54
import org.tron.protos.Protocol;
5+
import org.tron.protos.Protocol.ReasonCode;
66

77
public class DisconnectMessage extends P2pMessage {
88

@@ -16,7 +16,7 @@ public DisconnectMessage(byte type, byte[] rawData) throws Exception{
1616
public DisconnectMessage(ReasonCode reasonCode) {
1717
this.disconnectMessage = Protocol.DisconnectMessage
1818
.newBuilder()
19-
.setReason(Protocol.ReasonCode.forNumber(reasonCode.getReason()))
19+
.setReason(reasonCode)
2020
.build();
2121
this.type = MessageTypes.P2P_DISCONNECT.asByte();
2222
this.data = this.disconnectMessage.toByteArray();
@@ -26,6 +26,10 @@ public int getReason() {
2626
return this.disconnectMessage.getReason().getNumber();
2727
}
2828

29+
public ReasonCode getReasonCode() {
30+
return disconnectMessage.getReason();
31+
}
32+
2933
@Override
3034
public String toString() {
3135
return new StringBuilder().append(super.toString()).append("reason: ").append(this.disconnectMessage.getReason()).toString();

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

Lines changed: 0 additions & 123 deletions
This file was deleted.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@
3636
import org.tron.common.overlay.message.DisconnectMessage;
3737
import org.tron.common.overlay.message.HelloMessage;
3838
import org.tron.common.overlay.message.MessageCodec;
39-
import org.tron.common.overlay.message.ReasonCode;
4039
import org.tron.common.overlay.message.StaticMessages;
4140
import org.tron.core.db.ByteArrayWrapper;
4241
import org.tron.core.exception.P2pException;
4342
import org.tron.core.net.peer.PeerConnectionDelegate;
4443
import org.tron.core.net.peer.TronHandler;
44+
import org.tron.protos.Protocol.ReasonCode;
4545

4646
@Component
4747
@Scope("prototype")

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
*/
1818
package org.tron.common.overlay.server;
1919

20-
import static org.tron.common.overlay.message.ReasonCode.DUPLICATE_PEER;
21-
import static org.tron.common.overlay.message.ReasonCode.TOO_MANY_PEERS;
20+
import static org.tron.protos.Protocol.ReasonCode.DUPLICATE_PEER;
21+
import static org.tron.protos.Protocol.ReasonCode.TOO_MANY_PEERS;
2222

2323
import java.net.InetAddress;
2424
import java.net.InetSocketAddress;
@@ -36,9 +36,9 @@
3636
import org.springframework.beans.factory.annotation.Autowired;
3737
import org.springframework.stereotype.Component;
3838
import org.tron.common.overlay.client.PeerClient;
39-
import org.tron.common.overlay.message.ReasonCode;
4039
import org.tron.core.config.args.Args;
4140
import org.tron.core.db.ByteArrayWrapper;
41+
import org.tron.protos.Protocol.ReasonCode;
4242

4343

4444
@Component

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434
import org.tron.common.overlay.message.HelloMessage;
3535
import org.tron.common.overlay.message.P2pMessage;
3636
import org.tron.common.overlay.message.P2pMessageFactory;
37-
import org.tron.common.overlay.message.ReasonCode;
3837
import org.tron.core.config.args.Args;
3938
import org.tron.core.db.Manager;
4039
import org.tron.core.net.peer.PeerConnection;
40+
import org.tron.protos.Protocol.ReasonCode;
4141

4242
@Component
4343
@Scope("prototype")
@@ -92,7 +92,8 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf buffer, List<Object> ou
9292
break;
9393
case P2P_DISCONNECT:
9494
if (channel.getNodeStatistics() != null){
95-
channel.getNodeStatistics().nodeDisconnectedRemote(ReasonCode.fromInt(((DisconnectMessage) msg).getReason()));
95+
channel.getNodeStatistics()
96+
.nodeDisconnectedRemote(((DisconnectMessage) msg).getReasonCode());
9697
}
9798
channel.close();
9899
break;

0 commit comments

Comments
 (0)