Skip to content

Commit 2f61361

Browse files
committed
Merge remote-tracking branch 'origin/develop' into add_runtime_test_check
2 parents 421ed18 + f02a0a9 commit 2f61361

56 files changed

Lines changed: 701 additions & 934 deletions

Some content is hidden

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

‎.travis.yml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ cache:
1414
script:
1515
- sh tron.sh
1616
- "./gradlew build"
17-
- sh deploy.sh
1817

1918
skip_build:
2019
- README.md:

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

Lines changed: 65 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -26,75 +26,78 @@
2626
@Component
2727
public class PeerClient {
2828

29-
private static final Logger logger = LoggerFactory.getLogger("PeerClient");
30-
31-
@Autowired
32-
private ApplicationContext ctx;
33-
34-
@Autowired
35-
@Lazy
36-
private NodeImpl node;
37-
38-
private EventLoopGroup workerGroup;
39-
40-
public PeerClient() {
41-
workerGroup = new NioEventLoopGroup(0, new ThreadFactory() {
42-
AtomicInteger cnt = new AtomicInteger(0);
43-
@Override
44-
public Thread newThread(Runnable r) {
45-
return new Thread(r, "TronJClientWorker-" + cnt.getAndIncrement());
46-
}
47-
});
48-
}
49-
50-
public void connect(String host, int port, String remoteId) {
51-
try {
52-
ChannelFuture f = connectAsync(host, port, remoteId, false);
53-
f.sync().channel().closeFuture().sync();
54-
} catch (Exception e) {
55-
logger.info("PeerClient: Can't connect to " + host + ":" + port + " (" + e.getMessage() + ")");
56-
}
57-
}
58-
59-
public ChannelFuture connectAsync(NodeHandler nodeHandler, boolean discoveryMode) {
60-
Node node = nodeHandler.getNode();
61-
return connectAsync(node.getHost(), node.getPort(), node.getHexId(), discoveryMode)
62-
.addListener((ChannelFutureListener) future -> {
63-
if (!future.isSuccess()) {
64-
logger.error("connect to {}:{} fail,cause:{}", node.getHost(), node.getPort(),
65-
future.cause().getMessage());
66-
nodeHandler.getNodeStatistics().nodeDisconnectedLocal(ReasonCode.CONNECT_FAIL);
67-
nodeHandler.getNodeStatistics().notifyDisconnect();
68-
future.channel().close();
69-
}
70-
});
29+
private static final Logger logger = LoggerFactory.getLogger("PeerClient");
30+
31+
@Autowired
32+
private ApplicationContext ctx;
33+
34+
@Autowired
35+
@Lazy
36+
private NodeImpl node;
37+
38+
private EventLoopGroup workerGroup;
39+
40+
public PeerClient() {
41+
workerGroup = new NioEventLoopGroup(0, new ThreadFactory() {
42+
AtomicInteger cnt = new AtomicInteger(0);
43+
44+
@Override
45+
public Thread newThread(Runnable r) {
46+
return new Thread(r, "TronJClientWorker-" + cnt.getAndIncrement());
47+
}
48+
});
49+
}
50+
51+
public void connect(String host, int port, String remoteId) {
52+
try {
53+
ChannelFuture f = connectAsync(host, port, remoteId, false);
54+
f.sync().channel().closeFuture().sync();
55+
} catch (Exception e) {
56+
logger
57+
.info("PeerClient: Can't connect to " + host + ":" + port + " (" + e.getMessage() + ")");
7158
}
59+
}
60+
61+
public ChannelFuture connectAsync(NodeHandler nodeHandler, boolean discoveryMode) {
62+
Node node = nodeHandler.getNode();
63+
return connectAsync(node.getHost(), node.getPort(), node.getHexId(), discoveryMode)
64+
.addListener((ChannelFutureListener) future -> {
65+
if (!future.isSuccess()) {
66+
logger.error("connect to {}:{} fail,cause:{}", node.getHost(), node.getPort(),
67+
future.cause().getMessage());
68+
nodeHandler.getNodeStatistics().nodeDisconnectedLocal(ReasonCode.CONNECT_FAIL);
69+
nodeHandler.getNodeStatistics().notifyDisconnect();
70+
future.channel().close();
71+
}
72+
});
73+
}
7274

73-
public ChannelFuture connectAsync(String host, int port, String remoteId, boolean discoveryMode) {
75+
public ChannelFuture connectAsync(String host, int port, String remoteId, boolean discoveryMode) {
7476

75-
logger.info("connect peer {} {} {}", host, port, remoteId);
77+
logger.info("connect peer {} {} {}", host, port, remoteId);
7678

77-
TronChannelInitializer tronChannelInitializer = ctx.getBean(TronChannelInitializer.class, remoteId);
78-
tronChannelInitializer.setPeerDiscoveryMode(discoveryMode);
79-
tronChannelInitializer.setNodeImpl(node);
79+
TronChannelInitializer tronChannelInitializer = ctx
80+
.getBean(TronChannelInitializer.class, remoteId);
81+
tronChannelInitializer.setPeerDiscoveryMode(discoveryMode);
82+
tronChannelInitializer.setNodeImpl(node);
8083

81-
Bootstrap b = new Bootstrap();
82-
b.group(workerGroup);
83-
b.channel(NioSocketChannel.class);
84+
Bootstrap b = new Bootstrap();
85+
b.group(workerGroup);
86+
b.channel(NioSocketChannel.class);
8487

85-
b.option(ChannelOption.SO_KEEPALIVE, true);
86-
b.option(ChannelOption.MESSAGE_SIZE_ESTIMATOR, DefaultMessageSizeEstimator.DEFAULT);
87-
b.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, Args.getInstance().getNodeConnectionTimeout());
88-
b.remoteAddress(host, port);
88+
b.option(ChannelOption.SO_KEEPALIVE, true);
89+
b.option(ChannelOption.MESSAGE_SIZE_ESTIMATOR, DefaultMessageSizeEstimator.DEFAULT);
90+
b.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, Args.getInstance().getNodeConnectionTimeout());
91+
b.remoteAddress(host, port);
8992

90-
b.handler(tronChannelInitializer);
93+
b.handler(tronChannelInitializer);
9194

92-
// Start the client.
93-
return b.connect();
94-
}
95+
// Start the client.
96+
return b.connect();
97+
}
9598

96-
public void close() {
97-
workerGroup.shutdownGracefully();
98-
workerGroup.terminationFuture().syncUninterruptibly();
99-
}
99+
public void close() {
100+
workerGroup.shutdownGracefully();
101+
workerGroup.terminationFuture().syncUninterruptibly();
102+
}
100103
}

‎src/main/java/org/tron/common/overlay/client/WalletGrpcClient.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ public void shutdown() throws InterruptedException {
4242
}
4343

4444
public Account queryAccount(byte[] address) {
45-
ByteString addressBS = ByteString.copyFrom(address);
46-
Account request = Account.newBuilder().setAddress(addressBS).build();
45+
ByteString addressByteString = ByteString.copyFrom(address);
46+
Account request = Account.newBuilder().setAddress(addressByteString).build();
4747
return walletBlockingStub.getAccount(request);
4848
}
4949

@@ -96,8 +96,8 @@ public Optional<NodeList> listNodes() {
9696
}
9797

9898
public Optional<AssetIssueList> getAssetIssueByAccount(byte[] address) {
99-
ByteString addressBS = ByteString.copyFrom(address);
100-
Account request = Account.newBuilder().setAddress(addressBS).build();
99+
ByteString addressByteString = ByteString.copyFrom(address);
100+
Account request = Account.newBuilder().setAddress(addressByteString).build();
101101
AssetIssueList assetIssueList = walletBlockingStub
102102
.getAssetIssueByAccount(request);
103103
if (assetIssueList != null) {

‎src/main/java/org/tron/common/overlay/discover/DiscoverListener.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
* You should have received a copy of the GNU Lesser General Public License
1616
* along with the ethereumJ library. If not, see <http://www.gnu.org/licenses/>.
1717
*/
18+
1819
package org.tron.common.overlay.discover;
1920

2021
import org.tron.common.overlay.discover.node.NodeHandler;
2122
import org.tron.common.overlay.discover.node.NodeManager;
2223

2324
/**
2425
* Allows to handle discovered nodes state changes
25-
*
2626
* Created by Anton Nashatyrev on 21.07.2015.
2727
*/
2828
public interface DiscoverListener {

‎src/main/java/org/tron/common/overlay/discover/DiscoverServer.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* You should have received a copy of the GNU Lesser General Public License
1616
* along with the ethereumJ library. If not, see <http://www.gnu.org/licenses/>.
1717
*/
18+
1819
package org.tron.common.overlay.discover;
1920

2021
import io.netty.bootstrap.Bootstrap;

‎src/main/java/org/tron/common/overlay/discover/DiscoverTask.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* You should have received a copy of the GNU Lesser General Public License
1616
* along with the ethereumJ library. If not, see <http://www.gnu.org/licenses/>.
1717
*/
18+
1819
package org.tron.common.overlay.discover;
1920

2021
import java.util.ArrayList;

‎src/main/java/org/tron/common/overlay/discover/DiscoveryExecutor.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* You should have received a copy of the GNU Lesser General Public License
1616
* along with the ethereumJ library. If not, see <http://www.gnu.org/licenses/>.
1717
*/
18+
1819
package org.tron.common.overlay.discover;
1920

2021
import java.util.concurrent.Executors;

‎src/main/java/org/tron/common/overlay/discover/RefreshTask.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* You should have received a copy of the GNU Lesser General Public License
1616
* along with the ethereumJ library. If not, see <http://www.gnu.org/licenses/>.
1717
*/
18+
1819
package org.tron.common.overlay.discover;
1920

2021
import java.util.ArrayList;

‎src/main/java/org/tron/common/overlay/discover/dht/Bucket.java‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* You should have received a copy of the GNU Lesser General Public License
1616
* along with the ethereumJ library. If not, see <http://www.gnu.org/licenses/>.
1717
*/
18+
1819
package org.tron.common.overlay.discover.dht;
1920

2021
import java.util.ArrayList;
@@ -120,10 +121,8 @@ public void traverseTree(DoOnTree doOnTree) {
120121
doOnTree.call(this);
121122
}
122123

123-
/********************/
124-
// tree operations //
125124

126-
/********************/
125+
//tree operations
127126

128127
public interface DoOnTree {
129128

‎src/main/java/org/tron/common/overlay/discover/dht/DHTUtils.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* You should have received a copy of the GNU Lesser General Public License
1616
* along with the ethereumJ library. If not, see <http://www.gnu.org/licenses/>.
1717
*/
18+
1819
package org.tron.common.overlay.discover.dht;
1920

2021
import java.util.List;

0 commit comments

Comments
 (0)