mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-27 14:35:52 +00:00
Metadata versions of the transaction SQL helper functions.
This commit is contained in:
@@ -183,11 +183,21 @@ std::string SerializedTransaction::getSQLValueHeader()
|
|||||||
return "(TransID, TransType, FromAcct, FromSeq, LedgerSeq, Status, RawTxn)";
|
return "(TransID, TransType, FromAcct, FromSeq, LedgerSeq, Status, RawTxn)";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string SerializedTransaction::getMetaSQLValueHeader()
|
||||||
|
{
|
||||||
|
return "(TransID, TransType, FromAcct, FromSeq, LedgerSeq, Status, RawTxn, TxnMeta)";
|
||||||
|
}
|
||||||
|
|
||||||
std::string SerializedTransaction::getSQLInsertHeader()
|
std::string SerializedTransaction::getSQLInsertHeader()
|
||||||
{
|
{
|
||||||
return "INSERT INTO Transactions " + getSQLValueHeader() + " VALUES ";
|
return "INSERT INTO Transactions " + getSQLValueHeader() + " VALUES ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string SerializedTransaction::getMetaSQLInsertHeader()
|
||||||
|
{
|
||||||
|
return "INSERT INTO Transactions " + getMetaSQLValueHeader() + " VALUES ";
|
||||||
|
}
|
||||||
|
|
||||||
std::string SerializedTransaction::getSQL(uint32 inLedger, char status) const
|
std::string SerializedTransaction::getSQL(uint32 inLedger, char status) const
|
||||||
{
|
{
|
||||||
Serializer s;
|
Serializer s;
|
||||||
@@ -195,16 +205,36 @@ std::string SerializedTransaction::getSQL(uint32 inLedger, char status) const
|
|||||||
return getSQL(s, inLedger, status);
|
return getSQL(s, inLedger, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string SerializedTransaction::getMetaSQL(uint32 inLedger, const std::string& escapedMetaData) const
|
||||||
|
{
|
||||||
|
Serializer s;
|
||||||
|
add(s);
|
||||||
|
return getMetaSQL(s, inLedger, TXN_SQL_VALIDATED, escapedMetaData);
|
||||||
|
}
|
||||||
|
|
||||||
std::string SerializedTransaction::getSQL(Serializer rawTxn, uint32 inLedger, char status) const
|
std::string SerializedTransaction::getSQL(Serializer rawTxn, uint32 inLedger, char status) const
|
||||||
{
|
{
|
||||||
|
static boost::format bfTrans("('%s', '%s', '%s', '%d', '%d', '%c', %s)");
|
||||||
std::string rTxn;
|
std::string rTxn;
|
||||||
theApp->getTxnDB()->getDB()->escape(
|
theApp->getTxnDB()->getDB()->escape(
|
||||||
reinterpret_cast<const unsigned char *>(rawTxn.getDataPtr()), rawTxn.getLength(), rTxn);
|
reinterpret_cast<const unsigned char *>(rawTxn.getDataPtr()), rawTxn.getLength(), rTxn);
|
||||||
return str(boost::format("('%s', '%s', '%s', '%d', '%d', '%c', %s)")
|
return str(bfTrans
|
||||||
% getTransactionID().GetHex() % getTransactionType() % getSourceAccount().humanAccountID()
|
% getTransactionID().GetHex() % getTransactionType() % getSourceAccount().humanAccountID()
|
||||||
% getSequence() % inLedger % status % rTxn);
|
% getSequence() % inLedger % status % rTxn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string SerializedTransaction::getMetaSQL(Serializer rawTxn, uint32 inLedger, char status,
|
||||||
|
const std::string& escapedMetaData) const
|
||||||
|
{
|
||||||
|
static boost::format bfTrans("('%s', '%s', '%s', '%d', '%d', '%c', %s, %s)");
|
||||||
|
std::string rTxn;
|
||||||
|
theApp->getTxnDB()->getDB()->escape(
|
||||||
|
reinterpret_cast<const unsigned char *>(rawTxn.getDataPtr()), rawTxn.getLength(), rTxn);
|
||||||
|
return str(bfTrans
|
||||||
|
% getTransactionID().GetHex() % getTransactionType() % getSourceAccount().humanAccountID()
|
||||||
|
% getSequence() % inLedger % status % rTxn % escapedMetaData);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE(SerializedTransactionTS)
|
BOOST_AUTO_TEST_SUITE(SerializedTransactionTS)
|
||||||
|
|
||||||
|
|||||||
@@ -77,6 +77,12 @@ public:
|
|||||||
std::string getSQL(uint32 inLedger, char status) const;
|
std::string getSQL(uint32 inLedger, char status) const;
|
||||||
std::string getSQL(Serializer rawTxn, uint32 inLedger, char status) const;
|
std::string getSQL(Serializer rawTxn, uint32 inLedger, char status) const;
|
||||||
|
|
||||||
|
// SQL Functions with metadata
|
||||||
|
static std::string getMetaSQLValueHeader();
|
||||||
|
static std::string getMetaSQLInsertHeader();
|
||||||
|
std::string getMetaSQL(uint32 inLedger, const std::string& escapedMetaData) const;
|
||||||
|
std::string getMetaSQL(Serializer rawTxn, uint32 inLedger, char status, const std::string& escapedMetaData) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user