Skip to content

Commit

Permalink
refactor and code the main loopls
Browse files Browse the repository at this point in the history
  • Loading branch information
olenheim committed Jan 30, 2018
1 parent c1e5d3f commit ddfe87b
Show file tree
Hide file tree
Showing 124 changed files with 4,914 additions and 5,710 deletions.
10 changes: 5 additions & 5 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: "2"
plugins:
sonar-java:
enabled: true
config:
version: "2"
plugins:
sonar-java:
enabled: true
config:
sonar.java.source: 8
26 changes: 13 additions & 13 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
Please answer these questions before submitting your issue. Thanks!

1. What did you do?
If possible, provide a recipe for reproducing the error.


2. What did you expect to see?



3. What did you see instead?


Please answer these questions before submitting your issue. Thanks!

1. What did you do?
If possible, provide a recipe for reproducing the error.


2. What did you expect to see?



3. What did you see instead?


24 changes: 12 additions & 12 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
**What does this PR do?**

**Why are these changes required?**

**This PR has been tested by:**
- Unit Tests
- Manual Testing

**Follow up**

**Extra details**

**What does this PR do?**

**Why are these changes required?**

**This PR has been tested by:**
- Unit Tests
- Manual Testing

**Follow up**

**Extra details**

94 changes: 4 additions & 90 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,101 +19,15 @@ TRON is a block chain-based decentralized smart protocol and an application deve

TRON is a product of Web 4.0 and the decentralized internet of next generation.

# Quick Start

> Note: This repository is a IDEA project which you can simply download and import.
**Download and build**

```shell
> git clone https://github.com/tronprotocol/java-tron.git
> cd java-tron
> gradle build
```

**Import project to IDEA**

- [File] -> [New] -> [Project from Existing Sources...]
- Select java-tron/build.gradle
- Dialog [Import Project from Gradle], confirm [Use auto-import] and [Use gradle wrapper task configuration] have been
selected,then select Gradle JVM(JDK 1.8)and click [OK]

# Testing

**Install Kafka and create two topics (block and transaction)**


**Update the configuration**


**Starting program**

IDEA:
- [Edit Configurations...] -> [Add New Configuration] -> [Application]
- [Edit Configurations...] -> [Main Class]: `org.tron.example.Tron`
- [Edit Configurations...] -> [Use classpath of module]: `java-tron_main`
- [Edit Configurations...] -> [Program arguments]: `--type server`
- Run

![run](https://github.com/tronprotocol/wiki/blob/master/images/commands/default-set.gif)

or simply from terminal:
- ./gradlew run -Pserver=true

**Complete process**
# Quick Start

![help](https://github.com/tronprotocol/wiki/blob/master/images/commands/process.gif)
Read the [Quick Srart](http://wiki.tron.network/en/latest/quick_start.html).

**Other nodes to join need to modify the connection ip**
![help](https://github.com/tronprotocol/wiki/blob/master/images/commands/node-ip.gif)

# Commands
**help**

| Description | Example |
| --- | --- |
| Help tips | `help` |

![help](https://github.com/tronprotocol/wiki/blob/master/images/commands/help.gif)

**account**

| Description | Example |
| --- | --- |
| Get address | `account` |

![help](https://github.com/tronprotocol/wiki/blob/master/images/commands/account.gif)

**getbalance**

| Description | Example |
| --- | --- |
| Get balance | `getbalance` |

![help](https://github.com/tronprotocol/wiki/blob/master/images/commands/getbalance.gif)

**send [to] [balance]**

| Description | Example |
| --- | --- |
| Send balance to address | `send 2cddf5707aefefb199cb16430fb0f6220d460dfe 2` |

![help](https://github.com/tronprotocol/wiki/blob/master/images/commands/send1.gif)

**printblockchain**

| Description | Example |
| --- | --- |
| Print blockchain | `printblockchain`|

![help](https://github.com/tronprotocol/wiki/blob/master/images/commands/printblockchain.gif)

**exit**

| Description | Example |
| --- | --- |
| Exit | `exit` |

![help](https://github.com/tronprotocol/wiki/blob/master/images/commands/exit.gif)
Read the [Commands](http://wiki.tron.network/en/latest/quick_start.html#commands).

# Contact

Expand Down
13 changes: 7 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ apply plugin: 'application'
apply plugin: 'checkstyle'

sourceCompatibility = 1.8
mainClassName = 'org.tron.program.example.Tron'
mainClassName = 'org.tron.program.FullNode'

repositories {
mavenCentral()
Expand Down Expand Up @@ -112,8 +112,9 @@ dependencies {
compile group: 'io.grpc', name: 'grpc-stub', version: '1.9.0'
// end google grpc



compile group: 'io.scalecube', name: 'scalecube-services', version: '1.0.7'
compile group: 'io.scalecube', name: 'scalecube-cluster', version: '1.0.7'
compile group: 'io.scalecube', name: 'scalecube-transport', version: '1.0.7'
}

task lint(type: Checkstyle) {
Expand Down Expand Up @@ -148,9 +149,9 @@ sourceSets {


proto {
srcDir 'src/proto'
}
srcDir 'src/proto'
}
}

}

Expand All @@ -171,7 +172,7 @@ protobuf {
generateProtoTasks {
all().each { task ->
task.builtins {
java {outputSubDir = "gen"}
java { outputSubDir = "gen" }
}
}
all()*.plugins {
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM tronprotocol/centos7-jdk8
MAINTAINER tronprotocol

# Install dependencies && Download java-tron
RUN yum update && \
RUN yum update -y && \
yum install -y git && \
git clone https://github.com/tronprotocol/java-tron.git /home/java-tron

Expand Down
10 changes: 5 additions & 5 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-bin.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-bin.zip
Empty file modified gradlew
100755 → 100644
Empty file.
53 changes: 13 additions & 40 deletions src/main/java/org/tron/common/application/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,59 +12,32 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package org.tron.common.application;

import com.google.inject.Injector;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tron.core.db.BlockStore;
import org.tron.core.net.node.Node;
import org.tron.core.net.node.NodeImpl;

public class Application {

private static final Logger logger = LoggerFactory.getLogger("Application");
private Injector injector;

private NodeImpl p2pnode;
import org.tron.program.Args;

private ServiceContainer services;
public interface Application {

public Application(Injector injector) {
this.injector = injector;
void setOptions(Args args);

}
void init(String path, Args args);

public Application() {
this.services = new ServiceContainer();
p2pnode = new NodeImpl();
}
void initServices(Args args);

public Injector getInjector() {
return injector;
}
void startup();

public void addService(Service service) {
this.services.add(service);
}
void shutdown();

public BlockStore getBlockStoreS() {
return p2pnode.getBlockdb();
}
void startServies();

public Node getP2pNode() {
return p2pnode.getP2pNode();
}
public void run() {
p2pnode.start();
this.services.start();
}
void shutdownServices();

Node getP2pNode();

public void shutdown() {
logger.info("shutting down");
this.services.stop();
System.exit(0);
}
BlockStore getBlockStoreS();

void addService(Service service);
}
24 changes: 10 additions & 14 deletions src/main/java/org/tron/common/application/ApplicationFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package org.tron.common.application;

import com.google.inject.Guice;
Expand All @@ -20,7 +21,7 @@
public class ApplicationFactory {

/**
* Build a Guice instance
* Build a Guice instance.
*
* @return Guice
*/
Expand All @@ -30,24 +31,19 @@ public Injector buildGuice() {
}

/**
* Build a new application
*
* @return
* Build a new application.
*/
public Application build() {
return new Application(buildGuice());
return new ApplicationImpl();
}

/**
* Build a new cli application
*
* @return
* Build a new cli application.
*/
public CliApplication buildCli() {
return new CliApplication(buildGuice());
}

public static Application create() {
return new Application();
//public CliApplication buildCli() {
// return new CliApplication(buildGuice());
//}
public static Application create() {
return new ApplicationImpl();
}
}
Loading

0 comments on commit ddfe87b

Please sign in to comment.