-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from raventrov/baley
A pure-Java implementation of the PlatON protocol
- Loading branch information
Showing
432 changed files
with
51,545 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
.gradle | ||
gradle | ||
.idea | ||
*.impl | ||
*.iml | ||
*.log | ||
*.bak | ||
*.class | ||
logs/* | ||
build/* | ||
account/build/ | ||
common/build/ | ||
consensus/build/ | ||
core/build/ | ||
core/out/ | ||
crypto/build/ | ||
crypto/out/ | ||
p2p/build/ | ||
slice/build/ | ||
storage/build/ | ||
storage/out/ | ||
out/* | ||
slice/src/main/java/ | ||
slice/src/main/grpc/ | ||
core/db-01/ | ||
core/database/ | ||
slice/src/main/java/ | ||
database/ | ||
testdb/ | ||
|
||
out | ||
core/config | ||
core/blockchain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,26 @@ | ||
# PlatON-Java | ||
Java implementation of the PlatON protocol | ||
# Welcome to PlatON-Java | ||
|
||
# About | ||
|
||
PlatON-Java is a pure-Java implementation of the PlatON protocol. | ||
|
||
# Running PlatON-Java | ||
|
||
##### Importing project to IntelliJ IDEA: | ||
|
||
``` | ||
> git clone https://github.com/PlatONnetwork/PlatON-Java.git | ||
> cd PlatON-Java | ||
> ./gradlew.bat build | ||
``` | ||
|
||
IDEA: | ||
* File -> New -> Project from existing sources… | ||
* Select PlatON-Java/build.gradle | ||
* Dialog “Import Project from gradle”: press “OK” | ||
* After building run `org.platon.Start` . | ||
|
||
|
||
# License | ||
PlatON-Java is released under the [LGPL-V3 license](LICENSE). | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
sourceCompatibility = 1.8 | ||
|
||
dependencies { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
subprojects { | ||
|
||
group 'org.platon' | ||
version '0.1.0-SNAPSHOT' | ||
|
||
/** load plugin */ | ||
apply plugin: 'java' | ||
apply plugin: 'maven' | ||
|
||
compileJava.options.encoding = 'UTF-8' | ||
compileJava.options.compilerArgs << '-XDignore.symbol.file' | ||
compileTestJava.options.encoding = 'UTF-8' | ||
|
||
ext { | ||
iceVersion = '3.7.1' | ||
springVersion = '4.2.0.RELEASE' | ||
} | ||
|
||
/** define resp */ | ||
repositories { | ||
maven { | ||
url "http://maven.aliyun.com/nexus/content/groups/public/" | ||
} | ||
} | ||
|
||
/** define common dependency */ | ||
dependencies { | ||
compile "ch.qos.logback:logback-classic:1.1.7" | ||
compile "ch.qos.logback:logback-core:1.1.7" | ||
compile "org.slf4j:slf4j-api:1.7.7" | ||
compile "org.slf4j:slf4j-api:1.7.7" | ||
compile "org.slf4j:log4j-over-slf4j:1.7.7" | ||
compile "org.slf4j:jul-to-slf4j:1.7.7" | ||
compile "org.slf4j:jcl-over-slf4j:1.7.7" | ||
|
||
// spring define | ||
compile "org.springframework:spring-context:${springVersion}" | ||
compile "org.springframework:spring-orm:${springVersion}" | ||
compile "org.springframework:spring-tx:${springVersion}" | ||
|
||
// config | ||
compile "com.typesafe:config:1.2.1" | ||
compile "com.googlecode.concurrent-locks:concurrent-locks:1.0.0" | ||
|
||
testCompile "org.springframework:spring-test:${springVersion}" | ||
testCompile "org.mockito:mockito-core:2.19.1" | ||
testCompile group: 'junit', name: 'junit', version: '4.11' | ||
testCompile group: 'org.powermock', name: 'powermock-module-junit4', version: '2.0.0-beta.5' | ||
testCompile group: 'org.powermock', name: 'powermock-api-mockito2', version: '2.0.0-beta.5' | ||
} | ||
|
||
task "create-dir" << { | ||
sourceSets*.java.srcDirs*.each { | ||
it.mkdirs() | ||
} | ||
sourceSets*.resources.srcDirs*.each { | ||
it.mkdirs() | ||
} | ||
} | ||
} | ||
|
||
task wrapper(type: Wrapper) { | ||
gradleVersion = "4.7" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
sourceCompatibility = 1.8 | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
|
||
compile project(':slice') | ||
compile "com.google.guava:guava:24.1-jre" | ||
|
||
compile "com.madgag.spongycastle:core:1.58.0.0" // for SHA3 and SECP256K1 | ||
compile "com.madgag.spongycastle:prov:1.58.0.0" // for SHA3 and SECP256K1 | ||
compile "com.fasterxml.jackson.core:jackson-databind:2.5.1" | ||
compile "com.fasterxml.jackson.core:jackson-annotations:2.5.0" | ||
compile "org.apache.commons:commons-collections4:4.0" | ||
|
||
compile "com.cedarsoftware:java-util:1.8.0" | ||
|
||
testCompile group: 'junit', name: 'junit', version: '4.11' | ||
} | ||
|
||
task createJavaProject << { | ||
sourceSets*.java.srcDirs*.each{ it.mkdirs() } | ||
sourceSets*.resources.srcDirs*.each{ it.mkdirs()} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package org.platon.common; | ||
|
||
import org.slf4j.LoggerFactory; | ||
|
||
public interface AppenderName { | ||
|
||
final static String APPENDER_CONSENSUS = "consensus"; | ||
|
||
final static String APPENDER_KEY_STORE = "keystore"; | ||
|
||
final static String APPENDER_PLATIN = "plain"; | ||
|
||
final static String APPENDER_RPC = "grpc"; | ||
|
||
final static String APPENDER_WALLET = "wallet"; | ||
|
||
final static String APPENDER_DB = "db"; | ||
|
||
final static String APPENDER_STATE = "state"; | ||
|
||
final static String APPENDER_PENDING = "pending"; | ||
|
||
final static String APPENDER_MINE = "mine"; | ||
|
||
static void showWarn(String message, String... messages) { | ||
|
||
LoggerFactory.getLogger(APPENDER_PLATIN).warn(message); | ||
final String ANSI_RED = "\u001B[31m"; | ||
final String ANSI_RESET = "\u001B[0m"; | ||
|
||
System.err.println(ANSI_RED); | ||
System.err.println(""); | ||
System.err.println(" " + message); | ||
for (String msg : messages) { | ||
System.err.println(" " + msg); | ||
} | ||
System.err.println(""); | ||
System.err.println(ANSI_RESET); | ||
} | ||
|
||
static void showErrorAndExit(String message, String... messages) { | ||
|
||
LoggerFactory.getLogger(APPENDER_PLATIN).error(message); | ||
|
||
|
||
final String ANSI_RED = "\u001B[31m"; | ||
final String ANSI_RESET = "\u001B[0m"; | ||
|
||
System.err.println(ANSI_RED); | ||
System.err.println(""); | ||
System.err.println(" " + message); | ||
for (String msg : messages) { | ||
System.err.println(" " + msg); | ||
} | ||
System.err.println(""); | ||
System.err.println(ANSI_RESET); | ||
|
||
throw new RuntimeException(message); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package org.platon.common; | ||
|
||
import com.google.protobuf.ByteString; | ||
import com.google.protobuf.InvalidProtocolBufferException; | ||
import org.platon.common.proto.BaseProto; | ||
import org.platon.common.utils.ByteArrayWrapper; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* base encode and decode by protoBuf | ||
* @author yanze | ||
*/ | ||
public class BasicPbCodec { | ||
|
||
public static byte[] encodeBytesList(byte[]... elements){ | ||
if(elements == null){ | ||
return null; | ||
} | ||
BaseProto.BaseBytesList.Builder builder = BaseProto.BaseBytesList.newBuilder(); | ||
for(byte[] element : elements){ | ||
builder.addBytesListData(ByteString.copyFrom(element)); | ||
} | ||
return builder.build().toByteArray(); | ||
} | ||
|
||
public static byte[] encodeBytesList(List<ByteArrayWrapper> bytesList){ | ||
if(bytesList == null){ | ||
return null; | ||
} | ||
BaseProto.BaseBytesList.Builder builder = BaseProto.BaseBytesList.newBuilder(); | ||
for(int i = 0;i<bytesList.size();i++){ | ||
builder.addBytesListData(ByteString.copyFrom(bytesList.get(i).getData())); | ||
} | ||
return builder.build().toByteArray(); | ||
} | ||
|
||
public static List<ByteArrayWrapper> decodeBytesList(byte[] protoBuf) throws InvalidProtocolBufferException { | ||
BaseProto.BaseBytesList baseBytesList = BaseProto.BaseBytesList.parseFrom(protoBuf); | ||
List<ByteArrayWrapper> list = new ArrayList<>(); | ||
for(int i = 0;i<baseBytesList.getBytesListDataCount();i++){ | ||
list.add(new ByteArrayWrapper(baseBytesList.getBytesListData(i).toByteArray())); | ||
} | ||
return list; | ||
} | ||
|
||
public static byte[] encodeInt(int data){ | ||
BaseProto.BaseInt.Builder builder = BaseProto.BaseInt.newBuilder(); | ||
builder.setIntData(data); | ||
return builder.build().toByteArray(); | ||
} | ||
|
||
public static int decodeInt(byte[] protoBuf) throws InvalidProtocolBufferException{ | ||
BaseProto.BaseInt baseInt = BaseProto.BaseInt.parseFrom(protoBuf); | ||
return baseInt.getIntData(); | ||
} | ||
|
||
public static byte[] encodeLong(long data){ | ||
BaseProto.BaseLong.Builder builder = BaseProto.BaseLong.newBuilder(); | ||
builder.setLongData(data); | ||
return builder.build().toByteArray(); | ||
} | ||
|
||
public static long decodeLong(byte[] protoBuf) throws InvalidProtocolBufferException{ | ||
BaseProto.BaseLong baseLong = BaseProto.BaseLong.parseFrom(protoBuf); | ||
return baseLong.getLongData(); | ||
} | ||
|
||
public static byte[] encodeString(String data){ | ||
if(data == null){ | ||
return null; | ||
} | ||
BaseProto.BaseString.Builder builder = BaseProto.BaseString.newBuilder(); | ||
builder.setStringData(data); | ||
return builder.build().toByteArray(); | ||
} | ||
|
||
public static String decodeString(byte[] protoBuf) throws InvalidProtocolBufferException{ | ||
BaseProto.BaseString baseString = BaseProto.BaseString.parseFrom(protoBuf); | ||
return baseString.getStringData(); | ||
} | ||
|
||
} |
Oops, something went wrong.