Skip to content

Commit

Permalink
Merge pull request #163 from WeBankFinTech/feature/support-batch-tran…
Browse files Browse the repository at this point in the history
…saction

Feature/optimize offline batch transaction
  • Loading branch information
yanggang-JV committed Apr 11, 2020
2 parents deb0872 + 52a6d5f commit e376591
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

## 1. 发现 bug

使用过程中遇到的任何问题,可以查看 [FAQ](https://github.com/WeBankFinTech/weid-doc/blob/master/docs/zh_CN/docs/faq.md),或者给我们提 [issue](https://github.com/WeBankFinTech/WeIdentity/issues)
使用过程中遇到的任何问题,可以查看 [FAQ](https://weidentity.readthedocs.io/zh_CN/latest/docs/faq.html),或者给我们提 [issue](https://github.com/WeBankFinTech/WeIdentity/issues)

## 2. 优化建议

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,37 @@
import lombok.Setter;

/**
* 离线交易的参数.
*
* @author tonychen 2020年4月4日
*/
@Getter
@Setter
public class TransactionArgs {


/**
* 每条请求对应的ID,唯一标识.
*/
private String requestId;

/**
* 交易上链需要调用的方法名.
*/
private String method;

/**
* 交易参数.
*/
private String args;

/**
* 交易额外的信息.
*/
private String extra;

/**
* 交易发生时的时间戳.
*/
private Long timeStamp;

/**
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/com/webank/weid/util/BatchTransactionUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,18 @@
public class BatchTransactionUtils {

private static final Logger logger = LoggerFactory.getLogger(BatchTransactionUtils.class);
private static final Integer THRESHOLD = 3;

/**
* 阈值,当写入的交易达到这个条数时,换新文件.
*/
private static final Integer THRESHOLD = 10000;
private static OutputStreamWriter ow = null;
private static String secretKey;
private static String currentFilePath;

/**
* 本机IP地址.
*/
private static String ipAddr;
private static Integer count;
private static String currentDir = System.getProperty("user.dir");
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/webank/weid/util/OffLineBatchTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ public class OffLineBatchTask extends AbstractService {

private static final Logger logger = LoggerFactory.getLogger(OffLineBatchTask.class);

//private static EvidenceServiceEngine engine;

private static Map<String, String> userKey = new HashMap<>();

private static String secretKey;
Expand Down Expand Up @@ -83,7 +81,10 @@ private static String getKey() {


/**
* 批量上链接口
* 批量上链接口.
*
* @param transactionArgs 上链交易参数
* @return 每条交易的上链结果
*/
public static ResponseData<List<Boolean>> sendBatchTransaction(
List<TransactionArgs> transactionArgs) {
Expand All @@ -108,7 +109,6 @@ public static ResponseData<List<Boolean>> sendBatchTransaction(
switch (method) {

case "createEvidence":
//批量接口
customKeys.add(StringUtils.EMPTY);
signers.add(argArray[4]);
break;
Expand Down

0 comments on commit e376591

Please sign in to comment.