mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-21 03:26:01 +00:00
Tiny fixes.
This commit is contained in:
@@ -30,6 +30,7 @@ Application::Application()
|
|||||||
mWallet.load();
|
mWallet.load();
|
||||||
mPeerDoor=NULL;
|
mPeerDoor=NULL;
|
||||||
mRPCDoor=NULL;
|
mRPCDoor=NULL;
|
||||||
|
mDatabase=NULL;
|
||||||
|
|
||||||
CKey::pointer account_key(new CKey(CKey::GetBaseFromString("This is my payphrase."), 0, false));
|
CKey::pointer account_key(new CKey(CKey::GetBaseFromString("This is my payphrase."), 0, false));
|
||||||
|
|
||||||
|
|||||||
113
Peer.cpp
113
Peer.cpp
@@ -28,7 +28,7 @@ void Peer::handle_write(const boost::system::error_code& error , size_t bytes_tr
|
|||||||
cout << "Peer::handle_write Error: " << error << " bytes: "<< bytes_transferred << endl;
|
cout << "Peer::handle_write Error: " << error << " bytes: "<< bytes_transferred << endl;
|
||||||
|
|
||||||
mSendingPacket=PackedMessage::pointer();
|
mSendingPacket=PackedMessage::pointer();
|
||||||
if(mSendQ.size())
|
if(!mSendQ.empty())
|
||||||
{
|
{
|
||||||
PackedMessage::pointer packet=mSendQ.front();
|
PackedMessage::pointer packet=mSendQ.front();
|
||||||
|
|
||||||
@@ -126,7 +126,7 @@ void Peer::processReadBuffer()
|
|||||||
int type=PackedMessage::getType(mReadbuf);
|
int type=PackedMessage::getType(mReadbuf);
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
case newcoin::HELLO:
|
case newcoin::mtHELLO:
|
||||||
{
|
{
|
||||||
newcoin::TMHello msg;
|
newcoin::TMHello msg;
|
||||||
if(msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
|
if(msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
|
||||||
@@ -135,7 +135,7 @@ void Peer::processReadBuffer()
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case newcoin::ERROR_MSG:
|
case newcoin::mtERROR_MSG:
|
||||||
{
|
{
|
||||||
newcoin::TMErrorMsg msg;
|
newcoin::TMErrorMsg msg;
|
||||||
if(msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
|
if(msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
|
||||||
@@ -143,7 +143,7 @@ void Peer::processReadBuffer()
|
|||||||
else cout << "pars error: " << type << endl;
|
else cout << "pars error: " << type << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
case newcoin::PING:
|
case newcoin::mtPING:
|
||||||
{
|
{
|
||||||
newcoin::TMPing msg;
|
newcoin::TMPing msg;
|
||||||
if(msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
|
if(msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
|
||||||
@@ -151,7 +151,7 @@ void Peer::processReadBuffer()
|
|||||||
else cout << "pars error: " << type << endl;
|
else cout << "pars error: " << type << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
case newcoin::GET_CONTACTS:
|
case newcoin::mtGET_CONTACTS:
|
||||||
{
|
{
|
||||||
newcoin::TMGetContacts msg;
|
newcoin::TMGetContacts msg;
|
||||||
if(msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
|
if(msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
|
||||||
@@ -159,7 +159,7 @@ void Peer::processReadBuffer()
|
|||||||
else cout << "pars error: " << type << endl;
|
else cout << "pars error: " << type << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
case newcoin::CONTACT:
|
case newcoin::mtCONTACT:
|
||||||
{
|
{
|
||||||
newcoin::TMContact msg;
|
newcoin::TMContact msg;
|
||||||
if(msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
|
if(msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
|
||||||
@@ -167,7 +167,7 @@ void Peer::processReadBuffer()
|
|||||||
else cout << "pars error: " << type << endl;
|
else cout << "pars error: " << type << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
case newcoin::SEARCH_TRANSACTION:
|
case newcoin::mtSEARCH_TRANSACTION:
|
||||||
{
|
{
|
||||||
newcoin::TMSearchTransaction msg;
|
newcoin::TMSearchTransaction msg;
|
||||||
if(msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
|
if(msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
|
||||||
@@ -175,7 +175,7 @@ void Peer::processReadBuffer()
|
|||||||
else cout << "pars error: " << type << endl;
|
else cout << "pars error: " << type << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
case newcoin::GET_ACCOUNT:
|
case newcoin::mtGET_ACCOUNT:
|
||||||
{
|
{
|
||||||
newcoin::TMGetAccount msg;
|
newcoin::TMGetAccount msg;
|
||||||
if(msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
|
if(msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
|
||||||
@@ -183,7 +183,7 @@ void Peer::processReadBuffer()
|
|||||||
else cout << "pars error: " << type << endl;
|
else cout << "pars error: " << type << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
case newcoin::ACCOUNT:
|
case newcoin::mtACCOUNT:
|
||||||
{
|
{
|
||||||
newcoin::TMAccount msg;
|
newcoin::TMAccount msg;
|
||||||
if(msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
|
if(msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
|
||||||
@@ -191,7 +191,7 @@ void Peer::processReadBuffer()
|
|||||||
else cout << "pars error: " << type << endl;
|
else cout << "pars error: " << type << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
case newcoin::TRANSACTION:
|
case newcoin::mtTRANSACTION:
|
||||||
{
|
{
|
||||||
newcoin::TMTransaction msg;
|
newcoin::TMTransaction msg;
|
||||||
if(msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
|
if(msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
|
||||||
@@ -199,7 +199,7 @@ void Peer::processReadBuffer()
|
|||||||
else cout << "pars error: " << type << endl;
|
else cout << "pars error: " << type << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
case newcoin::GET_LEDGER:
|
case newcoin::mtGET_LEDGER:
|
||||||
{
|
{
|
||||||
newcoin::TMGetLedger msg;
|
newcoin::TMGetLedger msg;
|
||||||
if(msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
|
if(msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
|
||||||
@@ -207,7 +207,7 @@ void Peer::processReadBuffer()
|
|||||||
else cout << "pars error: " << type << endl;
|
else cout << "pars error: " << type << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
case newcoin::LEDGER:
|
case newcoin::mtLEDGER:
|
||||||
{
|
{
|
||||||
newcoin::TMLedger msg;
|
newcoin::TMLedger msg;
|
||||||
if(msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
|
if(msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
|
||||||
@@ -216,7 +216,7 @@ void Peer::processReadBuffer()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
case newcoin::PROPOSE_LEDGER:
|
case newcoin::mtPROPOSE_LEDGER:
|
||||||
{
|
{
|
||||||
newcoin::TM msg;
|
newcoin::TM msg;
|
||||||
if(msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
|
if(msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
|
||||||
@@ -224,7 +224,7 @@ void Peer::processReadBuffer()
|
|||||||
else cout << "pars error: " << type << endl;
|
else cout << "pars error: " << type << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
case newcoin::CLOSE_LEDGER:
|
case newcoin::mtCLOSE_LEDGER:
|
||||||
{
|
{
|
||||||
newcoin::TM msg;
|
newcoin::TM msg;
|
||||||
if(msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
|
if(msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
|
||||||
@@ -232,7 +232,7 @@ void Peer::processReadBuffer()
|
|||||||
else cout << "pars error: " << type << endl;
|
else cout << "pars error: " << type << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
case newcoin::GET_VALIDATION:
|
case newcoin::mtGET_VALIDATION:
|
||||||
{
|
{
|
||||||
newcoin::TM msg;
|
newcoin::TM msg;
|
||||||
if(msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
|
if(msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
|
||||||
@@ -240,7 +240,7 @@ void Peer::processReadBuffer()
|
|||||||
else cout << "pars error: " << type << endl;
|
else cout << "pars error: " << type << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
case newcoin::VALIDATION:
|
case newcoin::mtVALIDATION:
|
||||||
{
|
{
|
||||||
newcoin::TM msg;
|
newcoin::TM msg;
|
||||||
if(msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
|
if(msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
|
||||||
@@ -250,7 +250,7 @@ void Peer::processReadBuffer()
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case newcoin::GET_OBJECT:
|
case newcoin::mtGET_OBJECT:
|
||||||
{
|
{
|
||||||
newcoin::TMGetObjectByHash msg;
|
newcoin::TMGetObjectByHash msg;
|
||||||
if(msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
|
if(msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
|
||||||
@@ -258,7 +258,7 @@ void Peer::processReadBuffer()
|
|||||||
else cout << "pars error: " << type << endl;
|
else cout << "pars error: " << type << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
case newcoin::OBJECT:
|
case newcoin::mtOBJECT:
|
||||||
{
|
{
|
||||||
newcoin::TMObjectByHash msg;
|
newcoin::TMObjectByHash msg;
|
||||||
if(msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
|
if(msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
|
||||||
@@ -272,6 +272,78 @@ void Peer::processReadBuffer()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Peer::recvHello(newcoin::TMHello& packet)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Peer::recvTransaction(newcoin::TMTransaction& packet)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Peer::recvValidation(newcoin::TMValidation& packet)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Peer::recvGetValidation(newcoin::TMGetValidations& packet)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Peer::recvContact(newcoin::TMContact& packet)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Peer::recvGetContacts(newcoin::TMGetContacts& packet)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Peer::recvIndexedObject(newcoin::TMIndexedObject& packet)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Peer::recvGetObjectByHash(newcoin::TMGetObjectByHash& packet)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Peer::recvObjectByHash(newcoin::TMObjectByHash& packet)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Peer::recvPing(newcoin::TMPing& packet)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Peer::recvErrorMessage(newcoin::TMErrorMsg& packet)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Peer::recvSearchTransaction(newcoin::TMSearchTransaction& packet)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Peer::recvGetAccount(newcoin::TMGetAccount& packet)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Peer::recvAccount(newcoin::TMAccount& packet)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Peer::recvGetLedger(newcoin::TMGetLedger& packet)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Peer::recvLedger(newcoin::TMLedger& packet)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Peer::sendHello()
|
||||||
|
{
|
||||||
|
newcoin::TMHello* h=new newcoin::TMHello();
|
||||||
|
// set up parameters
|
||||||
|
PackedMessage::pointer packet(new PackedMessage(PackedMessage::MessagePointer(h), newcoin::mtHELLO));
|
||||||
|
sendPacket(packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
||||||
@@ -282,7 +354,7 @@ void Peer::sendHello()
|
|||||||
hello->set_port(theConfig.PEER_PORT);
|
hello->set_port(theConfig.PEER_PORT);
|
||||||
hello->set_version(theConfig.VERSION);
|
hello->set_version(theConfig.VERSION);
|
||||||
|
|
||||||
PackedMessage::pointer packet(new PackedMessage(PackedMessage::MessagePointer(hello),newcoin::HELLO));
|
PackedMessage::pointer packet(new PackedMessage(PackedMessage::MessagePointer(hello),newcoin::mtHELLO));
|
||||||
sendPacket(packet);
|
sendPacket(packet);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@@ -413,8 +485,6 @@ void Peer::receiveFullLedger(newcoin::FullLedger& packet)
|
|||||||
theApp->getLedgerMaster().addFullLedger(packet);
|
theApp->getLedgerMaster().addFullLedger(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void Peer::connectTo(KnownNode& node)
|
void Peer::connectTo(KnownNode& node)
|
||||||
{
|
{
|
||||||
tcp::endpoint endpoint( address::from_string(node.mIP), node.mPort);
|
tcp::endpoint endpoint( address::from_string(node.mIP), node.mPort);
|
||||||
@@ -423,3 +493,4 @@ void Peer::connectTo(KnownNode& node)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
24
Peer.h
24
Peer.h
@@ -1,6 +1,7 @@
|
|||||||
#ifndef __PEER__
|
#ifndef __PEER__
|
||||||
#define __PEER__
|
#define __PEER__
|
||||||
|
|
||||||
|
#include <bitset>
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
#include <boost/enable_shared_from_this.hpp>
|
#include <boost/enable_shared_from_this.hpp>
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
@@ -10,28 +11,22 @@
|
|||||||
#include "Transaction.h"
|
#include "Transaction.h"
|
||||||
#include "list"
|
#include "list"
|
||||||
|
|
||||||
class KnownNode;
|
|
||||||
|
|
||||||
/*
|
|
||||||
This is one other node you are connected to.
|
|
||||||
When you connect you:
|
|
||||||
Send Hello
|
|
||||||
Send Your latest ledger
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
class Peer : public boost::enable_shared_from_this<Peer>
|
class Peer : public boost::enable_shared_from_this<Peer>
|
||||||
{
|
{
|
||||||
// Must keep track of the messages you have already sent to or received from this peer
|
public:
|
||||||
// Well actually we can just keep track of if we have broadcast each message
|
static const int psbGotHello=0, psbSentHello=1, psbInMap=2, psbTrusted=3;
|
||||||
|
static const int psbNoLedgers=4, psbNoTransactions=5, psbDownLevel=6;
|
||||||
|
|
||||||
|
protected:
|
||||||
boost::asio::ip::tcp::socket mSocket;
|
boost::asio::ip::tcp::socket mSocket;
|
||||||
std::vector<uint8_t> mReadbuf;
|
std::vector<uint8_t> mReadbuf;
|
||||||
std::list<PackedMessage::pointer> mSendQ;
|
std::list<PackedMessage::pointer> mSendQ;
|
||||||
PackedMessage::pointer mSendingPacket;
|
PackedMessage::pointer mSendingPacket;
|
||||||
|
std::bitset<32> mPeerBits;
|
||||||
|
|
||||||
Peer(boost::asio::io_service& io_service);
|
Peer(boost::asio::io_service& io_service);
|
||||||
|
|
||||||
|
|
||||||
void handle_write(const boost::system::error_code& error, size_t bytes_transferred);
|
void handle_write(const boost::system::error_code& error, size_t bytes_transferred);
|
||||||
//void handle_read(const boost::system::error_code& error, size_t bytes_transferred);
|
//void handle_read(const boost::system::error_code& error, size_t bytes_transferred);
|
||||||
void handle_read_header(const boost::system::error_code& error);
|
void handle_read_header(const boost::system::error_code& error);
|
||||||
@@ -81,9 +76,6 @@ public:
|
|||||||
|
|
||||||
void connected(const boost::system::error_code& error);
|
void connected(const boost::system::error_code& error);
|
||||||
|
|
||||||
// try to connect to this Peer
|
|
||||||
void connectTo(KnownNode& node);
|
|
||||||
|
|
||||||
void sendPacket(PackedMessage::pointer packet);
|
void sendPacket(PackedMessage::pointer packet);
|
||||||
void sendLedgerProposal(Ledger::pointer ledger);
|
void sendLedgerProposal(Ledger::pointer ledger);
|
||||||
void sendFullLedger(Ledger::pointer ledger);
|
void sendFullLedger(Ledger::pointer ledger);
|
||||||
@@ -93,8 +85,6 @@ public:
|
|||||||
static PackedMessage::pointer createLedgerProposal(Ledger::pointer ledger);
|
static PackedMessage::pointer createLedgerProposal(Ledger::pointer ledger);
|
||||||
static PackedMessage::pointer createValidation(Ledger::pointer ledger);
|
static PackedMessage::pointer createValidation(Ledger::pointer ledger);
|
||||||
static PackedMessage::pointer createGetFullLedger(uint256& hash);
|
static PackedMessage::pointer createGetFullLedger(uint256& hash);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ bool SHAMap::compare(SHAMap::pointer otherMap, SHAMapDiff& differences, int maxC
|
|||||||
nodeStack.push(SHAMapDiffNode(SHAMapNode(), getHash(), otherMap->getHash()));
|
nodeStack.push(SHAMapDiffNode(SHAMapNode(), getHash(), otherMap->getHash()));
|
||||||
|
|
||||||
ScopedLock sl(Lock());
|
ScopedLock sl(Lock());
|
||||||
while(nodeStack.size())
|
while(!nodeStack.empty())
|
||||||
{
|
{
|
||||||
SHAMapDiffNode node(nodeStack.top());
|
SHAMapDiffNode node(nodeStack.top());
|
||||||
nodeStack.pop();
|
nodeStack.pop();
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ bool SHAMapLeafNode::addUpdateItem(SHAMapItem::pointer item)
|
|||||||
std::cerr << " addi(" << item->getTag().GetHex() << std::endl;
|
std::cerr << " addi(" << item->getTag().GetHex() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
std::list<SHAMapItem::pointer>::iterator it;
|
std::list<SHAMapItem::pointer>::iterator it;
|
||||||
for(it=mItems.begin(); it!=mItems.end(); it++)
|
for(it=mItems.begin(); it!=mItems.end(); ++it)
|
||||||
{
|
{
|
||||||
SHAMapItem &nodeItem=**it;
|
SHAMapItem &nodeItem=**it;
|
||||||
if(nodeItem.getTag()==item->getTag())
|
if(nodeItem.getTag()==item->getTag())
|
||||||
@@ -191,7 +191,7 @@ bool SHAMapLeafNode::addUpdateItem(SHAMapItem::pointer item)
|
|||||||
bool SHAMapLeafNode::delItem(const uint256& tag)
|
bool SHAMapLeafNode::delItem(const uint256& tag)
|
||||||
{
|
{
|
||||||
std::list<SHAMapItem::pointer>::iterator it;
|
std::list<SHAMapItem::pointer>::iterator it;
|
||||||
for(it=mItems.begin(); it!=mItems.end(); it++)
|
for(it=mItems.begin(); it!=mItems.end(); ++it)
|
||||||
{
|
{
|
||||||
if((*it)->getTag()==tag)
|
if((*it)->getTag()==tag)
|
||||||
{
|
{
|
||||||
@@ -211,7 +211,7 @@ SHAMapItem::pointer SHAMapLeafNode::findItem(const uint256& tag)
|
|||||||
|
|
||||||
SHAMapItem::pointer SHAMapLeafNode::firstItem()
|
SHAMapItem::pointer SHAMapLeafNode::firstItem()
|
||||||
{
|
{
|
||||||
if(mItems.size()==0) return SHAMapItem::pointer();
|
if(mItems.empty()) return SHAMapItem::pointer();
|
||||||
return *(mItems.begin());
|
return *(mItems.begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,7 +254,7 @@ SHAMapItem::pointer SHAMapLeafNode::prevItem(const uint256& tag)
|
|||||||
|
|
||||||
SHAMapItem::pointer SHAMapLeafNode::lastItem()
|
SHAMapItem::pointer SHAMapLeafNode::lastItem()
|
||||||
{
|
{
|
||||||
if(mItems.size()==0) return SHAMapItem::pointer();
|
if(mItems.empty()) return SHAMapItem::pointer();
|
||||||
return *(mItems.rbegin());
|
return *(mItems.rbegin());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,7 +262,7 @@ SHAMapItem::pointer SHAMapLeafNode::lastItem()
|
|||||||
bool SHAMapLeafNode::updateHash()
|
bool SHAMapLeafNode::updateHash()
|
||||||
{
|
{
|
||||||
uint256 nh;
|
uint256 nh;
|
||||||
if(mItems.size()!=0)
|
if(!mItems.empty())
|
||||||
{
|
{
|
||||||
Serializer s;
|
Serializer s;
|
||||||
BOOST_FOREACH(const SHAMapItem::pointer &mi, mItems)
|
BOOST_FOREACH(const SHAMapItem::pointer &mi, mItems)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
Transaction::Transaction() : mTransactionID(0), mAccountFrom(0), mAccountTo(0),
|
Transaction::Transaction() : mTransactionID(0), mAccountFrom(0), mAccountTo(0),
|
||||||
mAmount(0), mFromAccountSeq(0), mSourceLedger(0), mIdent(0),
|
mAmount(0), mFee(0), mFromAccountSeq(0), mSourceLedger(0), mIdent(0),
|
||||||
mInLedger(0), mStatus(INVALID)
|
mInLedger(0), mStatus(INVALID)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,32 +2,32 @@ package newcoin;
|
|||||||
|
|
||||||
enum MessageType {
|
enum MessageType {
|
||||||
// core
|
// core
|
||||||
HELLO= 0;
|
mtHELLO= 0;
|
||||||
ERROR_MSG= 1;
|
mtERROR_MSG= 1;
|
||||||
PING= 2;
|
mtPING= 2;
|
||||||
|
|
||||||
// network presence detection
|
// network presence detection
|
||||||
GET_CONTACTS= 10;
|
mtGET_CONTACTS= 10;
|
||||||
CONTACT= 11;
|
mtCONTACT= 11;
|
||||||
|
|
||||||
|
|
||||||
// operations for 'small' nodes
|
// operations for 'small' nodes
|
||||||
SEARCH_TRANSACTION= 20;
|
mtSEARCH_TRANSACTION= 20;
|
||||||
GET_ACCOUNT= 21;
|
mtGET_ACCOUNT= 21;
|
||||||
ACCOUNT= 22;
|
mtACCOUNT= 22;
|
||||||
|
|
||||||
// transaction and ledger processing
|
// transaction and ledger processing
|
||||||
TRANSACTION= 30;
|
mtTRANSACTION= 30;
|
||||||
GET_LEDGER= 31;
|
mtGET_LEDGER= 31;
|
||||||
LEDGER= 32;
|
mtLEDGER= 32;
|
||||||
PROPOSE_LEDGER= 33;
|
mtPROPOSE_LEDGER= 33;
|
||||||
CLOSE_LEDGER= 35;
|
mtCLOSE_LEDGER= 35;
|
||||||
|
|
||||||
// data replication and synchronization
|
// data replication and synchronization
|
||||||
GET_VALIDATIONS= 40;
|
mtGET_VALIDATIONS= 40;
|
||||||
VALIDATION= 41;
|
mtVALIDATION= 41;
|
||||||
GET_OBJECT= 42;
|
mtGET_OBJECT= 42;
|
||||||
OBJECT= 43;
|
mtOBJECT= 43;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -47,14 +47,14 @@ you must first combine coins from one address to another.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
enum TransactionStatus {
|
enum TransactionStatus {
|
||||||
NEW = 1; // origin node did/could not validate
|
tsNEW = 1; // origin node did/could not validate
|
||||||
CURRENT = 2; // scheduled to go in this ledger
|
tsCURRENT = 2; // scheduled to go in this ledger
|
||||||
COMMITED = 3; // in a closed ledger
|
tsCOMMITED = 3; // in a closed ledger
|
||||||
REJECT_CONFLICT = 4;
|
tsREJECT_CONFLICT = 4;
|
||||||
REJECT_INVALID = 5;
|
tsREJECT_INVALID = 5;
|
||||||
REJECT_FUNDS = 6;
|
tsREJECT_FUNDS = 6;
|
||||||
HELD_SEQ = 7;
|
tsHELD_SEQ = 7;
|
||||||
HELD_LEDGER = 8; // held for future ledger
|
tsHELD_LEDGER = 8; // held for future ledger
|
||||||
}
|
}
|
||||||
|
|
||||||
message TMTransaction {
|
message TMTransaction {
|
||||||
@@ -143,13 +143,13 @@ message TMAccount{
|
|||||||
message TMIndexedObject
|
message TMIndexedObject
|
||||||
{
|
{
|
||||||
enum ObjectType {
|
enum ObjectType {
|
||||||
TRANSACTION = 1;
|
otTRANSACTION = 1;
|
||||||
TRANSACTION_NODE = 2; // a node in a transaction tree
|
otTRANSACTION_NODE = 2; // a node in a transaction tree
|
||||||
TRANSACTION_LEAF = 3; // a leaf in a transaction tree
|
otTRANSACTION_LEAF = 3; // a leaf in a transaction tree
|
||||||
ACCOUNT = 4; // a single account state (with balance/sequence)
|
otACCOUNT = 4; // a single account state (with balance/sequence)
|
||||||
ACCOUNT_NODE = 5; // a node in an account state tree
|
otACCOUNT_NODE = 5; // a node in an account state tree
|
||||||
ACCOUNT_LEAF = 6; // a leaf in an account state tree
|
otACCOUNT_LEAF = 6; // a leaf in an account state tree
|
||||||
LEDGER = 7;
|
otLEDGER = 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
required bytes hash = 1;
|
required bytes hash = 1;
|
||||||
|
|||||||
1
rpc.cpp
1
rpc.cpp
@@ -215,7 +215,6 @@ bool HTTPAuthorized(map<std::string, std::string>& mapHeaders)
|
|||||||
//
|
//
|
||||||
// 1.0 spec: http://json-rpc.org/wiki/specification
|
// 1.0 spec: http://json-rpc.org/wiki/specification
|
||||||
// 1.2 spec: http://groups.google.com/group/json-rpc/web/json-rpc-over-http
|
// 1.2 spec: http://groups.google.com/group/json-rpc/web/json-rpc-over-http
|
||||||
// http://www.codeproject.com/KB/recipes/JSON_Spirit.aspx
|
|
||||||
//
|
//
|
||||||
|
|
||||||
std::string JSONRPCRequest(const std::string& strMethod, const Json::Value& params, const Json::Value& id)
|
std::string JSONRPCRequest(const std::string& strMethod, const Json::Value& params, const Json::Value& id)
|
||||||
|
|||||||
17
uint256.h
17
uint256.h
@@ -12,13 +12,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
#include "types.h"
|
||||||
typedef __int64 int64;
|
|
||||||
typedef unsigned __int64 uint64;
|
|
||||||
#else
|
|
||||||
typedef long long int64;
|
|
||||||
typedef unsigned long long uint64;
|
|
||||||
#endif
|
|
||||||
#if defined(_MSC_VER) && _MSC_VER < 1300
|
#if defined(_MSC_VER) && _MSC_VER < 1300
|
||||||
#define for if (false) ; else for
|
#define for if (false) ; else for
|
||||||
#endif
|
#endif
|
||||||
@@ -59,7 +54,7 @@ public:
|
|||||||
base_uint ret;
|
base_uint ret;
|
||||||
for (int i = 0; i < WIDTH; i++)
|
for (int i = 0; i < WIDTH; i++)
|
||||||
ret.pn[i] = ~pn[i];
|
ret.pn[i] = ~pn[i];
|
||||||
ret++;
|
++ret;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -649,17 +644,17 @@ inline int Testuint256AdHoc(std::vector<std::string> vArg)
|
|||||||
|
|
||||||
|
|
||||||
printf("%s\n", g.ToString().c_str());
|
printf("%s\n", g.ToString().c_str());
|
||||||
g--; printf("g--\n");
|
--g; printf("--g\n");
|
||||||
printf("%s\n", g.ToString().c_str());
|
printf("%s\n", g.ToString().c_str());
|
||||||
g--; printf("g--\n");
|
g--; printf("g--\n");
|
||||||
printf("%s\n", g.ToString().c_str());
|
printf("%s\n", g.ToString().c_str());
|
||||||
g++; printf("g++\n");
|
g++; printf("g++\n");
|
||||||
printf("%s\n", g.ToString().c_str());
|
printf("%s\n", g.ToString().c_str());
|
||||||
g++; printf("g++\n");
|
++g; printf("++g\n");
|
||||||
printf("%s\n", g.ToString().c_str());
|
printf("%s\n", g.ToString().c_str());
|
||||||
g++; printf("g++\n");
|
g++; printf("g++\n");
|
||||||
printf("%s\n", g.ToString().c_str());
|
printf("%s\n", g.ToString().c_str());
|
||||||
g++; printf("g++\n");
|
++g; printf("++g\n");
|
||||||
printf("%s\n", g.ToString().c_str());
|
printf("%s\n", g.ToString().c_str());
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user