Merge pull request #4261

09a54a6 Use pnode->nLastRecv as sync score directly (Huang Le)
This commit is contained in:
Wladimir J. van der Laan 2014-06-02 14:25:03 +02:00
commit 42d87749eb
No known key found for this signature in database
GPG key ID: 74810B012346C9A6

View file

@ -1455,13 +1455,13 @@ bool OpenNetworkConnection(const CAddress& addrConnect, CSemaphoreGrant *grantOu
// for now, use a very simple selection metric: the node from which we received
// most recently
double static NodeSyncScore(const CNode *pnode) {
return -pnode->nLastRecv;
static int64_t NodeSyncScore(const CNode *pnode) {
return pnode->nLastRecv;
}
void static StartSync(const vector<CNode*> &vNodes) {
CNode *pnodeNewSync = NULL;
double dBestScore = 0;
int64_t nBestScore = 0;
int nBestHeight = g_signals.GetHeight().get_value_or(0);
@ -1473,10 +1473,10 @@ void static StartSync(const vector<CNode*> &vNodes) {
(pnode->nStartingHeight > (nBestHeight - 144)) &&
(pnode->nVersion < NOBLKS_VERSION_START || pnode->nVersion >= NOBLKS_VERSION_END)) {
// if ok, compare node's score with the best so far
double dScore = NodeSyncScore(pnode);
if (pnodeNewSync == NULL || dScore > dBestScore) {
int64_t nScore = NodeSyncScore(pnode);
if (pnodeNewSync == NULL || nScore > nBestScore) {
pnodeNewSync = pnode;
dBestScore = dScore;
nBestScore = nScore;
}
}
}