use of org.fisco.bcos.web3j.protocol.core.methods.response.SyncStatus in project web3sdk by FISCO-BCOS.
the class CnsService method isSynced.
boolean isSynced() throws Exception {
SyncStatus ethSyncing = web3j.getSyncStatus().send();
if (ethSyncing.isSyncing()) {
return false;
} else {
BcosBlock block = web3j.getBlockByNumber(DefaultBlockParameterName.LATEST, false).send();
long timestamp = block.getBlock().getTimestamp().longValueExact() * 1000;
return System.currentTimeMillis() - syncThreshold < timestamp;
}
}
Aggregations