2
1
After reading this answer, where Peter Wuille talks about how a node can't really tell if it is synced or not, it got me wondering if there is a way we can tell that a node is as synced as it possibly can be given the peers it is connected to.
Could we add an RPC call like getsyncstatus that would have the node ask its peers for their highest known blocks and if a majority (or some percentage) of their peers all agree on the best known block height, then it could use that info to be able to say (with not perfect reliability) how synced the node is?
So, for example, if a node has 8 peers, and 7 of them are returning 330448 as the best block height, and the client has information about block 330448, then it could give a status code and message signalling that it is up to date. If the peers give different answers (which could happen if you connect to a malicious node that is falsely reporting it's best known height OR if other peers are not fully synced), then it could give a status code and a message indicating that the search was inconclusive and they should try again later. And lastly, if 87.5% of nodes are saying 330448 and the node is only synced up to block 1000, then it can give a status code and message indicating that the node is likely not sufficiently synchronized.
I think this would mainly be useful as a way to determine whether servers are sufficiently synchronized with the network for use on some application. The responses to this question describes a way to see if nodes are up to date, but they all seem kind of hacky, and I'm not sure they would be reliable enough.
What if the client has received a block recently but it is not done processing it, what will
getblocktemplatedo in this case? – morsecoder – 2014-11-17T19:57:27.327@StephenM347 It looks at when it finished validating the tip of the best blockchain. (So, it doesn't take blocks that haven't been validated into account.) – Nick ODell – 2014-11-17T20:00:03.123
Okay, thanks. I wish this were exposed in the RPC interface in a less hacky way. – morsecoder – 2014-11-17T20:02:45.783
So won't this method fail if the client is synced past all of the checkpoints, but has been offline for like 8 hours? – morsecoder – 2014-11-17T20:06:15.440
2@StephenM347 Well, it'll fail to fail. :) In all seriousness, you're correct. – Nick ODell – 2014-11-17T21:20:16.600
So, unfortunately this doesn't really solve the problem then... :/ – morsecoder – 2014-11-17T21:27:55.767
1But it does answer my question, so if you update it to include the stuff you told me in this commenting, I'll mark is as the right answer. And adding a new RPC call could fix this, you think, right? – morsecoder – 2014-11-17T21:33:55.063