mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Track a peer's last closed ledger.
This commit is contained in:
13
src/Peer.cpp
13
src/Peer.cpp
@@ -523,6 +523,12 @@ void Peer::recvHello(newcoin::TMHello& packet)
|
||||
// XXX Set timer: connection is in grace period to be useful.
|
||||
// XXX Set timer: connection idle (idle may vary depending on connection type.)
|
||||
|
||||
if ((packet.has_closedledger()) && (packet.closedledger().size() == (256 / 8)))
|
||||
{
|
||||
memcpy(mClosedLedgerHash.begin(), packet.closedledger().data(), (256 / 8));
|
||||
mClosedLedgerTime = boost::posix_time::second_clock::universal_time();
|
||||
}
|
||||
|
||||
bDetach = false;
|
||||
}
|
||||
|
||||
@@ -775,11 +781,10 @@ void Peer::sendHello()
|
||||
|
||||
Ledger::pointer closedLedger = theApp->getMasterLedger().getClosedLedger();
|
||||
assert(closedLedger && closedLedger->isClosed());
|
||||
if(closedLedger->isClosed())
|
||||
if (closedLedger->isClosed())
|
||||
{
|
||||
Serializer s(128);
|
||||
closedLedger->addRaw(s);
|
||||
h->set_closedledger(s.getDataPtr(), s.getLength());
|
||||
uint256 hash = closedLedger->getHash();
|
||||
h->set_closedledger(hash.begin(), hash.GetSerializeSize());
|
||||
}
|
||||
|
||||
PackedMessage::pointer packet = boost::make_shared<PackedMessage>
|
||||
|
||||
14
src/Peer.h
14
src/Peer.h
@@ -15,9 +15,9 @@
|
||||
|
||||
enum PeerPunish
|
||||
{
|
||||
PP_INVALID_REQUEST=1, // The peer sent a request that makes no sense
|
||||
PP_UNKNOWN_REQUEST=2, // The peer sent a request that might be garbage
|
||||
PP_UNWANTED_DATA=3, // The peer sent us data we didn't want/need
|
||||
PP_INVALID_REQUEST = 1, // The peer sent a request that makes no sense
|
||||
PP_UNKNOWN_REQUEST = 2, // The peer sent a request that might be garbage
|
||||
PP_UNWANTED_DATA = 3, // The peer sent us data we didn't want/need
|
||||
};
|
||||
|
||||
typedef std::pair<std::string,int> ipPort;
|
||||
@@ -25,8 +25,8 @@ typedef std::pair<std::string,int> ipPort;
|
||||
class Peer : public boost::enable_shared_from_this<Peer>
|
||||
{
|
||||
public:
|
||||
static const int psbGotHello=0, psbSentHello=1, psbInMap=2, psbTrusted=3;
|
||||
static const int psbNoLedgers=4, psbNoTransactions=5, psbDownLevel=6;
|
||||
static const int psbGotHello = 0, psbSentHello = 1, psbInMap = 2, psbTrusted = 3;
|
||||
static const int psbNoLedgers = 4, psbNoTransactions = 5, psbDownLevel = 6;
|
||||
|
||||
void handleConnect(const boost::system::error_code& error, boost::asio::ip::tcp::resolver::iterator it);
|
||||
|
||||
@@ -36,6 +36,10 @@ private:
|
||||
ipPort mIpPort;
|
||||
uint256 mCookieHash;
|
||||
|
||||
// network state information
|
||||
uint256 mClosedLedgerHash;
|
||||
boost::posix_time::ptime mClosedLedgerTime;
|
||||
|
||||
boost::asio::ssl::stream<boost::asio::ip::tcp::socket> mSocketSsl;
|
||||
|
||||
boost::asio::deadline_timer mVerifyTimer;
|
||||
|
||||
Reference in New Issue
Block a user