Skip to content

Commit

Permalink
Merge pull request #162 from yg3630536/feature/offline-code
Browse files Browse the repository at this point in the history
* get offline flag from db
  • Loading branch information
chenhaozx committed Apr 11, 2020
2 parents b38db0e + 381ad86 commit deb0872
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@
import org.apache.commons.lang3.StringUtils;
import org.bcos.web3j.crypto.Sign;
import org.bcos.web3j.crypto.Sign.SignatureData;
import org.fisco.bcos.web3j.abi.datatypes.Bool;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.webank.weid.constant.ErrorCode;
import com.webank.weid.constant.ParamKeyConstant;
import com.webank.weid.constant.WeIdConstant;
import com.webank.weid.protocol.base.EvidenceInfo;
import com.webank.weid.protocol.base.EvidenceSignInfo;
Expand All @@ -42,6 +44,7 @@
import com.webank.weid.protocol.response.ResponseData;
import com.webank.weid.rpc.EvidenceService;
import com.webank.weid.rpc.WeIdService;
import com.webank.weid.service.impl.inner.PropertiesService;
import com.webank.weid.util.BatchTransactionUtils;
import com.webank.weid.util.DataToolUtils;
import com.webank.weid.util.DateUtils;
Expand Down Expand Up @@ -210,7 +213,7 @@ private ResponseData<String> hashToNewEvidence(String hashValue, String privateK
Long timestamp = DateUtils.getNoMillisecondTimeStamp();

//如果
boolean flag = true;
boolean flag = getOfflineFlag();
if (flag) {
String rawData = new StringBuffer()
.append(hashValue)
Expand Down Expand Up @@ -410,7 +413,7 @@ public ResponseData<String> createEvidenceWithLogAndCustomKey(
StandardCharsets.UTF_8);
Long timestamp = DateUtils.getNoMillisecondTimeStamp();
//如果
boolean flag = true;
boolean flag = getOfflineFlag();
if (flag) {
String rawData = new StringBuffer()
.append(hashValue)
Expand Down Expand Up @@ -471,4 +474,13 @@ public ResponseData<EvidenceInfo> getEvidenceByCustomKey(String customKey) {
private boolean isChainStringLengthValid(String string) {
return string.length() < WeIdConstant.ON_CHAIN_STRING_LENGTH;
}

private boolean getOfflineFlag() {
String flag = PropertiesService.getInstance()
.getProperty(ParamKeyConstant.ENABLE_OFFLINE);
if (StringUtils.isNotBlank(flag)) {
return new Boolean(flag);
}
return false;
}
}

0 comments on commit deb0872

Please sign in to comment.