2

ping doesn't return anything so what is it used for?

If a user wants to ping and check ping time for all peers, getpeerinfo can be used.

2
  • I think ping is a basic networking utility that would be expected to be included in all P2P software. getpeerinfo provides additional information that you may not be interested in if you are just looking at ping time. Jul 5, 2021 at 14:03
  • It does not have any arguments so that user can mention address of a node to ping, it does not return any details, so I am not sure why would someone use it. I could not understand this comment by Greg Maxwell. If Bitcoin Core does not ping all peers automatically every few seconds then maybe there are use cases for this RPC else it can only be used for spamming (assuming there are no rate limits)
    – user103136
    Jul 5, 2021 at 15:01

1 Answer 1

4

The help text is your friend:

Requests that a ping be sent to all other nodes, to measure ping time.
Results provided in getpeerinfo, pingtime and pingwait fields are decimal seconds.
Ping command is handled in queue with all other commands, so it measures processing backlog, not just network ping

After you use ping, you may see a new field, pingwait, in the getpeerinfo output. This is the time for waiting for the ping response. You will also see pingtime being updated once the peer responds to the ping. The purpose is to get an update on the ping times since the ping time reported may have been measured a long time ago.

2
  • getpeerinfo for one peer before ping: pastebin.com/s81cmpu7 getpeerinfo for same peer after ping: pastebin.com/6ZUgWTZ4 I don't see pingwait in it. pingtime changed from 0.077075 to 0.077956 but it changes regularly even without running ping command
    – user103136
    Jul 5, 2021 at 17:48
  • I could see pingwait today in pastebin.com/vKi5sfK2
    – user103136
    Jul 6, 2021 at 19:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.