mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
ctid everywhere
This commit is contained in:
@@ -74,7 +74,8 @@ public:
|
||||
|
||||
// return value: true = we had the transaction already
|
||||
bool
|
||||
inLedger(uint256 const& hash, std::uint32_t ledger);
|
||||
inLedger(uint256 const& hash, std::uint32_t ledger,
|
||||
std::optional<uint32_t> tseq, std::optional<uint16_t> netID);
|
||||
|
||||
void
|
||||
canonicalize(std::shared_ptr<Transaction>* pTransaction);
|
||||
|
||||
@@ -37,14 +37,15 @@ TransactionMaster::TransactionMaster(Application& app)
|
||||
}
|
||||
|
||||
bool
|
||||
TransactionMaster::inLedger(uint256 const& hash, std::uint32_t ledger)
|
||||
TransactionMaster::inLedger(uint256 const& hash, std::uint32_t ledger,
|
||||
std::optional<uint32_t> tseq, std::optional<uint16_t> netID)
|
||||
{
|
||||
auto txn = mCache.fetch(hash);
|
||||
|
||||
if (!txn)
|
||||
return false;
|
||||
|
||||
txn->setStatus(COMMITTED, ledger);
|
||||
txn->setStatus(COMMITTED, ledger, tseq, netID);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -127,7 +127,9 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
setStatus(TransStatus status, std::uint32_t ledgerSeq);
|
||||
setStatus(TransStatus status, std::uint32_t ledgerSeq,
|
||||
std::optional<uint32_t> transactionSeq = std::nullopt, std::optional<uint16_t> networkID = std::nullopt);
|
||||
|
||||
|
||||
void
|
||||
setStatus(TransStatus status)
|
||||
@@ -387,6 +389,9 @@ private:
|
||||
uint256 mTransactionID;
|
||||
|
||||
LedgerIndex mInLedger = 0;
|
||||
std::optional<uint32_t> mTxnSeq;
|
||||
std::optional<uint16_t> mNetworkID;
|
||||
|
||||
TransStatus mStatus = INVALID;
|
||||
TER mResult = temUNCERTAIN;
|
||||
bool mApplying = false;
|
||||
|
||||
@@ -44,12 +44,14 @@ convertBlobsToTxResult(
|
||||
|
||||
auto tr = std::make_shared<Transaction>(txn, reason, app);
|
||||
|
||||
tr->setStatus(Transaction::sqlTransactionStatus(status));
|
||||
tr->setLedger(ledger_index);
|
||||
|
||||
auto metaset =
|
||||
std::make_shared<TxMeta>(tr->getID(), tr->getLedger(), rawMeta);
|
||||
|
||||
uint32_t txnIdx = metaset->getAsObject().getFieldU32(sfTransactionIndex);
|
||||
uint32_t netID = app.config().NETWORK_ID;
|
||||
|
||||
tr->setStatus(Transaction::sqlTransactionStatus(status), ledger_index, txnIdx, netID);
|
||||
|
||||
to.emplace_back(std::move(tr), metaset);
|
||||
};
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <ripple/protocol/ErrorCodes.h>
|
||||
#include <ripple/protocol/Feature.h>
|
||||
#include <ripple/protocol/jss.h>
|
||||
#include <ripple/rpc/CTID.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -59,10 +60,15 @@ Transaction::Transaction(
|
||||
//
|
||||
|
||||
void
|
||||
Transaction::setStatus(TransStatus ts, std::uint32_t lseq)
|
||||
Transaction::setStatus(TransStatus ts, std::uint32_t lseq,
|
||||
std::optional<std::uint32_t> tseq, std::optional<std::uint16_t> netID)
|
||||
{
|
||||
mStatus = ts;
|
||||
mInLedger = lseq;
|
||||
if (tseq)
|
||||
mTxnSeq = tseq;
|
||||
if (netID)
|
||||
mNetworkID = netID;
|
||||
}
|
||||
|
||||
TransStatus
|
||||
@@ -180,6 +186,20 @@ Transaction::getJson(JsonOptions options, bool binary) const
|
||||
if (ct)
|
||||
ret[jss::date] = ct->time_since_epoch().count();
|
||||
}
|
||||
|
||||
// compute outgoing CTID
|
||||
// override local network id if it's explicitly in the txn
|
||||
std::optional netID = mNetworkID;
|
||||
if (mTransaction->isFieldPresent(sfNetworkID))
|
||||
netID = mTransaction->getFieldU32(sfNetworkID);
|
||||
|
||||
if (mTxnSeq && netID && *mTxnSeq <= 0xFFFFU && *netID < 0xFFFFU && mInLedger < 0xFFFFFFFUL)
|
||||
{
|
||||
std::optional<std::string> ctid =
|
||||
RPC::encodeCTID(mInLedger, *mTxnSeq, *netID);
|
||||
if (ctid)
|
||||
ret[jss::ctid] = *ctid;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -334,7 +334,8 @@ saveValidatedLedger(
|
||||
seq, acceptedLedgerTx->getEscMeta()) +
|
||||
";");
|
||||
|
||||
app.getMasterTransaction().inLedger(transactionID, seq);
|
||||
app.getMasterTransaction().inLedger(
|
||||
transactionID, seq, acceptedLedgerTx->getTxnSeq(), app.config().NETWORK_ID);
|
||||
}
|
||||
|
||||
tr.commit();
|
||||
|
||||
@@ -265,6 +265,10 @@ doTxHelp(RPC::Context& context, TxArgs args)
|
||||
result.validated = isValidated(
|
||||
context.ledgerMaster, ledger->info().seq, ledger->info().hash);
|
||||
|
||||
/*
|
||||
// RH NOTE: this is now handled inside the Transaction class
|
||||
// leaving a copy here in case for some reason it's needed again
|
||||
|
||||
// compute outgoing CTID
|
||||
uint32_t lgrSeq = ledger->info().seq;
|
||||
uint32_t txnIdx = meta->getAsObject().getFieldU32(sfTransactionIndex);
|
||||
@@ -272,6 +276,7 @@ doTxHelp(RPC::Context& context, TxArgs args)
|
||||
|
||||
if (txnIdx <= 0xFFFFU && netID < 0xFFFFU && lgrSeq < 0xFFFFFFFUL)
|
||||
result.ctid = RPC::encodeCTID(lgrSeq, (uint16_t)txnIdx, (uint16_t)netID);
|
||||
*/
|
||||
}
|
||||
|
||||
return {result, rpcSUCCESS};
|
||||
|
||||
Reference in New Issue
Block a user