mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 11:05:54 +00:00
.
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
|
#ifndef __APPLICATION__
|
||||||
|
#define __APPLICATION__
|
||||||
|
|
||||||
#include "UniqueNodeList.h"
|
#include "UniqueNodeList.h"
|
||||||
#include "ConnectionPool.h"
|
#include "ConnectionPool.h"
|
||||||
#include "KnownNodeList.h"
|
#include "KnownNodeList.h"
|
||||||
@@ -5,7 +8,6 @@
|
|||||||
#include "TimingService.h"
|
#include "TimingService.h"
|
||||||
#include "ValidationCollection.h"
|
#include "ValidationCollection.h"
|
||||||
#include "Wallet.h"
|
#include "Wallet.h"
|
||||||
#include "Serializer.h"
|
|
||||||
#include "database/database.h"
|
#include "database/database.h"
|
||||||
|
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
@@ -28,7 +30,7 @@ class Application
|
|||||||
ConnectionPool mConnectionPool;
|
ConnectionPool mConnectionPool;
|
||||||
PeerDoor* mPeerDoor;
|
PeerDoor* mPeerDoor;
|
||||||
RPCDoor* mRPCDoor;
|
RPCDoor* mRPCDoor;
|
||||||
Serializer* mSerializer;
|
//Serializer* mSerializer;
|
||||||
|
|
||||||
boost::asio::io_service mIOService;
|
boost::asio::io_service mIOService;
|
||||||
|
|
||||||
@@ -46,8 +48,8 @@ public:
|
|||||||
|
|
||||||
void setDB(Database* db){ mDatabase=db; }
|
void setDB(Database* db){ mDatabase=db; }
|
||||||
|
|
||||||
Serializer* getSerializer(){ return(mSerializer); }
|
//Serializer* getSerializer(){ return(mSerializer); }
|
||||||
void setSerializer(Serializer* ser){ mSerializer=ser; }
|
//void setSerializer(Serializer* ser){ mSerializer=ser; }
|
||||||
|
|
||||||
|
|
||||||
void run();
|
void run();
|
||||||
@@ -56,3 +58,5 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern Application* theApp;
|
extern Application* theApp;
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,3 +1,6 @@
|
|||||||
|
#ifndef __CONNECTION_POOL__
|
||||||
|
#define __CONNECTION_POOL__
|
||||||
|
|
||||||
#include "Peer.h"
|
#include "Peer.h"
|
||||||
#include "PackedMessage.h"
|
#include "PackedMessage.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
@@ -20,3 +23,5 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -28,12 +28,14 @@ bool LedgerHistory::loadLedger(uint256& hash)
|
|||||||
|
|
||||||
bool LedgerHistory::loadAcceptedLedger(uint32 index)
|
bool LedgerHistory::loadAcceptedLedger(uint32 index)
|
||||||
{
|
{
|
||||||
|
// TODO: LedgerHistory::loadAcceptedLedger(uint32 index)
|
||||||
|
/*
|
||||||
Ledger::pointer ledger=theApp->getSerializer()->loadAcceptedLedger(index);
|
Ledger::pointer ledger=theApp->getSerializer()->loadAcceptedLedger(index);
|
||||||
if(ledger)
|
if(ledger)
|
||||||
{
|
{
|
||||||
mAcceptedLedgers[index]=ledger;
|
mAcceptedLedgers[index]=ledger;
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}*/
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
7
Peer.cpp
7
Peer.cpp
@@ -291,10 +291,11 @@ void Peer::receiveValidation(newcoin::Validation& validation)
|
|||||||
|
|
||||||
void Peer::receiveGetValidations(newcoin::GetValidations& request)
|
void Peer::receiveGetValidations(newcoin::GetValidations& request)
|
||||||
{
|
{
|
||||||
vector<newcoin::Validation>* validations=theApp->getValidationCollection().getValidations(request.ledgerindex());
|
vector<newcoin::Validation> validations;
|
||||||
if(validations)
|
theApp->getValidationCollection().getValidations(request.ledgerindex(),validations);
|
||||||
|
if(validations.size())
|
||||||
{
|
{
|
||||||
BOOST_FOREACH(newcoin::Validation& valid, *validations)
|
BOOST_FOREACH(newcoin::Validation& valid, validations)
|
||||||
{
|
{
|
||||||
PackedMessage::pointer packet(new PackedMessage(PackedMessage::MessagePointer(new newcoin::Validation(valid)),newcoin::VALIDATION));
|
PackedMessage::pointer packet(new PackedMessage(PackedMessage::MessagePointer(new newcoin::Validation(valid)),newcoin::VALIDATION));
|
||||||
sendPacket(packet);
|
sendPacket(packet);
|
||||||
|
|||||||
@@ -28,29 +28,45 @@ void ValidationCollection::load()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ValidationCollection::addToDB(newcoin::Validation& valid,bool weCare)
|
void ValidationCollection::addToDB(newcoin::Validation& valid,int weCare)
|
||||||
{
|
{
|
||||||
Database* db=theApp->getDB();
|
Database* db=theApp->getDB();
|
||||||
|
uint256 hash=protobufTo256(valid.hash());
|
||||||
|
uint160 hanko=protobufTo160(valid.hanko());
|
||||||
|
uint256 sig=protobufTo256(valid.sig());
|
||||||
|
|
||||||
|
string hashStr,hankoStr,sigStr;
|
||||||
|
db->escape(hash.begin(),hash.GetSerializeSize(),hashStr);
|
||||||
|
db->escape(hanko.begin(),hanko.GetSerializeSize(),hankoStr);
|
||||||
|
db->escape(sig.begin(),sig.GetSerializeSize(),sigStr);
|
||||||
|
string sql=strprintf("INSERT INTO Validations (LedgerIndex,Hash,Hanko,SeqNum,Sig,WeCare) values (%d,%s,%s,%d,%s,%d)",valid.ledgerindex(),hashStr.c_str(),hankoStr.c_str(),valid.seqnum(),sigStr.c_str(),weCare);
|
||||||
|
db->executeSQL(sql.c_str());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ValidationCollection::hasValidation(uint256& ledgerHash,uint160& hanko,uint32 seqnum)
|
bool ValidationCollection::hasValidation(uint32 ledgerIndex,uint160& hanko,uint32 seqnum)
|
||||||
{
|
{
|
||||||
if(mValidations.count(ledgerHash))
|
string hankoStr;
|
||||||
|
Database* db=theApp->getDB();
|
||||||
|
db->escape(hanko.begin(),hanko.GetSerializeSize(),hankoStr);
|
||||||
|
string sql=strprintf("SELECT ValidationID,seqnum from Validations where LedgerIndex=%d and hanko=%s",ledgerIndex,hankoStr);
|
||||||
|
if(db->executeSQL(sql.c_str()))
|
||||||
{
|
{
|
||||||
BOOST_FOREACH(newcoin::Validation& valid,mValidations[ledgerHash])
|
if(db->startIterRows())
|
||||||
{
|
{
|
||||||
if( valid.seqnum()==seqnum &&
|
if(db->getNextRow())
|
||||||
protobufTo160(valid.hanko()) == hanko) return(true);
|
{
|
||||||
|
uint32 currentSeqNum=db->getInt(1);
|
||||||
|
if(currentSeqNum>=seqnum)
|
||||||
|
{
|
||||||
|
db->endIterRows();
|
||||||
|
return(true);
|
||||||
}
|
}
|
||||||
|
// delete the old validation we were storing
|
||||||
|
sql=strprintf("DELETE FROM Validations where ValidationID=%d",db->getInt(0));
|
||||||
|
db->endIterRows();
|
||||||
|
db->executeSQL(sql.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mIgnoredValidations.count(ledgerHash))
|
|
||||||
{
|
|
||||||
BOOST_FOREACH(newcoin::Validation& valid,mIgnoredValidations[ledgerHash])
|
|
||||||
{
|
|
||||||
if( valid.seqnum()==seqnum &&
|
|
||||||
protobufTo160(valid.hanko()) == hanko) return(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return(false);
|
return(false);
|
||||||
@@ -67,20 +83,17 @@ void ValidationCollection::addValidation(newcoin::Validation& valid)
|
|||||||
uint160 hanko=protobufTo160(valid.hanko());
|
uint160 hanko=protobufTo160(valid.hanko());
|
||||||
|
|
||||||
// make sure we don't already have this validation
|
// make sure we don't already have this validation
|
||||||
if(hasValidation(hash,hanko,valid.seqnum())) return;
|
if(hasValidation(valid.ledgerindex(),hanko,valid.seqnum())) return;
|
||||||
|
|
||||||
// check if we care about this hanko
|
// check if we care about this hanko
|
||||||
int validity=theApp->getUNL().checkValid(valid);
|
int validity=theApp->getUNL().checkValid(valid);
|
||||||
if( validity==1 )
|
if( validity==1 )
|
||||||
{
|
{
|
||||||
mValidations[hash].push_back(valid);
|
|
||||||
mIndexValidations[valid.ledgerindex()].push_back(valid);
|
|
||||||
addToGroup(valid);
|
|
||||||
addToDB(valid,true);
|
addToDB(valid,true);
|
||||||
|
addToGroup(valid);
|
||||||
theApp->getLedgerMaster().checkConsensus(valid.ledgerindex());
|
theApp->getLedgerMaster().checkConsensus(valid.ledgerindex());
|
||||||
}else if(validity==0)
|
}else if(validity==0)
|
||||||
{
|
{
|
||||||
mIgnoredValidations[hash].push_back(valid);
|
|
||||||
addToDB(valid,false);
|
addToDB(valid,false);
|
||||||
}else
|
}else
|
||||||
{ // the signature wasn't valid
|
{ // the signature wasn't valid
|
||||||
@@ -147,7 +160,11 @@ void ValidationCollection::addToGroup(newcoin::Validation& newValid)
|
|||||||
newGroup.mValidations.push_back(newValid);
|
newGroup.mValidations.push_back(newValid);
|
||||||
newGroup.mSuperLedger=Ledger::pointer(new Ledger(newLedger)); // since this super ledger gets modified and we don't want to screw the original
|
newGroup.mSuperLedger=Ledger::pointer(new Ledger(newLedger)); // since this super ledger gets modified and we don't want to screw the original
|
||||||
|
|
||||||
BOOST_FOREACH(newcoin::Validation& valid,mIndexValidations[newValid.ledgerindex()])
|
vector<newcoin::Validation> retVec;
|
||||||
|
getValidations(newValid.ledgerindex(),retVec);
|
||||||
|
|
||||||
|
|
||||||
|
BOOST_FOREACH(newcoin::Validation& valid,retVec)
|
||||||
{
|
{
|
||||||
uint256 hash=protobufTo256(valid.hash());
|
uint256 hash=protobufTo256(valid.hash());
|
||||||
Ledger::pointer ledger=theApp->getLedgerMaster().getLedger(hash);
|
Ledger::pointer ledger=theApp->getLedgerMaster().getLedger(hash);
|
||||||
@@ -169,13 +186,12 @@ void ValidationCollection::addToGroup(newcoin::Validation& newValid)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<newcoin::Validation>* ValidationCollection::getValidations(uint32 ledgerIndex)
|
void ValidationCollection::getValidations(uint32 ledgerIndex,vector<newcoin::Validation>& retVec)
|
||||||
{
|
{
|
||||||
if(mIndexValidations.count(ledgerIndex))
|
string sql=strprintf("SELECT * From Validations where LedgerIndex=%d and wecare=1",ledgerIndex);
|
||||||
{
|
|
||||||
return(&(mIndexValidations[ledgerIndex]));
|
// TODO: ValidationCollection::getValidations(uint32 ledgerIndex)
|
||||||
}
|
|
||||||
return(NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -29,9 +29,9 @@ class ValidationCollection
|
|||||||
std::map<uint32, std::vector< Group > > mIndexGroups; // all the groups at each index
|
std::map<uint32, std::vector< Group > > mIndexGroups; // all the groups at each index
|
||||||
//std::map<uint32, std::vector< newcoin::Validation > > mIndexValidations; // all the validations at each index
|
//std::map<uint32, std::vector< newcoin::Validation > > mIndexValidations; // all the validations at each index
|
||||||
|
|
||||||
bool hasValidation(uint256& ledgerHash,uint160& hanko,uint32 seqnum);
|
bool hasValidation(uint32 ledgerIndex,uint160& hanko,uint32 seqnum);
|
||||||
void addToGroup(newcoin::Validation& valid);
|
void addToGroup(newcoin::Validation& valid);
|
||||||
void addToDB(newcoin::Validation& valid,bool weCare);
|
void addToDB(newcoin::Validation& valid,int weCare);
|
||||||
public:
|
public:
|
||||||
ValidationCollection();
|
ValidationCollection();
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ public:
|
|||||||
|
|
||||||
void addValidation(newcoin::Validation& valid);
|
void addValidation(newcoin::Validation& valid);
|
||||||
|
|
||||||
std::vector<newcoin::Validation>* getValidations(uint32 ledgerIndex);
|
void getValidations(uint32 ledgerIndex,std::vector<newcoin::Validation>& retVec);
|
||||||
|
|
||||||
|
|
||||||
// It can miss some compatible ledgers of course if you don't know them
|
// It can miss some compatible ledgers of course if you don't know them
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
CREATE TABLE UNL (Hanko BLOB PRIMARY KEY, PubKey BLOB);
|
CREATE TABLE UNL (Hanko BLOB PRIMARY KEY, PubKey BLOB);
|
||||||
CREATE TABLE Transactions (TransactionID INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, From BLOB, Dest BLOB, Amount BIGINT UNSIGNED, LedgerIndex INT UNSIGNED, SeqNum INT, PubKey BLOB, Sig BLOB);
|
CREATE TABLE Transactions (TransactionID INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, From BLOB, Dest BLOB, Amount BIGINT UNSIGNED, LedgerIndex INT UNSIGNED, SeqNum INT, PubKey BLOB, Sig BLOB);
|
||||||
CREATE TABLE Ledgers (LedgerID INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, LedgerIndex INT UNSIGNED, Hash BLOB, ParentHash BLOB,FeeHeld BIGINT UNSIGNED);
|
CREATE TABLE Ledgers (LedgerID INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, LedgerIndex INT UNSIGNED, Hash BLOB, ParentHash BLOB,FeeHeld BIGINT UNSIGNED);
|
||||||
CREATE TABLE Validations(LedgerIndex INT UNSIGNED, Hash BLOB, Hanko BLOB, SeqNum INT UNSIGNED, Sig BLOB, WeCare TINYINT);
|
CREATE TABLE Validations(ValidationID INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, LedgerIndex INT UNSIGNED, Hash BLOB, Hanko BLOB, SeqNum INT UNSIGNED, Sig BLOB, WeCare TINYINT);
|
||||||
CREATE TABLE LedgerTransactionMap (LedgerID INT UNSIGNED, TransactionID INT UNSIGNED, Include TINYINT);
|
CREATE TABLE LedgerTransactionMap (LedgerID INT UNSIGNED, TransactionID INT UNSIGNED, Include TINYINT);
|
||||||
CREATE TABLE LedgerAccountMap(LedgerID INT UNSIGNED,AccountID INT UNSIGNED);
|
CREATE TABLE LedgerAccountMap(LedgerID INT UNSIGNED,AccountID INT UNSIGNED);
|
||||||
CREATE TABLE Accounts (AccountID INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, Address BLOB, Amount BIGINT UNSIGNED, SeqNum INT);
|
CREATE TABLE Accounts (AccountID INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, Address BLOB, Amount BIGINT UNSIGNED, SeqNum INT);
|
||||||
|
|||||||
@@ -95,7 +95,6 @@
|
|||||||
<ClCompile Include="database\database.cpp" />
|
<ClCompile Include="database\database.cpp" />
|
||||||
<ClCompile Include="database\sqlite3.c" />
|
<ClCompile Include="database\sqlite3.c" />
|
||||||
<ClCompile Include="database\SqliteDatabase.cpp" />
|
<ClCompile Include="database\SqliteDatabase.cpp" />
|
||||||
<ClCompile Include="DiskSerializer.cpp" />
|
|
||||||
<ClCompile Include="HttpReply.cpp" />
|
<ClCompile Include="HttpReply.cpp" />
|
||||||
<ClCompile Include="json\json_spirit_reader.cpp" />
|
<ClCompile Include="json\json_spirit_reader.cpp" />
|
||||||
<ClCompile Include="json\json_spirit_value.cpp" />
|
<ClCompile Include="json\json_spirit_value.cpp" />
|
||||||
@@ -105,7 +104,6 @@
|
|||||||
<ClCompile Include="Ledger.cpp" />
|
<ClCompile Include="Ledger.cpp" />
|
||||||
<ClCompile Include="LedgerHistory.cpp" />
|
<ClCompile Include="LedgerHistory.cpp" />
|
||||||
<ClCompile Include="LedgerMaster.cpp" />
|
<ClCompile Include="LedgerMaster.cpp" />
|
||||||
<ClCompile Include="MySqlSerializer.cpp" />
|
|
||||||
<ClCompile Include="newcoin.pb.cc" />
|
<ClCompile Include="newcoin.pb.cc" />
|
||||||
<ClCompile Include="NewcoinAddress.cpp" />
|
<ClCompile Include="NewcoinAddress.cpp" />
|
||||||
<ClCompile Include="PackedMessage.cpp" />
|
<ClCompile Include="PackedMessage.cpp" />
|
||||||
|
|||||||
@@ -132,12 +132,6 @@
|
|||||||
<ClCompile Include="Transaction.cpp">
|
<ClCompile Include="Transaction.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="MySqlSerializer.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="DiskSerializer.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="database\database.cpp">
|
<ClCompile Include="database\database.cpp">
|
||||||
<Filter>Header Files\util</Filter>
|
<Filter>Header Files\util</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|||||||
Reference in New Issue
Block a user