Skip to content

Commit

Permalink
refactor ExchangeCreateServlet post code
Browse files Browse the repository at this point in the history
  • Loading branch information
M-blockcoder committed Jun 3, 2020
1 parent 61c07a2 commit cb7862c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 22 deletions.
16 changes: 1 addition & 15 deletions crypto/src/main/java/org/tron/common/crypto/Hash.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,21 +120,7 @@ public static byte[] sha3(byte[] input, int start, int length) {
throw new RuntimeException(e);
}
}

public static byte[] sha512(byte[] input) {
MessageDigest digest;
try {
digest = MessageDigest.getInstance(HASH_512_ALGORITHM_NAME,
CRYPTO_PROVIDER);
digest.update(input);
return digest.digest();
} catch (NoSuchAlgorithmException e) {
logger.error(ALGORITHM_NOT_FOUND, e);
throw new RuntimeException(e);
}
}



public static byte[] encodeElement(byte[] srcData) {

// [0x80]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,16 @@ public class ExchangeCreateServlet extends RateLimiterServlet {

protected void doPost(HttpServletRequest request, HttpServletResponse response) {
try {
String contract = request.getReader().lines()
.collect(Collectors.joining(System.lineSeparator()));
Util.checkBodySize(contract);
boolean visible = Util.getVisiblePost(contract);
PostParams params = PostParams.getPostParams(request);
ExchangeCreateContract.Builder build = ExchangeCreateContract.newBuilder();
JsonFormat.merge(contract, build, visible);
JsonFormat.merge(params.getParams(), build, params.isVisible());
Transaction tx = wallet
.createTransactionCapsule(build.build(), ContractType.ExchangeCreateContract)
.getInstance();
JSONObject jsonObject = JSONObject.parseObject(contract);
JSONObject jsonObject = JSONObject.parseObject(params.getParams());
tx = Util.setTransactionPermissionId(jsonObject, tx);
response.getWriter().println(Util.printCreateTransaction(tx, visible));
response.getWriter().println(Util
.printCreateTransaction(tx, params.isVisible()));
} catch (Exception e) {
Util.processError(e, response);
}
Expand Down

0 comments on commit cb7862c

Please sign in to comment.