|
|
|
@ -78,6 +78,15 @@ public class ConfluxServiceImpl implements ConfluxService {
|
|
|
|
|
if (checkArgs.getIds().length > 100) { |
|
|
|
|
return AjaxResult.error("上链数量超出100!"); |
|
|
|
|
} |
|
|
|
|
String[] ids = checkArgs.getIds(); |
|
|
|
|
List<NftCollection> nftCollections = nftCollectionService.selectNftCollectionListByIds(ids, null); |
|
|
|
|
if (nftCollections != null) { |
|
|
|
|
List list = new ArrayList(); |
|
|
|
|
for (NftCollection n : nftCollections) { |
|
|
|
|
list.add(n.getInformationTableId()); |
|
|
|
|
} |
|
|
|
|
return AjaxResult.error("已经上链的id", list); |
|
|
|
|
} |
|
|
|
|
String checkArgsToken = AESUtil.decrypt(checkArgs.getToken(), ConfluxArt.AESKEY); |
|
|
|
|
String token = (String) redisUtils.get(checkArgsToken); |
|
|
|
|
if (null == token) { |
|
|
|
@ -153,9 +162,14 @@ public class ConfluxServiceImpl implements ConfluxService {
|
|
|
|
|
if (executeMakeUp(contract, contractConfig.getUnitName())) { |
|
|
|
|
isFalg = false; |
|
|
|
|
} |
|
|
|
|
try { |
|
|
|
|
Thread.sleep(500); |
|
|
|
|
} catch (InterruptedException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
System.out.println("--------正在铸造----------->"); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
System.out.println("------------------->"); |
|
|
|
|
return AjaxResult.success("上链成功!"); |
|
|
|
|
} |
|
|
|
|
return AjaxResult.error(); |
|
|
|
@ -173,9 +187,26 @@ public class ConfluxServiceImpl implements ConfluxService {
|
|
|
|
|
return AjaxResult.success(map); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public AjaxResult getNftStatus(String[] ids) { |
|
|
|
|
List<NftCollection> nftCollections = nftCollectionService.selectNftCollectionListByIds(ids, 2); |
|
|
|
|
if (nftCollections.size() > 0) { |
|
|
|
|
List list = new ArrayList(); |
|
|
|
|
for (NftCollection n : nftCollections) { |
|
|
|
|
list.add(n.getInformationTableId()); |
|
|
|
|
} |
|
|
|
|
return AjaxResult.success("上链成功的id", list); |
|
|
|
|
} |
|
|
|
|
return AjaxResult.error("暂无数据"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public boolean executeMakeUp(String contract, String markName) { |
|
|
|
|
log.info("[dispatchHandler]{}", "开始监听数据"); |
|
|
|
|
CollectConfig collect = collectConfigService.selectCollectConfigByStatus(); |
|
|
|
|
CollectConfig collect = (CollectConfig) redisUtils.get(contract); |
|
|
|
|
if (null == collect) { |
|
|
|
|
collect = collectConfigService.selectCollectConfigByStatus(); |
|
|
|
|
redisUtils.set(contract, collect); |
|
|
|
|
} |
|
|
|
|
if (collect.getOnPause()) { |
|
|
|
|
log.info("[dispatchHandler]{}", "暂停中"); |
|
|
|
|
try { |
|
|
|
@ -212,7 +243,11 @@ public class ConfluxServiceImpl implements ConfluxService {
|
|
|
|
|
} |
|
|
|
|
FilterMapVO vo = getFilter(eventParams); |
|
|
|
|
//获取数据高度
|
|
|
|
|
long from = collect.getEpochNumber(); |
|
|
|
|
String keyNumber = contract + "number"; |
|
|
|
|
long from = (long) redisUtils.get(keyNumber); |
|
|
|
|
if (null == redisUtils.get(contract + "number")) { |
|
|
|
|
from = collect.getEpochNumber(); |
|
|
|
|
} |
|
|
|
|
// Invoke cfx method
|
|
|
|
|
BigInteger epoch = cfx.getEpochNumber().sendAndGet(); |
|
|
|
|
log.info("[executeMakeUp][Current epoch]:{}", epoch); |
|
|
|
@ -277,13 +312,17 @@ public class ConfluxServiceImpl implements ConfluxService {
|
|
|
|
|
if (isSuccess) { |
|
|
|
|
t.setEpochNumber(to); |
|
|
|
|
log.info("[dispatchHandler][更新高度]:{}", to); |
|
|
|
|
redisUtils.set(contract + "number", to); |
|
|
|
|
} |
|
|
|
|
if (logList.size() > 0) { |
|
|
|
|
int i = collectConfigService.updateCollectConfig(t); |
|
|
|
|
if (i <= 0) { |
|
|
|
|
log.error("[dispatchHandler][更新高度失败]:{}", to); |
|
|
|
|
throw new RuntimeException("更新高度失败"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (logList.size() > 0) { |
|
|
|
|
log.info("[dispatchHandler][更新高度成功]:{}", to); |
|
|
|
|
redisUtils.del(contract); |
|
|
|
|
redisUtils.del(keyNumber); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|