Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tron-explore
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张建华@五瓣科技
tron-explore
Commits
01679829
Commit
01679829
authored
Dec 14, 2020
by
jianhua.zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
切换成中追地址抓取数据,调整接口前缀
parent
bcec3b74
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
56 additions
and
16 deletions
+56
-16
Constant.java
src/main/java/com/wuban/tron/explore/constant/Constant.java
+1
-1
Engine.java
src/main/java/com/wuban/tron/explore/fetch/Engine.java
+2
-2
BaseCommonService.java
...ava/com/wuban/tron/explore/service/BaseCommonService.java
+5
-9
OkHttpClientObject.java
.../java/com/wuban/tron/explore/util/OkHttpClientObject.java
+34
-0
application-dev.yml
src/main/resources/application-dev.yml
+2
-1
TronServiceImplTest.java
.../wuban/tron/explore/service/impl/TronServiceImplTest.java
+12
-3
No files found.
src/main/java/com/wuban/tron/explore/constant/Constant.java
View file @
01679829
...
...
@@ -55,7 +55,7 @@ public class Constant {
/**
* 数据同步阀值
*/
public
static
final
long
THRESHOLD
=
3
0000
;
public
static
final
long
THRESHOLD
=
1
0000
;
/**
* 用户地址长度
...
...
src/main/java/com/wuban/tron/explore/fetch/Engine.java
View file @
01679829
...
...
@@ -127,10 +127,10 @@ public class Engine {
/*
合约事件数据抓取、处理
*/
this
.
contractEventHandler
=
new
ContractEventHandler
();
/*
this.contractEventHandler = new ContractEventHandler();
this.contractEventFetcher = new ContractEventFetcher<>(this.contractEventHandler);
this.executor.execute(this.contractEventFetcher);
this
.
executor
.
execute
(
this
.
contractEventHandler
);
this.executor.execute(this.contractEventHandler);
*/
}
...
...
src/main/java/com/wuban/tron/explore/service/BaseCommonService.java
View file @
01679829
...
...
@@ -2,6 +2,7 @@ package com.wuban.tron.explore.service;
import
com.alibaba.fastjson.JSON
;
import
com.wuban.tron.explore.constant.Constant
;
import
com.wuban.tron.explore.util.OkHttpClientObject
;
import
lombok.extern.slf4j.Slf4j
;
import
okhttp3.*
;
import
org.springframework.beans.factory.annotation.Value
;
...
...
@@ -19,7 +20,7 @@ import java.util.concurrent.TimeUnit;
@Slf4j
public
abstract
class
BaseCommonService
{
private
static
final
String
PREFIX
=
"/wallet
solidity
"
;
private
static
final
String
PREFIX
=
"/wallet"
;
/**
* 按照高度查询block API
...
...
@@ -37,8 +38,6 @@ public abstract class BaseCommonService {
*/
protected
static
final
String
GET_ACCOUNT
=
PREFIX
+
"/getaccount"
;
protected
static
final
String
FREEZE_BALANCE
=
"/wallet/freezebalance"
;
/**
* 事件日志API
*/
...
...
@@ -49,6 +48,8 @@ public abstract class BaseCommonService {
*/
protected
static
final
String
GET_CONTRACT
=
"/wallet/getcontract"
;
private
final
OkHttpClient
client
=
OkHttpClientObject
.
CLIENT
.
getClientInstance
();
@Value
(
"${tron.site}"
)
private
String
tronSite
;
...
...
@@ -67,12 +68,7 @@ public abstract class BaseCommonService {
String
str
=
null
;
try
{
OkHttpClient
okHttpClient
=
new
OkHttpClient
();
okHttpClient
.
newBuilder
()
.
connectTimeout
(
1
,
TimeUnit
.
SECONDS
)
.
readTimeout
(
2
,
TimeUnit
.
SECONDS
);
response
=
okHttpClient
.
newCall
(
executeRequest
).
execute
();
response
=
client
.
newCall
(
executeRequest
).
execute
();
ResponseBody
body
=
response
.
body
();
if
(
response
.
code
()
==
Constant
.
SUCCESS_CODE
&&
body
!=
null
)
{
str
=
body
.
string
();
...
...
src/main/java/com/wuban/tron/explore/util/OkHttpClientObject.java
0 → 100644
View file @
01679829
package
com
.
wuban
.
tron
.
explore
.
util
;
import
okhttp3.OkHttpClient
;
import
java.util.concurrent.TimeUnit
;
/**
* Description :
* 获取okHttpClient单例
* @author : Jeason
* @date : Created in 2018/10/25 11:16
*/
public
enum
OkHttpClientObject
{
CLIENT
;
private
OkHttpClient
clientInstance
;
private
Integer
connectTimeout_time
=
5
;
private
Integer
writeTimeout_time
=
5
;
private
Integer
readTimeout_time
=
5
;
OkHttpClientObject
()
{
clientInstance
=
new
OkHttpClient
.
Builder
()
.
connectTimeout
(
connectTimeout_time
,
TimeUnit
.
SECONDS
)
.
writeTimeout
(
writeTimeout_time
,
TimeUnit
.
SECONDS
)
.
readTimeout
(
readTimeout_time
,
TimeUnit
.
SECONDS
)
.
retryOnConnectionFailure
(
true
)
.
build
();
}
public
OkHttpClient
getClientInstance
()
{
return
clientInstance
;
}
}
\ No newline at end of file
src/main/resources/application-dev.yml
View file @
01679829
# config
tron
:
site
:
https://api.shasta.trongrid.io
site
:
http://123.57.69.71:26667
#site: https://api.shasta.trongrid.io
contract
:
complier
:
...
...
src/test/java/com/wuban/tron/explore/service/impl/TronServiceImplTest.java
View file @
01679829
package
com
.
wuban
.
tron
.
explore
.
service
.
impl
;
import
com.wuban.tron.explore.domain.*
;
import
com.wuban.tron.explore.entity.Contract
;
import
com.wuban.tron.explore.entity.ContractEvent
;
import
com.wuban.tron.explore.service.ContractEventService
;
import
com.wuban.tron.explore.service.TronService
;
...
...
@@ -32,7 +33,7 @@ class TronServiceImplTest {
@Test
void
getBlockByNum
()
{
TronResponseData
data
=
this
.
tronService
.
getBlockByNum
(
850000
L
);
TronResponseData
data
=
this
.
tronService
.
getBlockByNum
(
1
L
);
log
.
info
(
data
.
toString
());
}
...
...
@@ -63,10 +64,18 @@ class TronServiceImplTest {
@Test
void
getContract
()
{
String
base58check
=
"T
TfwGdf3v66CaYQijg4Qb2CFtdgQnkkFko
"
;
String
base58check
=
"T
C2G9UXR8xt6Qg7i4efKe1fMahdgZCQb4e
"
;
String
hexString
=
ByteArray
.
toHexString
(
WalletApi
.
decodeFromBase58Check
(
base58check
));
System
.
out
.
println
(
hexString
);
this
.
tronService
.
getContract
(
hexString
);
Contract
contract
=
this
.
tronService
.
getContract
(
hexString
);
System
.
out
.
println
(
contract
.
toString
());
}
@Test
void
test
()
{
String
str
=
"4181f7e0f75501194bb82e55a896afb6e802ebd42e"
;
String
base58
=
WalletApi
.
encode58Check
(
ByteArray
.
fromHexString
(
str
));
System
.
out
.
println
(
base58
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment