Litecoin: Relay alerts prior to MIN_PEER_PROTO_VERSION disconnect

Otherwise the old client may fail to receive an alert saying they need to upgrade.
This commit is contained in:
Warren Togami 2015-01-23 01:40:05 -10:00
parent f2d66b7f6e
commit 85245f1e63

View File

@ -3287,6 +3287,12 @@ string GetWarnings(string strFor)
}
void static RelayAlerts(CNode* pfrom)
{
LOCK(cs_mapAlerts);
BOOST_FOREACH(PAIRTYPE(const uint256, CAlert)& item, mapAlerts)
item.second.RelayTo(pfrom);
}
@ -3479,6 +3485,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
vRecv >> pfrom->nVersion >> pfrom->nServices >> nTime >> addrMe;
if (pfrom->nVersion < MIN_PEER_PROTO_VERSION)
{
// relay alerts prior to disconnection
RelayAlerts(pfrom);
// disconnect from peers older than this proto version
LogPrintf("peer=%d using obsolete version %i; disconnecting\n", pfrom->id, pfrom->nVersion);
pfrom->PushMessage("reject", strCommand, REJECT_OBSOLETE,
@ -3560,11 +3568,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
}
// Relay alerts
{
LOCK(cs_mapAlerts);
BOOST_FOREACH(PAIRTYPE(const uint256, CAlert)& item, mapAlerts)
item.second.RelayTo(pfrom);
}
RelayAlerts(pfrom);
pfrom->fSuccessfullyConnected = true;