mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Fix a bug. We mishandle the sequence.
This commit is contained in:
@@ -121,16 +121,35 @@ TER TransactionEngine::applyTransaction(const SerializedTransaction& txn, Transa
|
|||||||
mNodes.clear();
|
mNodes.clear();
|
||||||
|
|
||||||
SLE::pointer txnAcct = entryCache(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(txn.getSourceAccount()));
|
SLE::pointer txnAcct = entryCache(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(txn.getSourceAccount()));
|
||||||
STAmount fee = txn.getTransactionFee();
|
if (!txnAcct)
|
||||||
STAmount balance = txnAcct->getFieldAmount(sfBalance);
|
terResult = terNO_ACCOUNT;
|
||||||
|
|
||||||
if (balance < fee)
|
|
||||||
terResult = terINSUF_FEE_B;
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
txnAcct->setFieldAmount(sfBalance, balance - fee);
|
uint32 t_seq = txn.getSequence();
|
||||||
applyTransaction = true;
|
uint32 a_seq = txnAcct->getFieldU32(sfSequence);
|
||||||
entryModify(txnAcct);
|
|
||||||
|
if (t_seq != a_seq)
|
||||||
|
{
|
||||||
|
if (a_seq < t_seq)
|
||||||
|
terResult = terPRE_SEQ;
|
||||||
|
else
|
||||||
|
terResult = tefPAST_SEQ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
STAmount fee = txn.getTransactionFee();
|
||||||
|
STAmount balance = txnAcct->getFieldAmount(sfBalance);
|
||||||
|
|
||||||
|
if (balance < fee)
|
||||||
|
terResult = terINSUF_FEE_B;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
txnAcct->setFieldAmount(sfBalance, balance - fee);
|
||||||
|
txnAcct->setFieldU32(sfSequence, t_seq + 1);
|
||||||
|
applyTransaction = true;
|
||||||
|
entryModify(txnAcct);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user