Improve sync (#1779)
* Do not relay `mnp`, `mnb`, `mnw`, `govobj` and `govobjvote` until fully synced This should massively lower outgoing traffic and load during sync process (especially on mainnet) * Apply "no sync from me until I'm synced" rule to all nodes
This commit is contained in:
parent
a79c972486
commit
63e3061487
@ -8,6 +8,7 @@
|
|||||||
#include "governance-object.h"
|
#include "governance-object.h"
|
||||||
#include "governance-vote.h"
|
#include "governance-vote.h"
|
||||||
#include "instantx.h"
|
#include "instantx.h"
|
||||||
|
#include "masternode-sync.h"
|
||||||
#include "masternodeman.h"
|
#include "masternodeman.h"
|
||||||
#include "messagesigner.h"
|
#include "messagesigner.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
@ -651,6 +652,12 @@ bool CGovernanceObject::GetCurrentMNVotes(const COutPoint& mnCollateralOutpoint,
|
|||||||
|
|
||||||
void CGovernanceObject::Relay(CConnman& connman)
|
void CGovernanceObject::Relay(CConnman& connman)
|
||||||
{
|
{
|
||||||
|
// Do not relay until fully synced
|
||||||
|
if(!masternodeSync.IsSynced()) {
|
||||||
|
LogPrint("gobject", "CGovernanceObject::Relay -- won't relay until fully synced\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CInv inv(MSG_GOVERNANCE_OBJECT, GetHash());
|
CInv inv(MSG_GOVERNANCE_OBJECT, GetHash());
|
||||||
connman.RelayInv(inv, MIN_GOVERNANCE_PEER_PROTO_VERSION);
|
connman.RelayInv(inv, MIN_GOVERNANCE_PEER_PROTO_VERSION);
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "governance-vote.h"
|
#include "governance-vote.h"
|
||||||
#include "governance-object.h"
|
#include "governance-object.h"
|
||||||
|
#include "masternode-sync.h"
|
||||||
#include "masternodeman.h"
|
#include "masternodeman.h"
|
||||||
#include "messagesigner.h"
|
#include "messagesigner.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
@ -226,6 +227,12 @@ CGovernanceVote::CGovernanceVote(COutPoint outpointMasternodeIn, uint256 nParent
|
|||||||
|
|
||||||
void CGovernanceVote::Relay(CConnman& connman) const
|
void CGovernanceVote::Relay(CConnman& connman) const
|
||||||
{
|
{
|
||||||
|
// Do not relay until fully synced
|
||||||
|
if(!masternodeSync.IsSynced()) {
|
||||||
|
LogPrint("gobject", "CGovernanceVote::Relay -- won't relay until fully synced\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CInv inv(MSG_GOVERNANCE_OBJECT_VOTE, GetHash());
|
CInv inv(MSG_GOVERNANCE_OBJECT_VOTE, GetHash());
|
||||||
connman.RelayInv(inv, MIN_GOVERNANCE_PEER_PROTO_VERSION);
|
connman.RelayInv(inv, MIN_GOVERNANCE_PEER_PROTO_VERSION);
|
||||||
}
|
}
|
||||||
|
@ -740,7 +740,7 @@ void CGovernanceManager::Sync(CNode* pfrom, const uint256& nProp, const CBloomFi
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// do not provide any data until our node is synced
|
// do not provide any data until our node is synced
|
||||||
if(fMasterNode && !masternodeSync.IsSynced()) return;
|
if(!masternodeSync.IsSynced()) return;
|
||||||
|
|
||||||
int nObjCount = 0;
|
int nObjCount = 0;
|
||||||
int nVoteCount = 0;
|
int nVoteCount = 0;
|
||||||
|
@ -840,8 +840,12 @@ void CMasternodePayments::CheckPreviousBlockVotes(int nPrevBlockHeight)
|
|||||||
|
|
||||||
void CMasternodePaymentVote::Relay(CConnman& connman)
|
void CMasternodePaymentVote::Relay(CConnman& connman)
|
||||||
{
|
{
|
||||||
// do not relay until synced
|
// Do not relay until fully synced
|
||||||
if (!masternodeSync.IsWinnersListSynced()) return;
|
if(!masternodeSync.IsSynced()) {
|
||||||
|
LogPrint("mnpayments", "CMasternodePayments::Relay -- won't relay until fully synced\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CInv inv(MSG_MASTERNODE_PAYMENT_VOTE, GetHash());
|
CInv inv(MSG_MASTERNODE_PAYMENT_VOTE, GetHash());
|
||||||
connman.RelayInv(inv);
|
connman.RelayInv(inv);
|
||||||
}
|
}
|
||||||
|
@ -654,6 +654,12 @@ bool CMasternodeBroadcast::CheckSignature(int& nDos)
|
|||||||
|
|
||||||
void CMasternodeBroadcast::Relay(CConnman& connman)
|
void CMasternodeBroadcast::Relay(CConnman& connman)
|
||||||
{
|
{
|
||||||
|
// Do not relay until fully synced
|
||||||
|
if(!masternodeSync.IsSynced()) {
|
||||||
|
LogPrint("masternode", "CMasternodeBroadcast::Relay -- won't relay until fully synced\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CInv inv(MSG_MASTERNODE_ANNOUNCE, GetHash());
|
CInv inv(MSG_MASTERNODE_ANNOUNCE, GetHash());
|
||||||
connman.RelayInv(inv);
|
connman.RelayInv(inv);
|
||||||
}
|
}
|
||||||
@ -813,6 +819,12 @@ bool CMasternodePing::CheckAndUpdate(CMasternode* pmn, bool fFromNewBroadcast, i
|
|||||||
|
|
||||||
void CMasternodePing::Relay(CConnman& connman)
|
void CMasternodePing::Relay(CConnman& connman)
|
||||||
{
|
{
|
||||||
|
// Do not relay until fully synced
|
||||||
|
if(!masternodeSync.IsSynced()) {
|
||||||
|
LogPrint("masternode", "CMasternodePing::Relay -- won't relay until fully synced\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CInv inv(MSG_MASTERNODE_PING, GetHash());
|
CInv inv(MSG_MASTERNODE_PING, GetHash());
|
||||||
connman.RelayInv(inv);
|
connman.RelayInv(inv);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user