mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-29 23:45:51 +00:00
Bugfixes.
This commit is contained in:
@@ -20,7 +20,13 @@ PackedMessage::PackedMessage(MessagePointer msg, int type)
|
|||||||
assert(msg_size);
|
assert(msg_size);
|
||||||
mBuffer.resize(HEADER_SIZE + msg_size);
|
mBuffer.resize(HEADER_SIZE + msg_size);
|
||||||
encodeHeader(msg_size,type);
|
encodeHeader(msg_size,type);
|
||||||
if(msg_size) mMsg->SerializeToArray(&mBuffer[HEADER_SIZE], msg_size);
|
if(msg_size)
|
||||||
|
{
|
||||||
|
mMsg->SerializeToArray(&mBuffer[HEADER_SIZE], msg_size);
|
||||||
|
#ifdef DEBUG
|
||||||
|
std::cerr << "PackedMessage: type=" << type << ", datalen=" << msg_size << std::endl;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PackedMessage::operator == (const PackedMessage& other)
|
bool PackedMessage::operator == (const PackedMessage& other)
|
||||||
|
|||||||
@@ -26,12 +26,13 @@ const unsigned HEADER_SIZE = 6;
|
|||||||
|
|
||||||
class PackedMessage : public boost::enable_shared_from_this<PackedMessage>
|
class PackedMessage : public boost::enable_shared_from_this<PackedMessage>
|
||||||
{
|
{
|
||||||
|
|
||||||
|
std::vector<uint8_t> mBuffer;
|
||||||
|
|
||||||
// Encodes the size and type into a header at the beginning of buf
|
// Encodes the size and type into a header at the beginning of buf
|
||||||
//
|
//
|
||||||
void encodeHeader(unsigned size, int type);
|
void encodeHeader(unsigned size, int type);
|
||||||
|
|
||||||
|
|
||||||
std::vector<uint8_t> mBuffer;
|
|
||||||
public:
|
public:
|
||||||
typedef boost::shared_ptr< ::google::protobuf::Message > MessagePointer;
|
typedef boost::shared_ptr< ::google::protobuf::Message > MessagePointer;
|
||||||
typedef boost::shared_ptr<PackedMessage> pointer;
|
typedef boost::shared_ptr<PackedMessage> pointer;
|
||||||
|
|||||||
6
Peer.cpp
6
Peer.cpp
@@ -5,6 +5,8 @@
|
|||||||
//#include <boost/log/trivial.hpp>
|
//#include <boost/log/trivial.hpp>
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
|
|
||||||
|
#include "json/writer.h"
|
||||||
|
|
||||||
#include "Peer.h"
|
#include "Peer.h"
|
||||||
#include "KnownNodeList.h"
|
#include "KnownNodeList.h"
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
@@ -123,7 +125,7 @@ void Peer::processReadBuffer()
|
|||||||
{
|
{
|
||||||
int type=PackedMessage::getType(mReadbuf);
|
int type=PackedMessage::getType(mReadbuf);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
std::cerr << "PRB(" << type << ")" << std::endl;
|
std::cerr << "PRB(" << type << "), len=" << (mReadbuf.size()-HEADER_SIZE) << std::endl;
|
||||||
#endif
|
#endif
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
@@ -295,6 +297,8 @@ void Peer::recvTransaction(newcoin::TMTransaction& packet)
|
|||||||
{ // transaction fails basic validity tests
|
{ // transaction fails basic validity tests
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
std::cerr << "Transaction from peer fails validity tests" << std::endl;
|
std::cerr << "Transaction from peer fails validity tests" << std::endl;
|
||||||
|
Json::StyledStreamWriter w;
|
||||||
|
w.write(std::cerr, tx->getJson(true));
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ Transaction::Transaction(const std::vector<unsigned char> &t, bool validate) : m
|
|||||||
mFromPubKey=theApp->getPubKeyCache().store(mAccountFrom, mFromPubKey);
|
mFromPubKey=theApp->getPubKeyCache().store(mAccountFrom, mFromPubKey);
|
||||||
|
|
||||||
updateID();
|
updateID();
|
||||||
|
updateFee();
|
||||||
|
|
||||||
if(!validate || checkSign())
|
if(!validate || checkSign())
|
||||||
mStatus=NEW;
|
mStatus=NEW;
|
||||||
@@ -130,11 +131,11 @@ Serializer::pointer Transaction::getRaw(bool prefix) const
|
|||||||
Serializer::pointer ret(new Serializer(77));
|
Serializer::pointer ret(new Serializer(77));
|
||||||
if(prefix) ret->add32(0x54584e00u);
|
if(prefix) ret->add32(0x54584e00u);
|
||||||
ret->add160(mAccountTo);
|
ret->add160(mAccountTo);
|
||||||
ret->addRaw(mFromPubKey->GetPubKey());
|
|
||||||
ret->add64(mAmount);
|
ret->add64(mAmount);
|
||||||
ret->add32(mFromAccountSeq);
|
ret->add32(mFromAccountSeq);
|
||||||
ret->add32(mSourceLedger);
|
ret->add32(mSourceLedger);
|
||||||
ret->add32(mIdent);
|
ret->add32(mIdent);
|
||||||
|
ret->addRaw(mFromPubKey->GetPubKey());
|
||||||
assert( (prefix&&(ret->getLength()==77)) || (!prefix&&(ret->getLength()==73)) );
|
assert( (prefix&&(ret->getLength()==77)) || (!prefix&&(ret->getLength()==73)) );
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user