Repository navigation
Expand file tree
/
Copy pathPendingManager.java
More file actions
61 lines (56 loc) · 1.99 KB
/
Copy pathPendingManager.java
File metadata and controls
61 lines (56 loc) · 1.99 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
package org.tron.core.db;
import java.util.ArrayList;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.tron.core.capsule.TransactionCapsule;
import org.tron.core.exception.ContractExeException;
import org.tron.core.exception.ContractValidateException;
import org.tron.core.exception.HighFreqException;
import org.tron.core.exception.ValidateSignatureException;
@Slf4j
public class PendingManager implements AutoCloseable {
List<TransactionCapsule> tmpTransactions = new ArrayList<>();
Manager dbManager;
public PendingManager(Manager db) {
this.dbManager = db;
tmpTransactions.addAll(db.getPendingTransactions());
db.getPendingTransactions().clear();
db.getDialog().reset();
}
@Override
public void close() {
this.tmpTransactions.stream()
.filter(
trx -> dbManager.getTransactionStore().get(trx.getTransactionId().getBytes()) == null)
.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 (HighFreqException e) {
logger.debug(e.getMessage(), e);
}
});
dbManager.getPoppedTransactions().stream()
.filter(
trx -> dbManager.getTransactionStore().get(trx.getTransactionId().getBytes()) == null)
.forEach(trx -> {
try {
dbManager.pushTransactions(trx);
} catch (ValidateSignatureException e) {
e.printStackTrace();
} catch (ContractValidateException e) {
e.printStackTrace();
} catch (ContractExeException e) {
e.printStackTrace();
} catch (HighFreqException e) {
e.printStackTrace();
}
});
dbManager.getPoppedTransactions().clear();
}
}