Skip to content

Commit cf1ea44

Browse files
committed
remove Useless Exception.
(cherry picked from commit e184134)
1 parent ebf7765 commit cf1ea44

6 files changed

Lines changed: 24 additions & 64 deletions

File tree

‎src/main/java/org/tron/core/db/Manager.java‎

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
import static org.tron.core.config.Parameter.ChainConstant.SOLIDIFIED_THRESHOLD;
44
import static org.tron.core.config.Parameter.NodeConstant.MAX_TRANSACTION_PENDING;
5-
import static org.tron.protos.Protocol.Transaction.Contract.ContractType.TransferAssetContract;
6-
import static org.tron.protos.Protocol.Transaction.Contract.ContractType.TransferContract;
75

86
import com.google.common.cache.Cache;
97
import com.google.common.cache.CacheBuilder;
@@ -46,7 +44,6 @@
4644
import org.tron.common.utils.SessionOptional;
4745
import org.tron.common.utils.Sha256Hash;
4846
import org.tron.common.utils.StringUtil;
49-
import org.tron.common.utils.Time;
5047
import org.tron.core.Constant;
5148
import org.tron.core.capsule.AccountCapsule;
5249
import org.tron.core.capsule.BlockCapsule;
@@ -73,11 +70,9 @@
7370
import org.tron.core.exception.ContractValidateException;
7471
import org.tron.core.exception.DupTransactionException;
7572
import org.tron.core.exception.HeaderNotFound;
76-
import org.tron.core.exception.HighFreqException;
7773
import org.tron.core.exception.ItemNotFoundException;
7874
import org.tron.core.exception.NonCommonBlockException;
7975
import org.tron.core.exception.ReceiptCheckErrException;
80-
import org.tron.core.exception.ReceiptException;
8176
import org.tron.core.exception.TaposException;
8277
import org.tron.core.exception.TooBigTransactionException;
8378
import org.tron.core.exception.TooBigTransactionResultException;
@@ -90,7 +85,6 @@
9085
import org.tron.core.witness.ProposalController;
9186
import org.tron.core.witness.WitnessController;
9287
import org.tron.protos.Protocol.AccountType;
93-
import org.tron.protos.Protocol.Transaction;
9488

9589

9690
@Slf4j
@@ -558,7 +552,7 @@ void validateDup(TransactionCapsule transactionCapsule) throws DupTransactionExc
558552
public boolean pushTransaction(final TransactionCapsule trx)
559553
throws ValidateSignatureException, ContractValidateException, ContractExeException,
560554
AccountResourceInsufficientException, DupTransactionException, TaposException,
561-
TooBigTransactionException, TransactionExpirationException, ReceiptException,
555+
TooBigTransactionException, TransactionExpirationException,
562556
TransactionTraceException, ReceiptCheckErrException, VMIllegalException, TooBigTransactionResultException {
563557

564558
if (!trx.validateSignature()) {
@@ -608,7 +602,7 @@ public void eraseBlock() {
608602

609603
public void pushVerifiedBlock(BlockCapsule block) throws ContractValidateException,
610604
ContractExeException, ValidateSignatureException, AccountResourceInsufficientException,
611-
TransactionExpirationException, TooBigTransactionException, DupTransactionException, ReceiptException,
605+
TransactionExpirationException, TooBigTransactionException, DupTransactionException,
612606
TaposException, ValidateScheduleException, TransactionTraceException, ReceiptCheckErrException,
613607
VMIllegalException, TooBigTransactionResultException {
614608
block.generatedByMyself = true;
@@ -617,7 +611,7 @@ public void pushVerifiedBlock(BlockCapsule block) throws ContractValidateExcepti
617611

618612
private void applyBlock(BlockCapsule block) throws ContractValidateException,
619613
ContractExeException, ValidateSignatureException, AccountResourceInsufficientException,
620-
TransactionExpirationException, TooBigTransactionException, DupTransactionException, ReceiptException,
614+
TransactionExpirationException, TooBigTransactionException, DupTransactionException,
621615
TaposException, ValidateScheduleException, TransactionTraceException, ReceiptCheckErrException,
622616
VMIllegalException, TooBigTransactionResultException {
623617
processBlock(block);
@@ -630,7 +624,7 @@ private void switchFork(BlockCapsule newHead)
630624
throws ValidateSignatureException, ContractValidateException, ContractExeException,
631625
ValidateScheduleException, AccountResourceInsufficientException, TaposException,
632626
TooBigTransactionException, TooBigTransactionResultException, DupTransactionException, TransactionExpirationException,
633-
NonCommonBlockException, ReceiptException, TransactionTraceException, ReceiptCheckErrException,
627+
NonCommonBlockException, TransactionTraceException, ReceiptCheckErrException,
634628
VMIllegalException {
635629
Pair<LinkedList<KhaosBlock>, LinkedList<KhaosBlock>> binaryTree;
636630
try {
@@ -673,7 +667,6 @@ private void switchFork(BlockCapsule newHead)
673667
| DupTransactionException
674668
| TransactionExpirationException
675669
| TransactionTraceException
676-
| ReceiptException
677670
| ReceiptCheckErrException
678671
| TooBigTransactionException
679672
| TooBigTransactionResultException
@@ -729,7 +722,7 @@ public synchronized void pushBlock(final BlockCapsule block)
729722
throws ValidateSignatureException, ContractValidateException, ContractExeException,
730723
UnLinkedBlockException, ValidateScheduleException, AccountResourceInsufficientException,
731724
TaposException, TooBigTransactionException, TooBigTransactionResultException, DupTransactionException, TransactionExpirationException,
732-
BadNumberBlockException, BadBlockException, NonCommonBlockException, ReceiptException, TransactionTraceException,
725+
BadNumberBlockException, BadBlockException, NonCommonBlockException, TransactionTraceException,
733726
ReceiptCheckErrException, VMIllegalException {
734727
try (PendingManager pm = new PendingManager(this)) {
735728

@@ -941,7 +934,7 @@ public boolean hasBlocks() {
941934
* Process transaction.
942935
*/
943936
public boolean processTransaction(final TransactionCapsule trxCap, BlockCapsule blockCap)
944-
throws ValidateSignatureException, ContractValidateException, ContractExeException, ReceiptException,
937+
throws ValidateSignatureException, ContractValidateException, ContractExeException,
945938
AccountResourceInsufficientException, TransactionExpirationException, TooBigTransactionException, TooBigTransactionResultException,
946939
DupTransactionException, TaposException, TransactionTraceException, ReceiptCheckErrException, VMIllegalException {
947940
if (trxCap == null) {
@@ -1100,9 +1093,6 @@ public synchronized BlockCapsule generateBlock(
11001093
} catch (ValidateSignatureException e) {
11011094
logger.info("contract not processed during ValidateSignatureException");
11021095
logger.debug(e.getMessage(), e);
1103-
} catch (ReceiptException e) {
1104-
logger.info("receipt exception: {}", e.getMessage());
1105-
logger.debug(e.getMessage(), e);
11061096
} catch (ReceiptCheckErrException e) {
11071097
logger.info("OutOfSlotTime exception: {}", e.getMessage());
11081098
logger.debug(e.getMessage(), e);
@@ -1140,9 +1130,6 @@ public synchronized BlockCapsule generateBlock(
11401130
logger.info("block exception");
11411131
} catch (NonCommonBlockException e) {
11421132
logger.info("non common exception");
1143-
} catch (ReceiptException e) {
1144-
logger.info("receipt exception: {}", e.getMessage());
1145-
logger.debug(e.getMessage(), e);
11461133
} catch (ReceiptCheckErrException e) {
11471134
logger.info("OutOfSlotTime exception: {}", e.getMessage());
11481135
logger.debug(e.getMessage(), e);
@@ -1156,13 +1143,11 @@ public synchronized BlockCapsule generateBlock(
11561143
}
11571144

11581145

1159-
11601146
public TransactionStore getTransactionStore() {
11611147
return this.transactionStore;
11621148
}
11631149

11641150

1165-
11661151
public TransactionHistoryStore getTransactionHistoryStore() {
11671152
return this.transactionHistoryStore;
11681153
}
@@ -1179,7 +1164,7 @@ public void processBlock(BlockCapsule block)
11791164
throws ValidateSignatureException, ContractValidateException, ContractExeException,
11801165
AccountResourceInsufficientException, TaposException, TooBigTransactionException,
11811166
DupTransactionException, TransactionExpirationException, ValidateScheduleException,
1182-
ReceiptException, TransactionTraceException, ReceiptCheckErrException, VMIllegalException, TooBigTransactionResultException {
1167+
TransactionTraceException, ReceiptCheckErrException, VMIllegalException, TooBigTransactionResultException {
11831168
// todo set revoking db max size.
11841169

11851170
// checkWitness
@@ -1508,8 +1493,6 @@ public void rePush(TransactionCapsule tx) {
15081493
logger.debug("pending manager: tapos exception", e);
15091494
} catch (TooBigTransactionException e) {
15101495
logger.debug("too big transaction");
1511-
} catch (ReceiptException e) {
1512-
logger.info("Receipt exception," + e.getMessage());
15131496
} catch (TransactionExpirationException e) {
15141497
logger.debug("expiration transaction");
15151498
} catch (TransactionTraceException e) {

‎src/main/java/org/tron/core/exception/ReceiptException.java‎

Lines changed: 0 additions & 13 deletions
This file was deleted.

‎src/main/java/org/tron/core/net/node/NodeDelegateImpl.java‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import org.tron.core.exception.ItemNotFoundException;
3232
import org.tron.core.exception.NonCommonBlockException;
3333
import org.tron.core.exception.ReceiptCheckErrException;
34-
import org.tron.core.exception.ReceiptException;
3534
import org.tron.core.exception.StoreException;
3635
import org.tron.core.exception.TaposException;
3736
import org.tron.core.exception.TooBigTransactionException;
@@ -102,8 +101,6 @@ public synchronized LinkedList<Sha256Hash> handleBlock(BlockCapsule block, boole
102101
throw new BadBlockException("TooBigTransaction exception," + e.getMessage());
103102
} catch (TransactionExpirationException e) {
104103
throw new BadBlockException("Expiration exception," + e.getMessage());
105-
} catch (ReceiptException e) {
106-
throw new BadBlockException("Receipt exception," + e.getMessage());
107104
} catch (BadNumberBlockException e) {
108105
throw new BadBlockException("bad number exception," + e.getMessage());
109106
} catch (TransactionTraceException e) {
@@ -154,8 +151,6 @@ public boolean handleTransaction(TransactionCapsule trx) throws BadTransactionEx
154151
} catch (TaposException e) {
155152
logger.info("Tapos error" + e.getMessage());
156153
return false;
157-
} catch (ReceiptException e) {
158-
logger.info("Receipt exception," + e.getMessage());
159154
} catch (TooBigTransactionException e) {
160155
logger.info("Too big transaction" + e.getMessage());
161156
return false;

‎src/main/java/org/tron/core/services/WitnessService.java‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import org.tron.core.exception.AccountResourceInsufficientException;
2525
import org.tron.core.exception.ContractExeException;
2626
import org.tron.core.exception.ContractValidateException;
27-
import org.tron.core.exception.ReceiptException;
2827
import org.tron.core.exception.TransactionTraceException;
2928
import org.tron.core.exception.TronException;
3029
import org.tron.core.exception.UnLinkedBlockException;
@@ -273,7 +272,7 @@ private BlockCapsule generateBlock(long when, ByteString witnessAddress,
273272
Boolean lastHeadBlockIsMaintenance)
274273
throws ValidateSignatureException, ContractValidateException, ContractExeException,
275274
UnLinkedBlockException, ValidateScheduleException, AccountResourceInsufficientException,
276-
ReceiptException, TransactionTraceException {
275+
TransactionTraceException {
277276
return tronApp.getDbManager().generateBlock(this.localWitnessStateMap.get(witnessAddress), when,
278277
this.privateKeyMap.get(witnessAddress), lastHeadBlockIsMaintenance);
279278
}

‎src/main/java/org/tron/program/SolidityNode.java‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.tron.core.exception.ContractValidateException;
2828
import org.tron.core.exception.DupTransactionException;
2929
import org.tron.core.exception.ReceiptCheckErrException;
30-
import org.tron.core.exception.ReceiptException;
3130
import org.tron.core.exception.TaposException;
3231
import org.tron.core.exception.TooBigTransactionException;
3332
import org.tron.core.exception.TooBigTransactionResultException;
@@ -142,8 +141,6 @@ private void syncSolidityBlock() throws BadBlockException {
142141
throw new BadBlockException("expiration exception");
143142
// } catch (BadNumberBlockException e) {
144143
// throw new BadBlockException("bad number exception");
145-
} catch (ReceiptException e) {
146-
throw new BadBlockException("Receipt exception");
147144
// } catch (NonCommonBlockException e) {
148145
// throw new BadBlockException("non common exception");
149146
} catch (TransactionTraceException e) {

‎src/test/java/org/tron/core/db/ManagerTest.java‎

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import org.tron.core.exception.ItemNotFoundException;
3636
import org.tron.core.exception.NonCommonBlockException;
3737
import org.tron.core.exception.ReceiptCheckErrException;
38-
import org.tron.core.exception.ReceiptException;
3938
import org.tron.core.exception.TaposException;
4039
import org.tron.core.exception.TooBigTransactionException;
4140
import org.tron.core.exception.TooBigTransactionResultException;
@@ -92,7 +91,7 @@ public void removeDb() {
9291
@Test
9392
public void setBlockReference()
9493
throws ContractExeException, UnLinkedBlockException, ValidateScheduleException, BadBlockException,
95-
ContractValidateException, ValidateSignatureException, BadItemException, ItemNotFoundException, AccountResourceInsufficientException, TransactionExpirationException, TooBigTransactionException, DupTransactionException, TaposException, BadNumberBlockException, NonCommonBlockException, ReceiptException, TransactionTraceException, ReceiptCheckErrException, VMIllegalException, TooBigTransactionResultException {
94+
ContractValidateException, ValidateSignatureException, BadItemException, ItemNotFoundException, AccountResourceInsufficientException, TransactionExpirationException, TooBigTransactionException, DupTransactionException, TaposException, BadNumberBlockException, NonCommonBlockException, TransactionTraceException, ReceiptCheckErrException, VMIllegalException, TooBigTransactionResultException {
9695

9796
BlockCapsule blockCapsule =
9897
new BlockCapsule(
@@ -216,7 +215,7 @@ public void updateWits() {
216215
@Test
217216
public void fork()
218217
throws ValidateSignatureException, ContractValidateException, ContractExeException,
219-
UnLinkedBlockException, ValidateScheduleException, BadItemException, ReceiptException,
218+
UnLinkedBlockException, ValidateScheduleException, BadItemException,
220219
ItemNotFoundException, HeaderNotFound, AccountResourceInsufficientException,
221220
TransactionExpirationException, TooBigTransactionException, DupTransactionException,
222221
BadBlockException, TaposException, BadNumberBlockException, NonCommonBlockException,
@@ -230,7 +229,7 @@ public void fork()
230229
byte[] address = ecKey.getAddress();
231230
WitnessCapsule witnessCapsule = new WitnessCapsule(ByteString.copyFrom(address));
232231
dbManager.addWitness(ByteString.copyFrom(address));
233-
dbManager.generateBlock(witnessCapsule, 1533529947843L, privateKey,false);
232+
dbManager.generateBlock(witnessCapsule, 1533529947843L, privateKey, false);
234233

235234
Map<ByteString, String> addressToProvateKeys = addTestWitnessAndAccount();
236235

@@ -284,7 +283,7 @@ public void fork()
284283
@Test
285284
public void doNotSwitch()
286285
throws ValidateSignatureException, ContractValidateException, ContractExeException,
287-
UnLinkedBlockException, ValidateScheduleException, BadItemException, ReceiptException,
286+
UnLinkedBlockException, ValidateScheduleException, BadItemException,
288287
ItemNotFoundException, HeaderNotFound, AccountResourceInsufficientException,
289288
TransactionExpirationException, TooBigTransactionException,
290289
DupTransactionException, BadBlockException,
@@ -299,7 +298,7 @@ public void doNotSwitch()
299298
byte[] address = ecKey.getAddress();
300299
WitnessCapsule witnessCapsule = new WitnessCapsule(ByteString.copyFrom(address));
301300
dbManager.addWitness(ByteString.copyFrom(address));
302-
dbManager.generateBlock(witnessCapsule, 1533529947843L, privateKey,false);
301+
dbManager.generateBlock(witnessCapsule, 1533529947843L, privateKey, false);
303302

304303
Map<ByteString, String> addressToProvateKeys = addTestWitnessAndAccount();
305304

@@ -379,14 +378,14 @@ public void doNotSwitch()
379378

380379
@Test
381380
public void testLastHeadBlockIsMaintenance()
382-
throws ValidateSignatureException, ContractValidateException, ContractExeException,
383-
UnLinkedBlockException, ValidateScheduleException, BadItemException, ReceiptException,
384-
ItemNotFoundException, HeaderNotFound, AccountResourceInsufficientException,
385-
TransactionExpirationException, TooBigTransactionException, DupTransactionException,
386-
BadBlockException, TaposException, BadNumberBlockException, NonCommonBlockException,
387-
TransactionTraceException, ReceiptCheckErrException, VMIllegalException,
388-
TooBigTransactionResultException {
389-
Args.setParam(new String[] {"--witness"}, Constant.TEST_CONF);
381+
throws ValidateSignatureException, ContractValidateException, ContractExeException,
382+
UnLinkedBlockException, ValidateScheduleException, BadItemException,
383+
ItemNotFoundException, HeaderNotFound, AccountResourceInsufficientException,
384+
TransactionExpirationException, TooBigTransactionException, DupTransactionException,
385+
BadBlockException, TaposException, BadNumberBlockException, NonCommonBlockException,
386+
TransactionTraceException, ReceiptCheckErrException, VMIllegalException,
387+
TooBigTransactionResultException {
388+
Args.setParam(new String[]{"--witness"}, Constant.TEST_CONF);
390389
long size = dbManager.getBlockStore().size();
391390
System.out.print("block store size:" + size + "\n");
392391
String key = "f31db24bfbd1a2ef19beddca0a0fa37632eded9ac666a05d3bd925f01dde1f62";
@@ -396,7 +395,7 @@ public void testLastHeadBlockIsMaintenance()
396395
WitnessCapsule witnessCapsule = new WitnessCapsule(ByteString.copyFrom(address));
397396
dbManager.addWitness(ByteString.copyFrom(address));
398397
BlockCapsule blockCapsule =
399-
dbManager.generateBlock(witnessCapsule, 1533529947843L, privateKey, true);
398+
dbManager.generateBlock(witnessCapsule, 1533529947843L, privateKey, true);
400399

401400
//has processed the first block of the maintenance period before starting the block
402401
dbManager.getWitnessStore().reset();
@@ -408,7 +407,7 @@ public void testLastHeadBlockIsMaintenance()
408407
@Test
409408
public void switchBack()
410409
throws ValidateSignatureException, ContractValidateException, ContractExeException,
411-
UnLinkedBlockException, ValidateScheduleException, BadItemException, ReceiptException,
410+
UnLinkedBlockException, ValidateScheduleException, BadItemException,
412411
ItemNotFoundException, HeaderNotFound, AccountResourceInsufficientException,
413412
TransactionExpirationException, TooBigTransactionException, DupTransactionException,
414413
BadBlockException, TaposException, BadNumberBlockException, NonCommonBlockException,
@@ -422,7 +421,7 @@ public void switchBack()
422421
byte[] address = ecKey.getAddress();
423422
WitnessCapsule witnessCapsule = new WitnessCapsule(ByteString.copyFrom(address));
424423
dbManager.addWitness(ByteString.copyFrom(address));
425-
dbManager.generateBlock(witnessCapsule, 1533529947843L, privateKey,false);
424+
dbManager.generateBlock(witnessCapsule, 1533529947843L, privateKey, false);
426425

427426
Map<ByteString, String> addressToProvateKeys = addTestWitnessAndAccount();
428427

0 commit comments

Comments
 (0)