Skip to content

Commit 871edd4

Browse files
authored
Merge pull request tronprotocol#2663 from tronprotocol/branchForCommunity
improve statement lambda and check error words
2 parents 75e5694 + 7a0b95f commit 871edd4

File tree

5 files changed

+30
-41
lines changed

5 files changed

+30
-41
lines changed

common/src/main/java/org/tron/common/runtime/vm/LogInfo.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ public LogInfo(byte[] address, List<DataWord> topics, byte[] data) {
4444

4545
public static Log buildLog(LogInfo logInfo) {
4646
List<ByteString> topics = Lists.newArrayList();
47-
logInfo.getTopics().forEach(topic -> {
48-
topics.add(ByteString.copyFrom(topic.getData()));
49-
});
47+
logInfo.getTopics().forEach(topic ->
48+
topics.add(ByteString.copyFrom(topic.getData()))
49+
);
5050
ByteString address = ByteString.copyFrom(logInfo.getAddress());
5151
ByteString data = ByteString.copyFrom(logInfo.getData());
5252
return Log.newBuilder().setAddress(address).addAllTopics(topics).setData(data).build();

framework/src/main/java/org/tron/core/Wallet.java

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -551,11 +551,11 @@ public TransactionCapsule createTransactionCapsule(com.google.protobuf.Message m
551551
/**
552552
* Broadcast a transaction.
553553
*/
554-
public GrpcAPI.Return broadcastTransaction(Transaction signaturedTransaction) {
554+
public GrpcAPI.Return broadcastTransaction(Transaction signedTransaction) {
555555
GrpcAPI.Return.Builder builder = GrpcAPI.Return.newBuilder();
556-
TransactionCapsule trx = new TransactionCapsule(signaturedTransaction);
556+
TransactionCapsule trx = new TransactionCapsule(signedTransaction);
557557
try {
558-
Message message = new TransactionMessage(signaturedTransaction.toByteArray());
558+
Message message = new TransactionMessage(signedTransaction.toByteArray());
559559
if (minEffectiveConnection != 0) {
560560
if (tronNetDelegate.getActivePeer().isEmpty()) {
561561
logger
@@ -686,7 +686,7 @@ public TransactionSignWeight getTransactionSignWeight(Transaction trx) {
686686
}
687687
if (permissionId != 0) {
688688
if (permission.getType() != PermissionType.Active) {
689-
throw new PermissionException("Permission type is error");
689+
throw new PermissionException("Permission type is wrong!");
690690
}
691691
//check operations
692692
if (!checkPermissionOprations(permission, contract)) {
@@ -1109,9 +1109,7 @@ public AssetIssueList getAssetIssueByAccount(ByteString accountAddress) {
11091109
AssetIssueList.Builder builder = AssetIssueList.newBuilder();
11101110
assetIssueCapsuleList.stream()
11111111
.filter(assetIssueCapsule -> assetIssueCapsule.getOwnerAddress().equals(accountAddress))
1112-
.forEach(issueCapsule -> {
1113-
builder.addAssetIssue(issueCapsule.getInstance());
1114-
});
1112+
.forEach(issueCapsule -> builder.addAssetIssue(issueCapsule.getInstance()));
11151113

11161114
return builder.build();
11171115
}
@@ -1249,9 +1247,7 @@ public AssetIssueContract getAssetIssueByName(ByteString assetName)
12491247
.stream()
12501248
.filter(assetIssueCapsule -> assetIssueCapsule.getName().equals(assetName))
12511249
.forEach(
1252-
issueCapsule -> {
1253-
builder.addAssetIssue(issueCapsule.getInstance());
1254-
});
1250+
issueCapsule -> builder.addAssetIssue(issueCapsule.getInstance()));
12551251

12561252
// check count
12571253
if (builder.getAssetIssueCount() > 1) {
@@ -1273,7 +1269,7 @@ public AssetIssueContract getAssetIssueByName(ByteString assetName)
12731269
// check count
12741270
if (builder.getAssetIssueCount() > 1) {
12751271
throw new NonUniqueObjectException(
1276-
"To get more than one asset, please use getAssetIssuebyid syntax");
1272+
"To get more than one asset, please use getAssetIssueById syntax");
12771273
}
12781274
}
12791275
}
@@ -1297,9 +1293,7 @@ public AssetIssueList getAssetIssueListByName(ByteString assetName) {
12971293
AssetIssueList.Builder builder = AssetIssueList.newBuilder();
12981294
assetIssueCapsuleList.stream()
12991295
.filter(assetIssueCapsule -> assetIssueCapsule.getName().equals(assetName))
1300-
.forEach(issueCapsule -> {
1301-
builder.addAssetIssue(issueCapsule.getInstance());
1302-
});
1296+
.forEach(issueCapsule -> builder.addAssetIssue(issueCapsule.getInstance()));
13031297

13041298
return builder.build();
13051299
}
@@ -1473,7 +1467,7 @@ private IncrementalMerkleVoucherContainer createWitness(OutputPoint outPoint, Lo
14731467
//Get the tree in blockNum-1 position
14741468
byte[] treeRoot = dbManager.getMerkleTreeIndexStore().get(blockNumber - 1);
14751469
if (treeRoot == null) {
1476-
throw new RuntimeException("treeRoot is null,blockNumber:" + (blockNumber - 1));
1470+
throw new RuntimeException("treeRoot is null, blockNumber:" + (blockNumber - 1));
14771471
}
14781472

14791473
IncrementalMerkleTreeCapsule treeCapsule = dbManager.getMerkleTreeStore()
@@ -1986,7 +1980,7 @@ public TransactionCapsule createShieldedTransactionWithoutSpendAuthSig(
19861980
try {
19871981
transactionCapsule = builder.buildWithoutAsk();
19881982
} catch (ZksnarkException e) {
1989-
logger.error("createShieldedTransaction except, error is " + e.toString());
1983+
logger.error("createShieldedTransaction exception, error is " + e.toString());
19901984
throw new ZksnarkException(e.toString());
19911985
}
19921986
return transactionCapsule;
@@ -2368,7 +2362,7 @@ public Transaction callConstantContract(TransactionCapsule trxCap, Builder
23682362
ProgramResult result = context.getProgramResult();
23692363
if (result.getException() != null) {
23702364
RuntimeException e = result.getException();
2371-
logger.warn("Constant call has error {}", e.getMessage());
2365+
logger.warn("Constant call has an error {}", e.getMessage());
23722366
throw e;
23732367
}
23742368

framework/src/main/java/org/tron/core/services/RpcApiService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,12 @@ public void start() {
217217
logger.debug(e.getMessage(), e);
218218
}
219219

220-
logger.info("RpcApiService started, listening on " + port);
220+
logger.info("RpcApiService has started, listening on " + port);
221221

222222
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
223223
System.err.println("*** shutting down gRPC server since JVM is shutting down");
224224
//server.this.stop();
225-
System.err.println("*** server shut down");
225+
System.err.println("*** server is shutdown");
226226
}));
227227
}
228228

@@ -1068,7 +1068,7 @@ private void checkVoteWitnessAccount(VoteWitnessContract req) {
10681068

10691069
Preconditions.checkNotNull(witness, "witness[" + readableWitnessAddress + "] not exists");
10701070
Preconditions.checkArgument(vote.getVoteCount() <= 0,
1071-
"VoteAddress[" + readableWitnessAddress + "],VotesCount[" + vote
1071+
"VoteAddress[" + readableWitnessAddress + "], VotesCount[" + vote
10721072
.getVoteCount() + "] <= 0");
10731073
});
10741074
}

framework/src/main/java/org/tron/core/services/http/Util.java

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,7 @@ public static String printBlockList(BlockList list, boolean selfType) {
7070
List<Block> blocks = list.getBlockList();
7171
JSONObject jsonObject = JSONObject.parseObject(JsonFormat.printToString(list, selfType));
7272
JSONArray jsonArray = new JSONArray();
73-
blocks.stream().forEach(block -> {
74-
jsonArray.add(printBlockToJSON(block, selfType));
75-
});
73+
blocks.stream().forEach(block -> jsonArray.add(printBlockToJSON(block, selfType)));
7674
jsonObject.put("block", jsonArray);
7775

7876
return jsonObject.toJSONString();
@@ -98,9 +96,9 @@ public static String printTransactionList(TransactionList list, boolean selfType
9896
List<Transaction> transactions = list.getTransactionList();
9997
JSONObject jsonObject = JSONObject.parseObject(JsonFormat.printToString(list, selfType));
10098
JSONArray jsonArray = new JSONArray();
101-
transactions.stream().forEach(transaction -> {
102-
jsonArray.add(printTransactionToJSON(transaction, selfType));
103-
});
99+
transactions.stream().forEach(transaction -> jsonArray
100+
.add(printTransactionToJSON(transaction, selfType))
101+
);
104102
jsonObject.put(TRANSACTION, jsonArray);
105103

106104
return jsonObject.toJSONString();
@@ -109,9 +107,8 @@ public static String printTransactionList(TransactionList list, boolean selfType
109107
public static JSONArray printTransactionListToJSON(List<TransactionCapsule> list,
110108
boolean selfType) {
111109
JSONArray transactions = new JSONArray();
112-
list.stream().forEach(transactionCapsule -> {
113-
transactions.add(printTransactionToJSON(transactionCapsule.getInstance(), selfType));
114-
});
110+
list.stream().forEach(transactionCapsule -> transactions
111+
.add(printTransactionToJSON(transactionCapsule.getInstance(), selfType)));
115112
return transactions;
116113
}
117114

@@ -285,7 +282,7 @@ public static Transaction packTransaction(String strTransaction, boolean selfTyp
285282
public static void checkBodySize(String body) throws Exception {
286283
Args args = Args.getInstance();
287284
if (body.getBytes().length > args.getMaxMessageSize()) {
288-
throw new Exception("body size is too big, limit is " + args.getMaxMessageSize());
285+
throw new Exception("body size is too big, the limit is " + args.getMaxMessageSize());
289286
}
290287
}
291288

@@ -386,21 +383,21 @@ public static long getJsonLongValue(final JSONObject jsonObject, final String ke
386383
public static long getJsonLongValue(JSONObject jsonObject, String key, boolean required) {
387384
BigDecimal bigDecimal = jsonObject.getBigDecimal(key);
388385
if (required && bigDecimal == null) {
389-
throw new InvalidParameterException("key [" + key + "] not exist");
386+
throw new InvalidParameterException("key [" + key + "] does not exist");
390387
}
391388
return (bigDecimal == null) ? 0L : bigDecimal.longValueExact();
392389
}
393390

394-
public static String getMemo(byte[] meno) {
395-
int index = meno.length;
391+
public static String getMemo(byte[] memo) {
392+
int index = memo.length;
396393
for (; index > 0; --index) {
397-
if (meno[index - 1] != 0) {
394+
if (memo[index - 1] != 0) {
398395
break;
399396
}
400397
}
401398

402399
byte[] inputCheck = new byte[index];
403-
System.arraycopy(meno, 0, inputCheck, 0, index);
400+
System.arraycopy(memo, 0, inputCheck, 0, index);
404401
return new String(inputCheck, Charset.forName("UTF-8"));
405402
}
406403

framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/GetBrokerageOnSolidityServlet.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) {
2121
}
2222

2323
protected void doPost(HttpServletRequest request, HttpServletResponse response) {
24-
walletOnSolidity.futureGet(() -> {
25-
super.doPost(request, response);
26-
});
24+
walletOnSolidity.futureGet(() -> super.doPost(request, response));
2725
}
2826
}

0 commit comments

Comments
 (0)