Skip to content

Commit 21b2bb7

Browse files
committed
fix conflict
2 parents dfbd982 + ae15331 commit 21b2bb7

75 files changed

Lines changed: 3358 additions & 1335 deletions

File tree

Some content is hidden

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

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,4 @@ src/main/resources/META-INF/
5151
/output_witness/
5252
output*
5353
nodeId.properties
54+
Wallet

‎English version of TRON Protocol document.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
## The protocol of TRON is defined by Google Protobuf and contains a range of layers, from account, block to transfer.
55

66
+ There are 3 types of account—basic account, asset release account and contract account, and attributes included in each account are name, types, address, balance and related asset.
7-
+ A basic account is able to apply to be a validation node, which has serval parameters, including extra attributes, public key, URL, voting statistics, history performance, etc.
7+
+ A basic account is able to apply to be a validation node, which has several parameters, including extra attributes, public key, URL, voting statistics, history performance, etc.
88

99
There are three different `Account types`: `Normal`, `AssetIssue`, `Contract`.
1010

‎README.md‎

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ TRON Protocol and the TVM allow anyone to develop DAPPs for themselves or their
6363
* JDK 1.8 (JDK 1.9+ are not supported yet)
6464
* On Linux Ubuntu system (e.g. Ubuntu 16.04.4 LTS), ensure that the machine has [__Oracle JDK 8__](https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-ubuntu-16-04), instead of having __Open JDK 8__ in the system. If you are building the source code by using __Open JDK 8__, you will get [__Build Failed__](https://github.com/tronprotocol/java-tron/issues/337) result.
6565

66-
## Getting the code
66+
## Getting the code with git
6767

6868
* Use Git from the Terminal, see the [Setting up Git](https://help.github.com/articles/set-up-git/) and [Fork a Repo](https://help.github.com/articles/fork-a-repo/) articles.
6969
* develop branch: the newnest code
@@ -78,6 +78,42 @@ git checkout -t origin/master
7878

7979
* If you'd rather not use Git, [Download the ZIP](https://github.com/tronprotocol/java-tron/archive/develop.zip)
8080

81+
## Including java-tron as dependency
82+
83+
* If you don't want to checkout the code and build the project, you can include it directly as a dependency
84+
85+
**Using gradle:**
86+
87+
```
88+
repositories {
89+
maven { url 'https://jitpack.io' }
90+
}
91+
dependencies {
92+
implementation 'com.github.tronprotocol:java-tron:develop-SNAPSHOT'
93+
}
94+
```
95+
96+
**Using maven:**
97+
98+
```xml
99+
...
100+
<repositories>
101+
<repository>
102+
<id>jitpack.io</id>
103+
<url>https://jitpack.io</url>
104+
</repository>
105+
</repositories>
106+
...
107+
<dependency>
108+
<groupId>com.github.tronprotocol</groupId>
109+
<artifactId>java-tron</artifactId>
110+
<version>develop-SNAPSHOT</version><!--You can use any of the tag/branch name available-->
111+
</dependency>
112+
```
113+
114+
115+
116+
81117
## Building from source code
82118

83119
* Build in the Terminal
@@ -477,6 +513,10 @@ Then observe whether block synchronization success,If synchronization successf
477513
478514
Read the [Quick Start](http://wiki.tron.network/en/latest/Quick_Start.html).
479515
516+
# Advanced Configurations
517+
518+
Read the [Advanced Configurations](src/main/java/org/tron/core/config/README.md).
519+
480520
# Community
481521
482522
* [Slack](https://join.slack.com/t/tronfoundation/shared_invite/enQtMzAzNzg4NTI4NDM3LTAyZGQzMzEzMjNkNDU0ZjNkNTA4OTYyNTA5YWZmYjE3MTEyOWZhNzljNzQwODM3NDQ0OWRiMTIyMDhlYzgyOGQ)

‎build.gradle‎

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,29 @@ apply plugin: 'application'
2222
apply plugin: 'checkstyle'
2323
apply plugin: 'com.github.johnrengelman.shadow'
2424
apply plugin: "jacoco"
25+
apply plugin: 'maven-publish'
2526

2627
sourceCompatibility = 1.8
2728
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
2829
mainClassName = 'org.tron.program.FullNode'
2930

31+
publishing {
32+
publications {
33+
mavenJava(MavenPublication) {
34+
from components.java
35+
artifact sourceJar
36+
}
37+
}
38+
repositories {
39+
mavenLocal()
40+
}
41+
}
42+
43+
task sourceJar(type: Jar, dependsOn: classes) {
44+
classifier 'sources'
45+
from sourceSets.main.allSource
46+
}
47+
3048
repositories {
3149
maven { url 'http://mvnrepository.com' }
3250
mavenLocal()
@@ -268,8 +286,8 @@ def binaryRelease(taskName, jarName, mainClass) {
268286
}
269287
}
270288

271-
272289
artifacts {
273290
archives(binaryRelease('buildSolidityNodeJar', 'SolidityNode', 'org.tron.program.SolidityNode'),
274-
binaryRelease('buildFullNodeJar', 'FullNode', 'org.tron.program.FullNode'))
275-
}
291+
binaryRelease('buildFullNodeJar', 'FullNode', 'org.tron.program.FullNode'),
292+
binaryRelease('buildKeystoreFactoryJar', 'KeystoreFactory', 'org.tron.program.KeystoreFactory'))
293+
}

‎jitpack.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
install:
2+
- ./gradlew build publishToMavenLocal -x test

‎src/main/java/org/tron/common/overlay/server/SyncPool.java‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,13 @@ public class SyncPool {
8080

8181
private PeerClient peerClient;
8282

83-
@Autowired
84-
public SyncPool(PeerClient peerClient) {
85-
this.peerClient = peerClient;
86-
}
87-
8883
public void init(PeerConnectionDelegate peerDel) {
8984
this.peerDel = peerDel;
9085

9186
channelManager = ctx.getBean(ChannelManager.class);
9287

88+
peerClient = ctx.getBean(PeerClient.class);
89+
9390
poolLoopExecutor.scheduleWithFixedDelay(() -> {
9491
try {
9592
fillUp();
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
package org.tron.common.utils;
2+
3+
import java.util.Arrays;
4+
import java.util.concurrent.atomic.AtomicInteger;
5+
6+
/**
7+
* Created by olivier on 2018/06/01
8+
*/
9+
class SlotBaseCounter {
10+
private int slotSize;
11+
private AtomicInteger[] slotCounter;
12+
13+
public SlotBaseCounter(int slotSize) {
14+
slotSize = slotSize < 1 ? 1 : slotSize;
15+
this.slotSize = slotSize;
16+
this.slotCounter = new AtomicInteger[slotSize];
17+
for (int i = 0; i < this.slotSize; i++) {
18+
slotCounter[i] = new AtomicInteger(0);
19+
}
20+
}
21+
22+
public void increaseSlot(int slotSize) {
23+
slotCounter[slotSize].incrementAndGet();
24+
}
25+
26+
public void wipeSlot(int slotSize) {
27+
slotCounter[slotSize].set(0);
28+
}
29+
30+
public int totalCount() {
31+
return Arrays.stream(slotCounter).mapToInt(slotCounter -> slotCounter.get()).sum();
32+
}
33+
34+
@Override
35+
public String toString() {
36+
return Arrays.toString(slotCounter);
37+
}
38+
}
39+
40+
/**
41+
* Created by olivier on 2018/06/01
42+
*/
43+
public class SlidingWindowCounter {
44+
private volatile SlotBaseCounter slotBaseCounter;
45+
private volatile int windowSize;
46+
private volatile int head;
47+
48+
public SlidingWindowCounter(int windowSize) {
49+
resizeWindow(windowSize);
50+
}
51+
52+
public synchronized void resizeWindow(int windowSize) {
53+
this.windowSize = windowSize;
54+
this.slotBaseCounter = new SlotBaseCounter(windowSize);
55+
this.head = 0;
56+
}
57+
58+
public void increase() {
59+
slotBaseCounter.increaseSlot(head);
60+
}
61+
62+
public int totalAndAdvance() {
63+
int total = totalCount();
64+
advance();
65+
return total;
66+
}
67+
68+
public void advance() {
69+
int tail = (head + 1) % windowSize;
70+
slotBaseCounter.wipeSlot(tail);
71+
head = tail;
72+
}
73+
74+
public int totalCount() {
75+
return slotBaseCounter.totalCount();
76+
}
77+
78+
@Override
79+
public String toString() {
80+
return "total = " + totalCount() + " head = " + head + " >> " + slotBaseCounter;
81+
}
82+
}

‎src/main/java/org/tron/core/WalletSolidity.java‎

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,10 @@
55
import lombok.extern.slf4j.Slf4j;
66
import org.springframework.beans.factory.annotation.Autowired;
77
import org.springframework.stereotype.Component;
8-
import org.tron.api.GrpcAPI.AssetIssueList;
98
import org.tron.api.GrpcAPI.TransactionList;
10-
import org.tron.api.GrpcAPI.WitnessList;
119
import org.tron.common.utils.ByteArray;
1210
import org.tron.core.db.api.StoreAPI;
13-
import org.tron.protos.Contract.AssetIssueContract;
1411
import org.tron.protos.Protocol.Transaction;
15-
import org.tron.protos.Protocol.Witness;
1612

1713
@Slf4j
1814
@Component
@@ -21,19 +17,6 @@ public class WalletSolidity {
2117
@Autowired
2218
private StoreAPI storeAPI;
2319

24-
public WitnessList getWitnessList() {
25-
List<Witness> witnessAll = storeAPI.getWitnessAll();
26-
WitnessList witnessList = WitnessList.newBuilder().addAllWitnesses(witnessAll).build();
27-
return witnessList;
28-
}
29-
30-
public AssetIssueList getAssetIssueList() {
31-
List<AssetIssueContract> assetIssueAll = storeAPI.getAssetIssueAll();
32-
AssetIssueList assetIssueList =
33-
AssetIssueList.newBuilder().addAllAssetIssue(assetIssueAll).build();
34-
return assetIssueList;
35-
}
36-
3720
public TransactionList getTransactionsFromThis(ByteString thisAddress, long offset, long limit) {
3821
List<Transaction> transactionsFromThis = storeAPI
3922
.getTransactionsFromThis(ByteArray.toHexString(thisAddress.toByteArray()), offset, limit);

‎src/main/java/org/tron/core/actuator/WitnessCreateActuator.java‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,11 @@ private void createWitness(final WitnessCreateContract witnessCreateContract)
121121
.get(witnessCapsule.createDbKey());
122122
accountCapsule.setIsWitness(true);
123123
this.dbManager.getAccountStore().put(accountCapsule.createDbKey(), accountCapsule);
124-
dbManager.adjustBalance(witnessCreateContract.getOwnerAddress().toByteArray(),
125-
-dbManager.getDynamicPropertiesStore().getAccountUpgradeCost());
124+
long cost = dbManager.getDynamicPropertiesStore().getAccountUpgradeCost();
125+
dbManager.adjustBalance(witnessCreateContract.getOwnerAddress().toByteArray(), -cost);
126126

127-
dbManager.adjustBalance(this.dbManager.getAccountStore().getBlackhole().createDbKey(),
128-
+dbManager.getDynamicPropertiesStore().getAccountUpgradeCost());
127+
dbManager.adjustBalance(this.dbManager.getAccountStore().getBlackhole().createDbKey(), +cost);
128+
129+
dbManager.getDynamicPropertiesStore().addTotalCreateWitnessCost(cost);
129130
}
130131
}

‎src/main/java/org/tron/core/config/Parameter.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ interface NetConstants {
4545
long HEAD_NUM_MAX_DELTA = 1000L;
4646
long HEAD_NUM_CHECK_TIME = 60000L;
4747
int MAX_INVENTORY_SIZE_IN_MINUTES = 2;
48-
long NET_MAX_TRX_PER_SECOND = 1000L;
48+
long NET_MAX_TRX_PER_SECOND = 700L;
4949
long MAX_TRX_PER_PEER = 200L;
5050
int NET_MAX_INV_SIZE_IN_MINUTES = 2;
5151
int MSG_CACHE_DURATION_IN_BLOCKS = 5;

0 commit comments

Comments
 (0)