Skip to content

Commit

Permalink
Merge pull request #155 from WeBankFinTech/feature/batch-evidence
Browse files Browse the repository at this point in the history
Batch Evidence Creation
  • Loading branch information
chenhaozx committed Apr 9, 2020
2 parents 580f820 + f77cadc commit f742e57
Show file tree
Hide file tree
Showing 11 changed files with 463 additions and 90 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ dependencies {
if (gradleVer.startsWith("4")) {
if (!gradle.startParameter.isOffline()) {
compile logger, lombok, apache_commons, json, mysql_driver, zxing, rpc, pdfbox, protobuf, caffeine, oval
compile("com.webank:weid-contract-java:1.2.16") {
compile("com.webank:weid-contract-java:1.2.17") {
exclude group: "org.fisco-bcos", module: "web3sdk"
exclude group: "org.slf4j", module: "slf4j-log4j12"
}
Expand All @@ -154,7 +154,7 @@ dependencies {
testAnnotationProcessor 'org.projectlombok:lombok:1.18.10'
testCompileOnly 'org.projectlombok:lombok:1.18.10'
compile logger, apache_commons, json, mysql_driver, zxing, rpc, pdfbox, protobuf, caffeine, oval
compile("com.webank:weid-contract-java:1.2.16") {
compile("com.webank:weid-contract-java:1.2.17") {
exclude group: "org.fisco-bcos", module: "web3sdk"
exclude group: "org.slf4j", module: "slf4j-log4j12"
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/webank/weid/constant/ErrorCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ public enum ErrorCode {
/**
* The credential evidence interface does not support fisco bcos 1.3.
*/
CREDENTIAL_EVIDENCE_NOT_SUPPORTED(100503, "evidence interface does not support fisco bcos 1.3"),
FISCO_BCOS_VERSION_NOT_SUPPORTED(170000, "this function does not support current fisco bcos version"),

/**
* On-chain string length exceeded acceptable max.
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/webank/weid/constant/WeIdConstant.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,4 +240,6 @@ public final class WeIdConstant {
public static final String CNS_CPT_ADDRESS = "CptController";

public static final Integer ON_CHAIN_STRING_LENGTH = 2097152;

public static final String EVIDENCE_ATTRIBUTE_DELIMETER = "|";
}
2 changes: 2 additions & 0 deletions src/main/java/com/webank/weid/rpc/EvidenceService.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package com.webank.weid.rpc;

import java.util.List;
import java.util.Map;

import com.webank.weid.protocol.base.EvidenceInfo;
Expand Down Expand Up @@ -137,4 +138,5 @@ ResponseData<Boolean> addLogByCustomKey(
* @return true if yes, false otherwise
*/
ResponseData<Boolean> verifySigner(EvidenceInfo evidenceInfo, String weId, String publicKey);

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import java.io.File;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;

import com.google.common.base.Charsets;
import com.google.common.io.Files;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

package com.webank.weid.service.impl.engine;

import java.util.List;

import com.webank.weid.protocol.base.EvidenceInfo;
import com.webank.weid.protocol.response.ResponseData;

Expand All @@ -27,11 +29,24 @@ public interface EvidenceServiceEngine extends ReloadStaticContract {
ResponseData<String> createEvidence(
String hashValue,
String signature,
String extra,
String log,
Long timestamp,
String privateKey
);

/**
* Batch creation of evidences. Return values are a list which indicates successful or failed
* creation with strict order of input evidences.
*/
ResponseData<List<Boolean>> batchCreateEvidence(
List<String> hashValues,
List<String> signatures,
List<String> logs,
List<Long> timestamp,
List<String> signers,
String privateKey
);

ResponseData<Boolean> addLog(
String hashValue,
String log,
Expand All @@ -44,9 +59,19 @@ ResponseData<Boolean> addLog(
ResponseData<String> createEvidenceWithCustomKey(
String hashValue,
String signature,
String extra,
String log,
Long timestamp,
String extraKey,
String customKey,
String privateKey
);

ResponseData<List<Boolean>> batchCreateEvidenceWithCustomKey(
List<String> hashValues,
List<String> signatures,
List<String> logs,
List<Long> timestamps,
List<String> signers,
List<String> customKeys,
String privateKey
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import java.io.IOException;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -80,12 +81,26 @@ public EvidenceServiceEngineV1() {
/**
* 重新加载静态合约对象.
*/
@Override
public void reload() {
evidenceContract = getContractService(
fiscoConfig.getEvidenceAddress(),
EvidenceContract.class);
}


@Override
public ResponseData<List<Boolean>> batchCreateEvidence(
List<String> hashValues,
List<String> signatures,
List<String> logs,
List<Long> timestamp,
List<String> signers,
String privateKey
) {
return new ResponseData<>(null, ErrorCode.FISCO_BCOS_VERSION_NOT_SUPPORTED);
}

@Override
public ResponseData<String> createEvidence(
String hashValue,
Expand Down Expand Up @@ -180,7 +195,7 @@ public ResponseData<Boolean> addLog(

@Override
public ResponseData<String> getHashByCustomKey(String customKey) {
return new ResponseData<String>(null, ErrorCode.CREDENTIAL_EVIDENCE_NOT_SUPPORTED);
return new ResponseData<String>(null, ErrorCode.FISCO_BCOS_VERSION_NOT_SUPPORTED);
}

private static boolean isSignEvent(EvidenceAttributeChangedEventResponse event) {
Expand Down Expand Up @@ -372,16 +387,30 @@ public ResponseData<String> createEvidenceWithCustomKey(
String extraKey,
String privateKey) {

return new ResponseData<String>(null, ErrorCode.CREDENTIAL_EVIDENCE_NOT_SUPPORTED);
return new ResponseData<String>(null, ErrorCode.FISCO_BCOS_VERSION_NOT_SUPPORTED);
}

@Override
public ResponseData<List<Boolean>> batchCreateEvidenceWithCustomKey(
List<String> hashValues,
List<String> signatures,
List<String> logs,
List<Long> timestamps,
List<String> signers,
List<String> customKeys,
String privateKey
) {
return new ResponseData<>(null, ErrorCode.FISCO_BCOS_VERSION_NOT_SUPPORTED);
}


/* (non-Javadoc)
* @see com.webank.weid.service.impl.engine.EvidenceServiceEngine#getInfoByCustomKey(
* java.lang.String)
*/
@Override
public ResponseData<EvidenceInfo> getInfoByCustomKey(String extraKey) {

return new ResponseData<EvidenceInfo>(null, ErrorCode.CREDENTIAL_EVIDENCE_NOT_SUPPORTED);
return new ResponseData<EvidenceInfo>(null, ErrorCode.FISCO_BCOS_VERSION_NOT_SUPPORTED);
}
}

0 comments on commit f742e57

Please sign in to comment.