Skip to content

Commit

Permalink
Merge branch 'develop' into fromCommunity
Browse files Browse the repository at this point in the history
* develop:
  add java-tron.vmoption for configure jvm option
  add java-tron.vmoption for configure jvm option
  fix conflict
  fix warnings.
  update
  fix unit test
  update
  move common utils from framework to common module.
  move nodeinfo and peerinfo to common module
  • Loading branch information
Parachuteuk committed Nov 8, 2019
2 parents c5a7982 + 8ca2749 commit 3c23ce0
Show file tree
Hide file tree
Showing 32 changed files with 102 additions and 148 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ subprojects {
// archives jar
archives sourcesJar
}
}
}
3 changes: 0 additions & 3 deletions chainbase/src/main/java/org/tron/common/utils/Commons.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package org.tron.common.utils;

import static org.tron.common.utils.Hash.sha3omit12;
import static org.tron.core.Constant.ADD_PRE_FIX_BYTE_MAINNET;

import java.util.Arrays;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.spongycastle.math.ec.ECPoint;
import org.tron.core.capsule.AccountCapsule;
import org.tron.core.capsule.ExchangeCapsule;
import org.tron.core.exception.BalanceInsufficientException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import org.tron.common.utils.DBConfig;
import org.tron.common.utils.FileUtil;
import org.tron.core.db.common.SourceInter;
import org.tron.core.db2.ISession;
import org.tron.core.db2.common.IRevokingDB;
import org.tron.core.db2.core.ISession;
import org.tron.core.db2.core.RevokingDBWithCachingOldValue;
import org.tron.core.exception.RevokingStoreIllegalStateException;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.tron.core.db;

import org.tron.core.db2.ISession;
import org.tron.core.db2.common.IRevokingDB;
import org.tron.core.db2.core.ISession;
import org.tron.core.exception.RevokingStoreIllegalStateException;

public interface RevokingDatabase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.tron.common.storage.WriteOptionsWrapper;
import org.tron.common.utils.DBConfig;
import org.tron.core.db.RevokingDatabase;
import org.tron.core.db2.ISession;
import org.tron.core.db2.common.DB;
import org.tron.core.db2.common.IRevokingDB;
import org.tron.core.db2.common.Key;
Expand Down
3 changes: 3 additions & 0 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@ dependencies {
compile "com.madgag.spongycastle:core:1.58.0.0"
compile "com.madgag.spongycastle:prov:1.58.0.0"
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.5'
compile "com.cedarsoftware:java-util:1.8.0"
compile group: 'org.apache.httpcomponents', name: 'httpasyncclient', version: '4.1.1'
compile group: 'commons-codec', name: 'commons-codec', version: '1.11'
compile project(":protocol")
}
1 change: 0 additions & 1 deletion common/src/main/java/org/tron/common/utils/DecodeUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.util.Arrays;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.spongycastle.math.ec.ECPoint;

@Slf4j(topic = "Commons")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.tron.common.utils;

import java.util.Optional;
import org.tron.core.db2.core.ISession;
import org.tron.core.db2.ISession;

public final class SessionOptional {

Expand Down
124 changes: 62 additions & 62 deletions ...org/tron/common/utils/TypeConversion.java → ...org/tron/common/utils/TypeConversion.java
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,62 +1,62 @@
/*
* Copyright (c) [2016] [ <ether.camp> ]
* This file is part of the ethereumJ library.
*
* The ethereumJ library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The ethereumJ library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the ethereumJ library. If not, see <http://www.gnu.org/licenses/>.
*/

package org.tron.common.utils;

import com.google.common.primitives.Longs;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Hex;

@Slf4j(topic = "utils")
public class TypeConversion {

public static byte[] longToBytes(long x) {
return Longs.toByteArray(x);
}

public static long bytesToLong(byte[] bytes) {
return Longs.fromByteArray(bytes);
}

public static String bytesToHexString(byte[] src) {
return Hex.encodeHexString(src);
}

public static byte[] hexStringToBytes(String hexString) {
try {
return Hex.decodeHex(hexString);
} catch (DecoderException e) {
logger.debug(e.getMessage(), e);
return null;
}
}

public static boolean increment(byte[] bytes) {
final int startIndex = 0;
int i;
for (i = bytes.length - 1; i >= startIndex; i--) {
bytes[i]++;
if (bytes[i] != 0) {
break;
}
}

return (i >= startIndex || bytes[startIndex] != 0);
}
}
/*
* Copyright (c) [2016] [ <ether.camp> ]
* This file is part of the ethereumJ library.
*
* The ethereumJ library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The ethereumJ library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the ethereumJ library. If not, see <http://www.gnu.org/licenses/>.
*/

package org.tron.common.utils;

import com.google.common.primitives.Longs;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Hex;

@Slf4j(topic = "utils")
public class TypeConversion {

public static byte[] longToBytes(long x) {
return Longs.toByteArray(x);
}

public static long bytesToLong(byte[] bytes) {
return Longs.fromByteArray(bytes);
}

public static String bytesToHexString(byte[] src) {
return Hex.encodeHexString(src);
}

public static byte[] hexStringToBytes(String hexString) {
try {
return Hex.decodeHex(hexString);
} catch (DecoderException e) {
logger.debug(e.getMessage(), e);
return null;
}
}

public static boolean increment(byte[] bytes) {
final int startIndex = 0;
int i;
for (i = bytes.length - 1; i >= startIndex; i--) {
bytes[i]++;
if (bytes[i] != 0) {
break;
}
}

return (i >= startIndex || bytes[startIndex] != 0);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.tron.core.db2.core;
package org.tron.core.db2;

public interface ISession extends AutoCloseable {

Expand Down
30 changes: 12 additions & 18 deletions framework/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,12 @@ dependencies {

testCompile group: 'org.testng', name: 'testng', version: '6.14.3'

compile group: 'commons-codec', name: 'commons-codec', version: '1.11'

compile "com.madgag.spongycastle:core:1.58.0.0"
compile "com.madgag.spongycastle:prov:1.58.0.0"

compile group: 'com.typesafe', name: 'config', version: '1.3.2'


compile "com.cedarsoftware:java-util:1.8.0"

compile group: 'com.beust', name: 'jcommander', version: '1.72'

compile group: 'junit', name: 'junit', version: '4.12'
Expand Down Expand Up @@ -208,11 +204,7 @@ def binaryRelease(taskName, jarName, mainClass) {
}
}
}
startScripts {
doLast {
delete unixScript
}
}

def createScript(project, mainClass, name) {
project.tasks.create(name: name, type: CreateStartScripts) {
unixStartScriptGenerator.template = resources.text.fromFile('../gradle/unixStartScript.txt')
Expand All @@ -221,14 +213,14 @@ def createScript(project, mainClass, name) {
mainClassName = mainClass
applicationName = name
classpath = project.tasks[JavaPlugin.JAR_TASK_NAME].outputs.files + project.configurations.runtime
defaultJvmOpts = ['-XX:+UseConcMarkSweepGC',
'-XX:+PrintGCDetails',
'-Xloggc:./gc.log',
'-XX:+PrintGCDateStamps',
'-XX:+CMSParallelRemarkEnabled',
'-XX:ReservedCodeCacheSize=256m',
'-XX:+CMSScavengeBeforeRemark'
]
// defaultJvmOpts = ['-XX:+UseConcMarkSweepGC',
// '-XX:+PrintGCDetails',
// '-Xloggc:./gc.log',
// '-XX:+PrintGCDateStamps',
// '-XX:+CMSParallelRemarkEnabled',
// '-XX:ReservedCodeCacheSize=256m',
// '-XX:+CMSScavengeBeforeRemark'
// ]
}
project.tasks[name].dependsOn(project.jar)
project.applicationDistribution.with {
Expand All @@ -238,7 +230,9 @@ def createScript(project, mainClass, name) {
}
}
}

applicationDistribution.from("../gradle/java-tron.vmoptions") {
into "bin"
}
//distZip {
// doLast {
// file("$destinationDir/$archiveName").renameTo("$destinationDir/"+'java-tron-'+version+'-bin.zip')
Expand Down
46 changes: 0 additions & 46 deletions framework/src/main/java/org/tron/common/utils/SafeMessageMap.java

This file was deleted.

1 change: 0 additions & 1 deletion framework/src/main/java/org/tron/core/Wallet.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import static org.tron.core.config.Parameter.DatabaseConstants.PROPOSAL_COUNT_LIMIT_MAX;
import static org.tron.core.config.args.Parameter.ChainConstant.BLOCK_PRODUCED_INTERVAL;


import com.google.common.base.CaseFormat;
import com.google.common.collect.ContiguousSet;
import com.google.common.collect.DiscreteDomain;
Expand Down
2 changes: 1 addition & 1 deletion framework/src/main/java/org/tron/core/db/Manager.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
import org.tron.core.db.accountstate.TrieService;
import org.tron.core.db.accountstate.callback.AccountStateCallBack;
import org.tron.core.db.api.AssetUpdateHelper;
import org.tron.core.db2.core.ISession;
import org.tron.core.db2.ISession;
import org.tron.core.db2.core.ITronChainBase;
import org.tron.core.db2.core.SnapshotManager;
import org.tron.core.exception.AccountResourceInsufficientException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.tron.core.config.args.Args;
import org.tron.core.db.TronStoreWithRevoking;
import org.tron.core.db2.SnapshotRootTest.ProtoCapsuleTest;
import org.tron.core.db2.core.ISession;
import org.tron.core.db2.core.SnapshotManager;
import org.tron.core.exception.RevokingStoreIllegalStateException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.tron.core.db.RevokingDatabase;
import org.tron.core.db.TronStoreWithRevoking;
import org.tron.core.db2.SnapshotRootTest.ProtoCapsuleTest;
import org.tron.core.db2.core.ISession;
import org.tron.core.exception.RevokingStoreIllegalStateException;

@Slf4j
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import org.tron.core.config.args.Args;
import org.tron.core.db2.RevokingDbWithCacheNewValueTest.TestRevokingTronStore;
import org.tron.core.db2.SnapshotRootTest.ProtoCapsuleTest;
import org.tron.core.db2.core.ISession;
import org.tron.core.db2.core.SnapshotManager;
import org.tron.core.exception.BadItemException;
import org.tron.core.exception.ItemNotFoundException;
Expand Down Expand Up @@ -88,7 +87,7 @@ public synchronized void testClose() {
ProtoCapsuleTest protoCapsule = new ProtoCapsuleTest("close".getBytes());
for (int i = 1; i < 11; i++) {
ProtoCapsuleTest testProtoCapsule = new ProtoCapsuleTest(("close" + i).getBytes());
try (ISession _ = revokingDatabase.buildSession()) {
try (ISession session = revokingDatabase.buildSession()) {
tronDatabase.put(protoCapsule.getData(), testProtoCapsule);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.tron.core.config.DefaultConfig;
import org.tron.core.config.args.Args;
import org.tron.core.db2.RevokingDbWithCacheNewValueTest.TestRevokingTronStore;
import org.tron.core.db2.core.ISession;
import org.tron.core.db2.core.Snapshot;
import org.tron.core.db2.core.SnapshotManager;
import org.tron.core.db2.core.SnapshotRoot;
Expand Down
7 changes: 7 additions & 0 deletions gradle/java-tron.vmoptions
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-XX:+UseConcMarkSweepGC
-XX:+PrintGCDetails
-Xloggc:./gc.log
-XX:+PrintGCDateStamps
-XX:+CMSParallelRemarkEnabled
-XX:ReservedCodeCacheSize=256m
-XX:+CMSScavengeBeforeRemark
Loading

0 comments on commit 3c23ce0

Please sign in to comment.