Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jokoin #41

Open
wants to merge 55 commits into
base: Feature/AddNotAbi
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
7a751ac
Merge pull request #14 from tronprotocol/Feature/AddNotAbi
DorianRust Apr 18, 2019
355d35a
Merge pull request #15 from tronprotocol/Feature/AddNotAbi
DorianRust Apr 25, 2019
677a4d2
add empty json
Apr 26, 2019
944ae3e
Merge pull request #16 from tronprotocol/masterFixNotAbi
DorianRust Apr 26, 2019
83fed7c
Update README.md
DorianRust Jun 3, 2019
a9b174f
add input null check
Jun 3, 2019
3375522
Merge pull request #17 from tronprotocol/fixBug
llwslc Jun 3, 2019
cb1e4a9
add input null check
Jun 3, 2019
fc49425
Merge pull request #18 from tronprotocol/fixBug
DorianRust Jun 3, 2019
8dbd657
Update README.md
DorianRust Oct 12, 2019
e45152c
Update README.md
DorianRust Oct 12, 2019
2a6d605
fix bug
Jan 14, 2020
e89b4d0
TronWeb compatibility
helloboy12345 Jan 15, 2020
2be426d
fix bug
helloboy12345 Jan 15, 2020
27b3db3
update .gitignore
helloboy12345 Jan 15, 2020
e40842c
fix bug
helloboy12345 Jan 15, 2020
684dc69
fix logger method
Jan 15, 2020
4cc965c
add solidity comfirm
Jan 15, 2020
d296438
add solidity comfirm
Jan 15, 2020
a84f6c7
fix bug
Jan 16, 2020
953d558
add solidity comfirm
Jan 16, 2020
d7ef243
fix bug
TracyHesiCecil Jan 17, 2020
908ea98
fix following comment
TracyHesiCecil Jan 17, 2020
236a5c5
add solidity confirm
Jan 17, 2020
33e17dd
merge develop
Feb 3, 2020
1b2a7da
remove db config file
geb789 Feb 4, 2020
0a24db0
fix check style problem
Feb 5, 2020
22eabfe
remove duplicate function
M-blockcoder Feb 12, 2020
f39b4c2
remove duplicate function
Feb 12, 2020
b3fc3a3
Update config.conf
DorianRust Feb 13, 2020
a0331b2
add Filter and interceptor
alberto-zhang Feb 20, 2020
564e96a
delete interceptor
alberto-zhang Feb 20, 2020
61af258
Merge pull request #22 from tronprotocol/develop-alberto
DorianRust Feb 20, 2020
8d83b2b
add controller service
alberto-zhang Feb 20, 2020
b3bc34c
Merge pull request #23 from tronprotocol/develop-alberto
DorianRust Feb 21, 2020
6474a0b
delete nodeInfo blockChain
alberto-zhang Feb 21, 2020
5cc0115
Merge pull request #24 from tronprotocol/develop-alberto
DorianRust Feb 21, 2020
ed554d9
add 4xx 5xx
alberto-zhang Feb 21, 2020
7edeef9
add 2xx
alberto-zhang Feb 21, 2020
64d5e74
Merge pull request #25 from tronprotocol/develop-alberto
DorianRust Feb 21, 2020
4b8bf51
remove corsFilter
Feb 27, 2020
a3915f8
remove corsFilter
Feb 27, 2020
898488f
remove corsFilter
Feb 27, 2020
cb23e42
fix config file
Mar 2, 2020
6df3b0a
fix config file
Mar 2, 2020
dcb16e5
fix config file
Mar 2, 2020
bff95da
transaction data
M-blockcoder Jun 4, 2020
e152bf9
Bump guava from 24.1-jre to 29.0-jre
dependabot[bot] Mar 31, 2021
60b35c5
Merge pull request #32 from tronprotocol/dependabot/maven/com.google.…
jiangyy0824 Jun 1, 2021
55fc5cd
build(deps): bump guava version to 30.0-jre
Nov 23, 2021
ed28e2e
Merge pull request #33 from Starsakary/master
jiangyy0824 Nov 23, 2021
c714a45
Bump protobuf-java from 3.5.1 to 3.16.1
dependabot[bot] Jan 7, 2022
59a146c
Merge pull request #37 from tronprotocol/dependabot/maven/com.google.…
yanghang8612 Mar 29, 2022
fa24c1b
fix: upgrade fastjson
waynercheung Oct 25, 2022
730c126
Merge pull request #43 from tronprotocol/fix/fastjson_version
waynercheung Oct 25, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
target/classes/org/tron/trongrid/ContractEventTriggerEntity.class
target/classes/org/tron/trongrid/InternalTransactionPojo.class
target/*
.idea/*
troneventquery.iml
.classpath
.factorypath
.settings/*
.vscode/*
77 changes: 75 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ Make sure the relative path of config.conf and troneventquery jar. The config.co
- troneventquery/insertIndex.sh is used to setup mongodb index to speedup query.
(make sure run insertIndex before create collecions)

## Delete expire data
- troneventquery/deleteData.sh is used to delete expire data
- using crontable delete regularly mongodb expire data(if not delete, the database will be too big)


## What is the main HTTP service?
baseUrl: https://api.tronex.io
Expand Down Expand Up @@ -170,7 +174,6 @@ limit: each page size, default is 25
sort: sort Field, default is sort by timeStamp descending order
start: start page, default is 1

Note: if developers wants to check whether this event is confirmed or not, they could check the blocknumber is small than the solidified block number(get from url https://api.tronex.io/blocks/latestblockNum). If it is smaller than block number, it is conformed

Example: https://api.tronex.io/events/confirmed?since=1544483426749&limit=1&start=1&sort=timeStamp
```
Expand All @@ -197,7 +200,7 @@ block: block number, block number >= block will be shown

Example: https://api.tronex.io/blocks?limit=1&sort=timeStamp&start=0&block=0
```
Function: get latest solidified block number
Function: get latest block number
```
subpath: $baseUrl/blocks/latestSolidifiedBlockNumber

Expand All @@ -206,3 +209,73 @@ none

Example: https://api.tronex.io/blocks/latestSolidifiedBlockNumber
```
Function: get contract log list
```
subpath: $baseUrl/contractlogs

parameters
limit: each page size, default is 25
sort: sort Field, default is sort by timeStamp descending order
start: start page, default is 1
block: block number, block number >= block will be shown

Example: https://api.tronex.io/contractlogs
```
Function: get contract log list based on transactionId
```
subpath: $baseUrl/contractlogs/transaction/{transactionId}

parameters
transactionId

Example: https://api.tronex.io/contractlogs/transaction/{transactionId}
```
Function: post abi string and get contract log list based on transactionId(release on 3.6)
```
subpath: $baseUrl/contract/transaction/{transactionId}

parameters
transactionId
body:
abi: user self upload abi

Example: https://api.tronex.io/contract/transaction/{transactionId}
```
Function: get contract log list based on contractAddress
```
subpath: $baseUrl/contractlogs/contract/{contractAddress}

parameters
contractAddress

Example: https://api.tronex.io/contractlogs/contract/{contractAddress}
```
Function: post abi string and get contract log list based on contractAddress(release on 3.6)
```
subpath: $baseUrl/contract/contractAddress/{contractAddress}

parameters
contractAddress
abi: user self upload abi

Example: https://api.tronex.io/contract/contractAddress/{contractAddress}
```
Function: get contract log list based on uniqueId
```
subpath: $baseUrl/contractlogs/uniqueId/{uniqueId}

parameters
uniqueId

Example: https://api.tronex.io/contractlogs/uniqueId/{uniqueId}
```
Function: post abi string and get contract log list based on uniqueId(release on 3.6)
```
subpath: $baseUrl/contract/uniqueId/{uniqueId}

parameters
uniqueId
abi: user self upload abi

Example: https://api.tronex.io/contract/uniqueId/{uniqueId}
```
8 changes: 4 additions & 4 deletions config.conf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
mongo.host=47.90.245.68
mongo.port=27017
mongo.host=127.0.0.1
mongo.port=18883
mongo.dbname=eventlog
mongo.username=tron
mongo.password=123456

mongo.connectionsPerHost=8
mongo.threadsAllowedToBlockForConnectionMultiplier=4
mongo.connectionsPerHost=200
mongo.threadsAllowedToBlockForConnectionMultiplier=10
mongo.deadline=10
8 changes: 7 additions & 1 deletion deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ while true; do
break
fi
done
nohup java -jar target/troneventquery-1.0.0-SNAPSHOT.jar 2>&1 &
total=`cat /proc/meminfo |grep MemTotal |awk -F ' ' '{print $2}'`
xmx=`echo "$total/1024/1024*0.6" | bc |awk -F. '{print $1"g"}'`
logtime=`date +%Y-%m-%d_%H-%M-%S`
nohup java -Xmx$xmx -XX:+UseConcMarkSweepGC -XX:+PrintGCDetails -Xloggc:./gc.log\
-XX:+PrintGCDateStamps -XX:+CMSParallelRemarkEnabled -XX:ReservedCodeCacheSize=256m\
-XX:+CMSScavengeBeforeRemark -jar target/troneventquery-1.0.0-SNAPSHOT.jar >> query.log 2>&1 &

sleep 10
echo "ok!"
5 changes: 2 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,16 @@
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.5.1</version>
<version>3.16.1</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>24.1-jre</version>
<version>[30.0-jre,)</version>
</dependency>


</dependencies>

<build>
Expand Down
83 changes: 83 additions & 0 deletions src/main/java/org/tron/common/crypto/Crypto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package org.tron.common.crypto;
import static org.tron.common.utils.LogConfig.LOG;

import java.util.regex.Pattern;

public class Crypto {

private final static long SECRET_KEY = 5658116;
private final static String CONVERT_KEY = "DeCATbJIzM";
private final static String CONFUSED_WORDS_KEY = "FxYNgq";
private final static int LEN_KEY = 32;


static public String encrypt(String str){
Long time = new Long(157551410);
if(!isNumber(str)){
LOG.info("not number");
return null;
}

long number = Long.parseLong(str);
long newNumber = (number + time) * SECRET_KEY;
String[] numArr = String.valueOf(newNumber).split("");
String[] initArr = CONVERT_KEY.split("");
int len = numArr.length;
StringBuffer buffer = new StringBuffer();

for(int i = 0; i < len; i++){
int inx = Integer.parseInt(numArr[i]);
buffer.append(initArr[inx]);
}

String[] cwkArr = CONFUSED_WORDS_KEY.split("");
if(len < LEN_KEY){
int l = LEN_KEY - len;
for(int i = 0; i < l; i++){
int index = (int)(Math.random()*buffer.length());
int inx = (int)(Math.random()*(CONFUSED_WORDS_KEY.length()));
buffer.insert(index,cwkArr[inx]);
}
}
String result = buffer.toString();
return result;
}

public static int decrypt(String str){
Long time = new Long(157551410);
if(null == str || "".equals(str)){
return 0;
}
int l = CONFUSED_WORDS_KEY.length();
String[] cwkArr = CONFUSED_WORDS_KEY.split("");
for(int i = 0; i < l; i++){
str = str.replaceAll(cwkArr[i],"");
}
String[] initArr = str.split("");
int len = initArr.length;
StringBuffer result = new StringBuffer();
for(int i = 0; i < len; i++ ){
int k = CONVERT_KEY.indexOf(initArr[i]);
if(k == -1){
return 0;
}
result.append(k);
}
Long number;
try {
long total = Long.parseLong(result.toString());
long sum = total/SECRET_KEY;
number = sum - time;
} catch (NumberFormatException e) {
e.printStackTrace();
return 0;
}
return number.intValue();
}

public static boolean isNumber(String value) {
String pattern = "^[0-9]*[1-9][0-9]*$";
boolean isMatch = Pattern.matches(pattern, value);
return isMatch;
}
}
5 changes: 3 additions & 2 deletions src/main/java/org/tron/common/crypto/Hash.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@

package org.tron.common.crypto;

import static org.tron.common.utils.LogConfig.LOG;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.Provider;
import java.security.Security;
import lombok.extern.slf4j.Slf4j;
import org.tron.common.crypto.jce.TronCastleProvider;

@Slf4j(topic = "crypto")
public class Hash {

private static final Provider CRYPTO_PROVIDER;
Expand All @@ -48,7 +49,7 @@ public static byte[] sha3(byte[] input) {
digest.update(input);
return digest.digest();
} catch (NoSuchAlgorithmException e) {
log.error("Can't find such algorithm", e);
LOG.error("Can't find such algorithm", e);
throw new RuntimeException(e);
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/org/tron/common/utils/ByteArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

package org.tron.common.utils;

import static org.tron.common.utils.LogConfig.LOG;

import com.google.common.primitives.Ints;
import com.google.common.primitives.Longs;
import java.io.ByteArrayOutputStream;
Expand All @@ -29,7 +31,6 @@
import org.apache.commons.lang3.StringUtils;
import org.spongycastle.util.encoders.Hex;

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

public static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
Expand Down Expand Up @@ -101,7 +102,7 @@ public static byte[] fromObject(Object obj) {
objectOutputStream.flush();
bytes = byteArrayOutputStream.toByteArray();
} catch (IOException e) {
log.error("objectToByteArray failed: " + e.getMessage(), e);
LOG.error("objectToByteArray failed: " + e.getMessage(), e);
}
return bytes;
}
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/org/tron/common/utils/LogConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.tron.common.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;

@Configuration
public class LogConfig {
public static final Logger LOG = LoggerFactory.getLogger(LogConfig.class);
}
2 changes: 1 addition & 1 deletion src/main/java/org/tron/core/Wallet.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static String encode58Check(byte[] input) {
return Base58.encode(inputCheck);
}

private static byte[] decode58Check(String input) {
public static byte[] decode58Check(String input) {
byte[] decodeCheck = Base58.decode(input);
if (decodeCheck.length <= 4) {
return null;
Expand Down
34 changes: 15 additions & 19 deletions src/main/java/org/tron/trongeventquery/TronEventApplication.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.tron.trongeventquery;

import static org.tron.common.utils.LogConfig.LOG;
import static org.tron.trongeventquery.contractevents.ContractEventController.isRunRePushThread;

import com.mongodb.MongoClient;
import com.mongodb.MongoClientOptions;
import com.mongodb.MongoCredential;
Expand All @@ -14,37 +17,23 @@
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.PropertySource;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;


@SpringBootApplication(exclude = {MongoAutoConfiguration.class, MongoDataAutoConfiguration.class})
@ServletComponentScan("org.tron.trongeventquery.filter") //Scan Filter
@PropertySource(value = {"file:./config.conf"}, ignoreResourceNotFound = true)
public class TronEventApplication {

public static void main(String[] args) {
SpringApplication.run(TronEventApplication.class, args);
shutdown();
}

@Bean
public FilterRegistrationBean corsFilter() {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(true);
config.addAllowedOrigin("*");
config.addAllowedHeader("*");
config.addAllowedMethod("*");
source.registerCorsConfiguration("/**", config);
FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source));
bean.setOrder(0);
return bean;
}


@Bean
public MongoTemplate mongoTemplate(
@Value("${mongo.host}")String mongodbIp, @Value("${mongo.dbname}")String mongodbDbName,
Expand Down Expand Up @@ -82,4 +71,11 @@ public void customize(Connector connector) {
});
return factory;
}

public static void shutdown() {
Runnable stopThread =
() -> isRunRePushThread.set(false);
LOG.info("********register application shutdown hook********");
Runtime.getRuntime().addShutdownHook(new Thread(stopThread));
}
}
Loading