I have a four node setup and have get method in smartcontract to get the status of certain application. Currently the api invocation is happening at any node ( any of four nodes). For example if one of the node is syncing to other nodes ( was down for some time) in the network and if my api call is triggered at the syncing node the data which I am getting won't be the latest one. So is there anyway to identify the node is in sync with network and then perform the api get call or am I wrong with my understatnding.
As say in other answer you should use
web3.eth.isSyncing but just to be precise this function :
- if is synced, returns
- if is syncing, returns
- if is just started / not connected to other nodes, returns
The last case can be tricky as it gives you false positive.