use of org.aion.zero.impl.types.TxResponse in project aion by aionnetwork.
the class AionPendingStateImpl method processTxToTxPool.
private TxResponse processTxToTxPool(AionTransaction tx, int fetchLimit, List<AionTransaction> newPending) {
TxResponse response = addPendingTransactionInner(tx);
if (response.equals(TxResponse.SUCCESS)) {
newPending.add(tx);
addPendingTxToBackupDatabase(tx);
Map<BigInteger, AionTransaction> cachedTxWithSender = pendingTxCache.getCacheTxBySender(tx.getSenderAddress());
if (cachedTxWithSender != null) {
LOGGER_TX.debug("add Transaction from cache, sender: {}, size: {}", tx.getSenderAddress(), cachedTxWithSender.size());
BigInteger newCachedTxNonce = tx.getNonceBI().add(BigInteger.ONE);
AionTransaction newCachedTx = cachedTxWithSender.get(newCachedTxNonce);
while (response.equals(TxResponse.SUCCESS) && newCachedTx != null && fetchLimit-- > 0 && !txPool.isFull()) {
LOGGER_TX.debug("add Transaction from cache, sender: {}, nonce: {}", newCachedTx.getSenderAddress(), newCachedTxNonce);
response = addPendingTransactionInner(newCachedTx);
if (response.equals(TxResponse.SUCCESS)) {
newPending.add(newCachedTx);
addPendingTxToBackupDatabase(newCachedTx);
pendingTxCache.removeTransaction(newCachedTx.getSenderAddress(), newCachedTxNonce);
newCachedTxNonce = newCachedTxNonce.add(BigInteger.ONE);
newCachedTx = cachedTxWithSender.get(newCachedTxNonce);
}
}
}
}
return response;
}
use of org.aion.zero.impl.types.TxResponse in project aion by aionnetwork.
the class TXValidatorTest method validateTxSignatureSwapForkEnabledReceiverAddressIsZeroTest.
@Test
public void validateTxSignatureSwapForkEnabledReceiverAddressIsZeroTest() {
boolean signatureSwapEnabled = true;
AionTransaction tx = AionTransaction.create(key, nonce, ZERO_ADDRESS, value, data, nrg, nrgPrice, type, null);
TxResponse response = TXValidator.validateTx(tx, unityForkEnabled, signatureSwapEnabled);
assertEquals(TxResponse.SUCCESS, response);
}
use of org.aion.zero.impl.types.TxResponse in project aion by aionnetwork.
the class TXValidatorTest method validateTxSignatureSwapForkDisabledReceiverAddressTest.
@Test
public void validateTxSignatureSwapForkDisabledReceiverAddressTest() {
boolean signatureSwapEnabled = false;
byte[] dest = RandomUtils.nextBytes(32);
dest[0] = (byte) 0xa1;
AionTransaction tx = AionTransaction.create(key, nonce, new AionAddress(dest), value, data, nrg, nrgPrice, type, null);
TxResponse response = TXValidator.validateTx(tx, unityForkEnabled, signatureSwapEnabled);
assertEquals(TxResponse.SUCCESS, response);
}
Aggregations