mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Merge branch 'master' of github.com:jedmccaleb/NewCoin
This commit is contained in:
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
[submodule "websocketpp"]
|
||||
path = websocketpp
|
||||
url = https://github.com/zaphoyd/websocketpp.git
|
||||
23
SConstruct
23
SConstruct
@@ -24,7 +24,7 @@ env.Replace(CTAGS = CTAGS, CTAGSOPTIONS = '--tag-relative')
|
||||
#
|
||||
# Put objects files in their own directory.
|
||||
#
|
||||
for dir in ['src', 'database', 'json', 'util']:
|
||||
for dir in ['src', 'database', 'json', 'websocketpp']:
|
||||
VariantDir('obj/'+dir, dir, duplicate=0)
|
||||
|
||||
# Use openssl
|
||||
@@ -49,10 +49,21 @@ env.Append(LINKFLAGS = ['-rdynamic', '-pthread'])
|
||||
env.Append(CCFLAGS = ['-pthread', '-Wall', '-Wno-sign-compare', '-Wno-char-subscripts', '-DSQLITE_THREADSAFE'])
|
||||
env.Append(CXXFLAGS = ['-O0', '-pthread', '-Wno-invalid-offsetof', '-Wformat']+BOOSTFLAGS+DEBUGFLAGS)
|
||||
|
||||
DB_SRCS = glob.glob('database/*.c') + glob.glob('database/*.cpp')
|
||||
JSON_SRCS = glob.glob('json/*.cpp')
|
||||
NEWCOIN_SRCS = glob.glob('src/*.cpp')
|
||||
PROTO_SRCS = env.Protoc([], 'src/newcoin.proto', PROTOCOUTDIR='obj', PROTOCPYTHONOUTDIR=None)
|
||||
DB_SRCS = glob.glob('database/*.c') + glob.glob('database/*.cpp')
|
||||
JSON_SRCS = glob.glob('json/*.cpp')
|
||||
WEBSOCKETPP_SRCS = [
|
||||
'websocketpp/src/base64/base64.cpp',
|
||||
'websocketpp/src/md5/md5.c',
|
||||
'websocketpp/src/messages/data.cpp',
|
||||
'websocketpp/src/network_utilities.cpp',
|
||||
'websocketpp/src/processors/hybi_header.cpp',
|
||||
'websocketpp/src/processors/hybi_util.cpp',
|
||||
'websocketpp/src/sha1/sha1.cpp',
|
||||
'websocketpp/src/uri.cpp'
|
||||
]
|
||||
|
||||
NEWCOIN_SRCS = glob.glob('src/*.cpp')
|
||||
PROTO_SRCS = env.Protoc([], 'src/newcoin.proto', PROTOCOUTDIR='obj', PROTOCPYTHONOUTDIR=None)
|
||||
|
||||
env.Clean(PROTO_SRCS, 'site_scons/site_tools/protoc.pyc')
|
||||
|
||||
@@ -62,7 +73,7 @@ UNUSED_SRCS = ['src/HttpReply.cpp', 'src/ValidationCollection.cpp']
|
||||
for file in UNUSED_SRCS:
|
||||
NEWCOIN_SRCS.remove(file)
|
||||
|
||||
NEWCOIN_SRCS += DB_SRCS + JSON_SRCS
|
||||
NEWCOIN_SRCS += DB_SRCS + JSON_SRCS + WEBSOCKETPP_SRCS
|
||||
|
||||
# Derive the object files from the source files.
|
||||
NEWCOIN_OBJS = []
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
//#include <boost/log/trivial.hpp>
|
||||
|
||||
#include "../database/SqliteDatabase.h"
|
||||
|
||||
#include "Application.h"
|
||||
|
||||
@@ -66,18 +66,22 @@ bool ConnectionPool::savePeer(const std::string& strIp, int iPort,char code)
|
||||
Database* db = theApp->getWalletDB()->getDB();
|
||||
|
||||
std::string ipPort=db->escape(str(boost::format("%s %d") % strIp % iPort));
|
||||
|
||||
|
||||
ScopedLock sl(theApp->getWalletDB()->getDBLock());
|
||||
std::string sql=str(boost::format("SELECT count(*) FROM PeerIps WHERE IpPort=%s;") % ipPort);
|
||||
if(db->executeSQL(sql) && db->startIterRows())
|
||||
if (db->executeSQL(sql) && db->startIterRows())
|
||||
{
|
||||
if( db->getInt(0)==0)
|
||||
if ( db->getInt(0)==0)
|
||||
{
|
||||
db->executeSQL(str(boost::format("INSERT INTO PeerIps (IpPort,Score,Source) values (%s,0,'%c');") % ipPort % code));
|
||||
return true;
|
||||
}// else we already had this peer
|
||||
}else std::cout << "Error saving Peer" << std::endl;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Error saving Peer" << std::endl;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -86,15 +90,19 @@ bool ConnectionPool::peerAvailable(std::string& strIp, int& iPort)
|
||||
Database* db = theApp->getWalletDB()->getDB();
|
||||
std::vector<std::string> vstrIpPort;
|
||||
|
||||
vstrIpPort.reserve(mIpMap.size());
|
||||
|
||||
pipPeer ipPeer;
|
||||
BOOST_FOREACH(ipPeer, mIpMap)
|
||||
{
|
||||
std::string& strIp = ipPeer.first.first;
|
||||
int iPort = ipPeer.first.second;
|
||||
boost::mutex::scoped_lock sl(mPeerLock);
|
||||
pipPeer ipPeer;
|
||||
|
||||
vstrIpPort.push_back(db->escape(str(boost::format("%s %d") % strIp % iPort)));
|
||||
vstrIpPort.reserve(mIpMap.size());
|
||||
|
||||
BOOST_FOREACH(ipPeer, mIpMap)
|
||||
{
|
||||
std::string& strIp = ipPeer.first.first;
|
||||
int iPort = ipPeer.first.second;
|
||||
|
||||
vstrIpPort.push_back(db->escape(str(boost::format("%s %d") % strIp % iPort)));
|
||||
}
|
||||
}
|
||||
|
||||
std::string strIpPort;
|
||||
@@ -158,6 +166,8 @@ void ConnectionPool::policyEnforce()
|
||||
// XXX Broken: also don't send a message to a peer if we got it from the peer.
|
||||
void ConnectionPool::relayMessage(Peer* fromPeer, PackedMessage::pointer msg)
|
||||
{
|
||||
boost::mutex::scoped_lock sl(mPeerLock);
|
||||
|
||||
BOOST_FOREACH(naPeer pair, mConnectedMap)
|
||||
{
|
||||
Peer::pointer peer = pair.second;
|
||||
@@ -244,6 +254,8 @@ Json::Value ConnectionPool::getPeersJson()
|
||||
{
|
||||
Json::Value ret(Json::arrayValue);
|
||||
|
||||
boost::mutex::scoped_lock sl(mPeerLock);
|
||||
|
||||
BOOST_FOREACH(naPeer pair, mConnectedMap)
|
||||
{
|
||||
Peer::pointer peer = pair.second;
|
||||
@@ -258,6 +270,9 @@ Json::Value ConnectionPool::getPeersJson()
|
||||
std::vector<Peer::pointer> ConnectionPool::getPeerVector()
|
||||
{
|
||||
std::vector<Peer::pointer> ret;
|
||||
|
||||
boost::mutex::scoped_lock sl(mPeerLock);
|
||||
|
||||
ret.reserve(mConnectedMap.size());
|
||||
|
||||
BOOST_FOREACH(naPeer pair, mConnectedMap)
|
||||
@@ -283,6 +298,8 @@ bool ConnectionPool::peerConnected(Peer::pointer peer, const NewcoinAddress& na)
|
||||
}
|
||||
else
|
||||
{
|
||||
boost::mutex::scoped_lock sl(mPeerLock);
|
||||
|
||||
mConnectedMap[na] = peer;
|
||||
bSuccess = true;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <boost/ref.hpp>
|
||||
//#include <boost/log/trivial.hpp>
|
||||
|
||||
#include "../json/writer.h"
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/mem_fn.hpp>
|
||||
//#include <boost/log/trivial.hpp>
|
||||
|
||||
#include "Application.h"
|
||||
#include "Config.h"
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include "Application.h"
|
||||
#include "Config.h"
|
||||
#include <boost/bind.hpp>
|
||||
//#include <boost/log/trivial.hpp>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
1
websocketpp
Submodule
1
websocketpp
Submodule
Submodule websocketpp added at f78b9df4ad
Reference in New Issue
Block a user