mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-26 14:05:51 +00:00
added sqllite
This commit is contained in:
@@ -1,31 +1,56 @@
|
||||
#include "UniqueNodeList.h"
|
||||
#include "Application.h"
|
||||
using namespace std;
|
||||
|
||||
|
||||
void UniqueNodeList::addNode(uint160& hanko,uint1024& publicKey)
|
||||
void UniqueNodeList::addNode(uint160& hanko, vector<unsigned char>& publicKey)
|
||||
{
|
||||
"INSERT INTO UNL values ("
|
||||
theApp->getDB()->executeSQL(sql);
|
||||
Database* db=theApp->getDB();
|
||||
string sql="INSERT INTO UNL (Hanko,PubKey) values (";
|
||||
string hashStr;
|
||||
db->escape(hanko.begin(),hanko.GetSerializeSize(),hashStr);
|
||||
sql.append(hashStr);
|
||||
sql.append(",");
|
||||
db->escape(&(publicKey[0]),publicKey.size(),hashStr);
|
||||
sql.append(hashStr);
|
||||
sql.append(")");
|
||||
|
||||
db->executeSQL(sql.c_str());
|
||||
}
|
||||
|
||||
void UniqueNodeList::removeNode(uint160& hanko)
|
||||
{
|
||||
"DELETE FROM UNL where hanko="
|
||||
theApp->getDB()->executeSQL(sql);
|
||||
|
||||
Database* db=theApp->getDB();
|
||||
string sql="DELETE FROM UNL where hanko=";
|
||||
string hashStr;
|
||||
db->escape(hanko.begin(),hanko.GetSerializeSize(),hashStr);
|
||||
sql.append(hashStr);
|
||||
db->executeSQL(sql.c_str());
|
||||
}
|
||||
|
||||
// 0- we don't care, 1- we care and is valid, 2-invalid signature
|
||||
int UniqueNodeList::checkValid(newcoin::Validation& valid)
|
||||
{
|
||||
"SELECT pubkey from UNL where hanko="
|
||||
if( theApp->getDB()->executeSQL(sql) )
|
||||
{
|
||||
if(theApp->getDB()->getNextRow())
|
||||
{
|
||||
theApp->getDB()->getBytes();
|
||||
Database* db=theApp->getDB();
|
||||
string sql="SELECT pubkey from UNL where hanko=";
|
||||
string hashStr;
|
||||
db->escape((unsigned char*) &(valid.hanko()[0]),valid.hanko().size(),hashStr);
|
||||
sql.append(hashStr);
|
||||
|
||||
}else return(0); // not on our list
|
||||
if( db->executeSQL(sql.c_str()) )
|
||||
{
|
||||
if(db->startIterRows() && db->getNextRow())
|
||||
{
|
||||
//theApp->getDB()->getBytes();
|
||||
|
||||
// TODO: check that the public key makes the correct signature of the validation
|
||||
db->endIterRows();
|
||||
return(1);
|
||||
}else
|
||||
{
|
||||
db->endIterRows();
|
||||
|
||||
}
|
||||
}
|
||||
return(1);
|
||||
return(0); // not on our list
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user