getting connections working

This commit is contained in:
jed
2012-01-19 12:32:41 -08:00
parent 239e26a56e
commit 92f6ad6d37
9 changed files with 29 additions and 8 deletions

View File

@@ -17,9 +17,10 @@ PackedMessage::PackedMessage(MessagePointer msg, int type)
: mMsg(msg)
{
unsigned msg_size = mMsg->ByteSize();
assert(msg_size);
mBuffer.resize(HEADER_SIZE + msg_size);
encodeHeader(msg_size,type);
mMsg->SerializeToArray(&mBuffer[HEADER_SIZE], msg_size);
if(msg_size) mMsg->SerializeToArray(&mBuffer[HEADER_SIZE], msg_size);
}
bool PackedMessage::operator == (const PackedMessage& other)

View File

@@ -340,6 +340,7 @@ void Peer::sendHello()
{
newcoin::TMHello* h=new newcoin::TMHello();
// set up parameters
h->set_version(theConfig.VERSION);
PackedMessage::pointer packet(new PackedMessage(PackedMessage::MessagePointer(h), newcoin::mtHELLO));
sendPacket(packet);
}

View File

@@ -9,7 +9,7 @@ using namespace boost::asio::ip;
PeerDoor::PeerDoor(boost::asio::io_service& io_service) :
mAcceptor(io_service, tcp::endpoint(tcp::v4(), theConfig.PEER_PORT))
{
cout << "Opening door on port: " << theConfig.PEER_PORT << endl;
cout << "Opening peer door on port: " << theConfig.PEER_PORT << endl;
startListening();
}

View File

@@ -10,7 +10,7 @@ using namespace boost::asio::ip;
RPCDoor::RPCDoor(boost::asio::io_service& io_service) :
mAcceptor(io_service, tcp::endpoint(boost::asio::ip::address_v4::loopback(), theConfig.RPC_PORT))
{
cout << "Opening rpc door on port: " << theConfig.RPC_PORT << endl;
startListening();
}

View File

@@ -1,5 +1,5 @@
<config>
<PEER_PORT>5000</PEER_PORT>
<RPC_PORT>5001</RPC_PORT>
<PEER_PORT>51235</PEER_PORT>
<RPC_PORT>5005</RPC_PORT>
<NUMBER_CONNECTIONS>30</NUMBER_CONNECTIONS>
</config>

View File

@@ -1,6 +1,7 @@
#include "Application.h"
#include <iostream>
#include "CallRPC.h"
#include "Config.h"
extern void runTests();
using namespace std;
@@ -41,6 +42,7 @@ int parseCommandline(int argc, char* argv[])
int ret=0;
if(argc>1)
{
theConfig.load();
ret=commandLineRPC(argc, argv);
if(ret)
printHelp();

View File

@@ -87,6 +87,7 @@
<ClCompile Include="AccountState.cpp" />
<ClCompile Include="Application.cpp" />
<ClCompile Include="BitcoinUtil.cpp" />
<ClCompile Include="CallRPC.cpp" />
<ClCompile Include="Config.cpp" />
<ClCompile Include="ConnectionPool.cpp" />
<ClCompile Include="Conversion.cpp" />
@@ -106,6 +107,7 @@
<ClCompile Include="LedgerHistory.cpp" />
<ClCompile Include="LedgerMaster.cpp" />
<ClCompile Include="LocalTransaction.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="NetworkOPs.cpp" />
<ClCompile Include="newcoin.pb.cc" />
<ClCompile Include="NewcoinAddress.cpp" />
@@ -121,7 +123,6 @@
<ClCompile Include="SHAMap.cpp" />
<ClCompile Include="SHAMapDiff.cpp" />
<ClCompile Include="SHAMapNodes.cpp" />
<ClCompile Include="test.cpp" />
<ClCompile Include="TimingService.cpp" />
<ClCompile Include="Transaction.cpp" />
<ClCompile Include="UniqueNodeList.cpp" />
@@ -200,6 +201,7 @@
<None Include="Makefile" />
<None Include="nodes.xml" />
<None Include="notes.txt" />
<None Include="tests\client2\config.xml" />
<None Include="todo.txt" />
<None Include="unl.xml" />
<None Include="wallet.xml" />

View File

@@ -28,6 +28,15 @@
<Filter Include="Source Files\cryptopp">
<UniqueIdentifier>{c3412b4c-4150-48d7-a5f2-24bdb1a39c5b}</UniqueIdentifier>
</Filter>
<Filter Include="tests">
<UniqueIdentifier>{209ce0bd-b197-4cb2-ad50-f8f43bcd1e03}</UniqueIdentifier>
</Filter>
<Filter Include="tests\client1">
<UniqueIdentifier>{46b84833-f245-4c3d-94b8-472efdb3a040}</UniqueIdentifier>
</Filter>
<Filter Include="tests\client2">
<UniqueIdentifier>{b27b04b8-1c6e-4b20-9364-f18d4682dc00}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Application.cpp">
@@ -156,7 +165,10 @@
<ClCompile Include="DBInit.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="test.cpp">
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="CallRPC.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
@@ -342,6 +354,9 @@
<None Include="db layout.txt" />
<None Include="todo.txt" />
<None Include="Makefile" />
<None Include="tests\client2\config.xml">
<Filter>tests\client2</Filter>
</None>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="newcoin.proto" />

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<config>
<PEER_PORT>5000</PEER_PORT>
<RPC_PORT>5001</RPC_PORT>
<RPC_PORT>5002</RPC_PORT>
<NUMBER_CONNECTIONS>30</NUMBER_CONNECTIONS>
</config>