aboutsummaryrefslogtreecommitdiff
path: root/src/net.cpp
diff options
context:
space:
mode:
authorHuang Le <4tarhl@gmail.com>2014-05-30 23:44:44 +0800
committerWladimir J. van der Laan <laanwj@gmail.com>2014-06-02 14:26:24 +0200
commitacb53560874f54a661a71532f5c446d33dd07c7f (patch)
treef92a1f833b5499880e08b9b5be954a2827c712f0 /src/net.cpp
parent41b96da2643dd94030b8cde789d59110917b5a0f (diff)
Use pnode->nLastRecv as sync score directly
NodeSyncScore() should find the node which we recv data most recently, so put a negative sign to pnode->nLastRecv is indeed wrong. Also change the return value type to int64_t. Signed-off-by: Huang Le <4tarhl@gmail.com> Rebased-By: Wladimir J. van der Laan <laanwj@gmail.com> Rebased-From: 09a54a6
Diffstat (limited to 'src/net.cpp')
-rw-r--r--src/net.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/net.cpp b/src/net.cpp
index 4cbd26a563..a63625051b 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -1458,13 +1458,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);
@@ -1476,10 +1476,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;
}
}
}