Skip to content

Commit ac9545d

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 2f7b8f6 + 148b5c1 commit ac9545d

File tree

5 files changed

+25
-7
lines changed

5 files changed

+25
-7
lines changed

src/main/java/com/cc/etherscan/io/processor/EthereumContractProcessor.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package com.cc.etherscan.io.processor;
22

3+
import com.baomidou.mybatisplus.mapper.EntityWrapper;
4+
import com.baomidou.mybatisplus.mapper.Wrapper;
35
import com.cc.etherscan.io.common.Constants;
6+
import com.cc.etherscan.io.entity.EtherContract;
7+
import com.cc.etherscan.io.mapper.EtherContractMapper;
48
import lombok.extern.slf4j.Slf4j;
59
import org.springframework.data.redis.core.RedisTemplate;
610
import org.springframework.util.StringUtils;
@@ -26,8 +30,11 @@ public class EthereumContractProcessor implements PageProcessor {
2630

2731
private RedisTemplate redisTemplate;
2832

29-
public EthereumContractProcessor(RedisTemplate template) {
33+
private EtherContractMapper etherContractMapper;
34+
35+
public EthereumContractProcessor(RedisTemplate template, EtherContractMapper etherContractMapper) {
3036
this.redisTemplate = template;
37+
this.etherContractMapper = etherContractMapper;
3138
}
3239

3340

@@ -49,7 +56,14 @@ public void process(Page page) {
4956
continue;
5057
}
5158
if (redisTemplate.hasKey(String.format(REDIS_ETHER_EUM_KEY, address))) {
52-
continue;
59+
EtherContract queryEntity = new EtherContract();
60+
queryEntity.setAddress(address);
61+
Wrapper<EtherContract> wrapper = new EntityWrapper<>();
62+
wrapper.eq("address", address);
63+
Integer count = etherContractMapper.selectCount(wrapper);
64+
if (count > 0) {
65+
continue;
66+
}
5367
}
5468
page.addTargetRequest(url);
5569
Map<String, String> map = new HashMap<>();

src/main/java/com/cc/etherscan/io/schedule/EtherEumSchedule.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.cc.etherscan.io.schedule;
22

3+
import com.cc.etherscan.io.mapper.EtherContractMapper;
34
import com.cc.etherscan.io.pipeline.EthereumPipeline;
45
import com.cc.etherscan.io.processor.EthereumContractProcessor;
56
import org.springframework.beans.factory.annotation.Value;
@@ -23,6 +24,9 @@ public class EtherEumSchedule {
2324
@Resource
2425
private EthereumPipeline ethereumPipeline;
2526

27+
@Resource
28+
private EtherContractMapper etherContractMapper;
29+
2630
@Value("${etherscan.pageSize}")
2731
private int pageSize = 0;
2832

@@ -41,7 +45,7 @@ public class EtherEumSchedule {
4145
@Scheduled(cron="0 0/2 * * * ?")
4246
public void start() {
4347
for (int i = startPage; i<= totalPage; i++) {
44-
Spider.create(new EthereumContractProcessor(redisTemplate))
48+
Spider.create(new EthereumContractProcessor(redisTemplate, etherContractMapper))
4549
.addUrl("https://etherscan.io/contractsVerified/" + i + "?ps=" + pageSize)
4650
.addPipeline(ethereumPipeline)
4751
.thread(threadCount)

src/main/resources/application.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ spring:
99
connection-test-query: SELECT 1 FROM DUAL
1010
profiles:
1111
active: test
12-
#liquibase:
13-
#change-log: classpath:db-changelog.xml
12+
liquibase:
13+
change-log: classpath:db-changelog.xml
1414
mybatis-plus:
1515
mapper-locations: classpath*:sqlmap/*Mapper.xml
1616
typeAliasesPackage: com.cc.etherscan.io.entity

src/main/resources/db-changelog.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<property name="now" value="sysdate" dbms="mysql"/>
88

99
<!--原则上,这里只留下以项目模块为单位的include, 名字建议采用模块全名-->
10-
<include file="classpath:changelog/ether-contract-changelog.xml"/>
10+
<!--<include file="classpath:changelog/ether-contract-changelog.xml"/>-->
1111

1212

1313
</databaseChangeLog>

src/main/resources/logback.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<maxFileSize>5MB</maxFileSize>
1717
</triggeringPolicy>
1818
<encoder>
19-
<pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</pattern>
19+
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
2020
</encoder>
2121
</appender>
2222
<root level="INFO">

0 commit comments

Comments
 (0)