forked from tronprotocol/java-tron
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPendingManager.java
More file actions
82 lines (76 loc) · 2.94 KB
/
PendingManager.java
File metadata and controls
82 lines (76 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package org.tron.core.db;
import java.util.ArrayList;
import java.util.List;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.tron.core.capsule.TransactionCapsule;
import org.tron.core.exception.AccountResourceInsufficientException;
import org.tron.core.exception.BadItemException;
import org.tron.core.exception.ContractExeException;
import org.tron.core.exception.ContractValidateException;
import org.tron.core.exception.DupTransactionException;
import org.tron.core.exception.OutOfSlotTimeException;
import org.tron.core.exception.ReceiptException;
import org.tron.core.exception.TaposException;
import org.tron.core.exception.TooBigTransactionException;
import org.tron.core.exception.TransactionExpirationException;
import org.tron.core.exception.TransactionTraceException;
import org.tron.core.exception.ValidateSignatureException;
@Slf4j
public class PendingManager implements AutoCloseable {
@Getter
static List<TransactionCapsule> tmpTransactions = new ArrayList<>();
Manager dbManager;
public PendingManager(Manager db) {
this.dbManager = db;
tmpTransactions.addAll(db.getPendingTransactions());
db.getPendingTransactions().clear();
db.getSession().reset();
}
@Override
public void close() {
rePush(this.tmpTransactions);
rePush(dbManager.getPoppedTransactions());
dbManager.getPoppedTransactions().clear();
tmpTransactions.clear();
}
private void rePush(List<TransactionCapsule> txs) {
txs.stream()
.filter(
trx -> {
try {
return
dbManager.getTransactionStore().get(trx.getTransactionId().getBytes()) == null;
} catch (BadItemException e) {
return true;
}
})
.forEach(trx -> {
try {
dbManager.pushTransactions(trx);
} catch (ValidateSignatureException e) {
logger.debug(e.getMessage(), e);
} catch (ContractValidateException e) {
logger.debug(e.getMessage(), e);
} catch (ContractExeException e) {
logger.debug(e.getMessage(), e);
} catch (AccountResourceInsufficientException e) {
logger.debug(e.getMessage(), e);
} catch (DupTransactionException e) {
logger.debug("pending manager: dup trans", e);
} catch (TaposException e) {
logger.debug("pending manager: tapos exception", e);
} catch (TooBigTransactionException e) {
logger.debug("too big transaction");
} catch (ReceiptException e) {
logger.info("Receipt exception," + e.getMessage());
} catch (TransactionExpirationException e) {
logger.debug("expiration transaction");
} catch (TransactionTraceException e) {
logger.debug("transactionTrace transaction");
} catch (OutOfSlotTimeException e) {
logger.debug("outOfSlotTime transaction");
}
});
}
}