mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-26 22:15:52 +00:00
Save validations in a form they can actually be used.
This commit is contained in:
@@ -55,15 +55,16 @@ const char *LedgerDBInit[] = {
|
|||||||
);",
|
);",
|
||||||
"CREATE INDEX SeqLedger ON Ledgers(LedgerSeq);",
|
"CREATE INDEX SeqLedger ON Ledgers(LedgerSeq);",
|
||||||
|
|
||||||
"CREATE TABLE LedgerValidations ( \
|
"CREATE TABLE Validations ( \
|
||||||
LedgerHash CHARACTER(64), \
|
LedgerHash CHARACTER(64), \
|
||||||
NodePubKey CHARACTER(56), \
|
NodePubKey CHARACTER(56), \
|
||||||
Flags BIGINT UNSIGNED, \
|
|
||||||
SignTime BIGINT UNSIGNED, \
|
SignTime BIGINT UNSIGNED, \
|
||||||
Signature BLOB \
|
RawData BLOB \
|
||||||
);",
|
);",
|
||||||
"CREATE INDEX ValidationByHash ON \
|
"CREATE INDEX ValidationsByHash ON \
|
||||||
LedgerValidations(LedgerHash);",
|
Validations(LedgerHash);",
|
||||||
|
"CREATE INDEX ValidationsByTime ON \
|
||||||
|
Validations(SignTime);",
|
||||||
|
|
||||||
"END TRANSACTION;"
|
"END TRANSACTION;"
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -547,7 +547,7 @@ uint256 Ledger::getHashByIndex(uint32 ledgerIndex)
|
|||||||
{
|
{
|
||||||
uint256 ret;
|
uint256 ret;
|
||||||
|
|
||||||
std::string sql="SELECT LedgerHash FROM Ledgers WHERE LedgerSeq='";
|
std::string sql="SELECT LedgerHash FROM Ledgers INDEXED BY SeqLedger WHERE LedgerSeq='";
|
||||||
sql.append(boost::lexical_cast<std::string>(ledgerIndex));
|
sql.append(boost::lexical_cast<std::string>(ledgerIndex));
|
||||||
sql.append("';");
|
sql.append("';");
|
||||||
|
|
||||||
|
|||||||
@@ -300,8 +300,8 @@ void ValidationCollection::condWrite()
|
|||||||
void ValidationCollection::doWrite()
|
void ValidationCollection::doWrite()
|
||||||
{
|
{
|
||||||
LoadEvent::autoptr event(theApp->getJobQueue().getLoadEventAP(jtDISK));
|
LoadEvent::autoptr event(theApp->getJobQueue().getLoadEventAP(jtDISK));
|
||||||
static boost::format insVal("INSERT INTO LedgerValidations "
|
static boost::format insVal("INSERT INTO Validations "
|
||||||
"(LedgerHash,NodePubKey,Flags,SignTime,Signature) VALUES ('%s','%s','%u','%u',%s);");
|
"(LedgerHash,NodePubKey,SignTime,RawData) VALUES ('%s','%s','%u',%s);");
|
||||||
|
|
||||||
boost::mutex::scoped_lock sl(mValidationLock);
|
boost::mutex::scoped_lock sl(mValidationLock);
|
||||||
assert(mWriting);
|
assert(mWriting);
|
||||||
@@ -314,11 +314,16 @@ void ValidationCollection::doWrite()
|
|||||||
Database *db = theApp->getLedgerDB()->getDB();
|
Database *db = theApp->getLedgerDB()->getDB();
|
||||||
ScopedLock dbl(theApp->getLedgerDB()->getDBLock());
|
ScopedLock dbl(theApp->getLedgerDB()->getDBLock());
|
||||||
|
|
||||||
|
Serializer s(1024);
|
||||||
db->executeSQL("BEGIN TRANSACTION;");
|
db->executeSQL("BEGIN TRANSACTION;");
|
||||||
BOOST_FOREACH(const SerializedValidation::pointer& it, vector)
|
BOOST_FOREACH(const SerializedValidation::pointer& it, vector)
|
||||||
|
{
|
||||||
|
s.erase();
|
||||||
|
it->add(s);
|
||||||
db->executeSQL(boost::str(insVal % it->getLedgerHash().GetHex()
|
db->executeSQL(boost::str(insVal % it->getLedgerHash().GetHex()
|
||||||
% it->getSignerPublic().humanNodePublic() % it->getFlags() % it->getSignTime()
|
% it->getSignerPublic().humanNodePublic() % it->getSignTime()
|
||||||
% sqlEscape(it->getSignature())));
|
% sqlEscape(s.peekData())));
|
||||||
|
}
|
||||||
db->executeSQL("END TRANSACTION;");
|
db->executeSQL("END TRANSACTION;");
|
||||||
}
|
}
|
||||||
sl.lock();
|
sl.lock();
|
||||||
|
|||||||
Reference in New Issue
Block a user