Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
[RPC] Add an uptime command that displays the amount of time (in seconds) bitcoind has been running #10400
I am working on a tool that displays information about a bitcoin node using RPC. One of the parameters I would like to include is the
After thinking a bit on how to perform this task, I concluded that the easiest way to do it is to check the modification time of the
I propose the following solution in this PR and submit it for your review and opinion concerning this new RPC command before I work further on this topic. Do you think this new command makes sense? Please consider it a WIP/PoC as it does not have any error checking or tests.
Here is a sample return from the RPC command:
and the help function:
There is no need to look at the timestamp of any files - the server could simply remember its own startup timestamp and use that as a reference. This would work just as well on windows.
Thank you for replying Wladimir. You are correct of course. Checking the PID file was the most simple and with the least changes to the codebase I could think of - while still being useful (I am not familiar with the Bitcoin core and have not worked with C++ since 2010).
So, if you think this command is useful for inclusion in the core, I could work on improving it and then squash the commits in the end.
Should this information be its own command or should it be included in another existing command - if so, which one?
A gentle reminder that
/** * @note Do not add or change anything in the information returned by this * method. `getinfo` exists for backwards-compatibility only. It combines * information from wildly different sources in the program, which is a mess, * and is thus planned to be deprecated eventually. * * Based on the source of the information, new information should be added to: * - `getblockchaininfo`, * - `getnetworkinfo` or * - `getwalletinfo` * * Or alternatively, create a specific query method for the information. **
One of the other
Thank you for your feedback. I went ahead and made some modifications according to your suggestions.
I have pushed a new commit that removes
I called it
I am not sure of the naming conventions. Should I use
I have build the QT client (QT5 in my case) and the daemon and from my testing every is working well. I have also started the QT client with the
I will add a functional test to the RPC interface for this command. I'm not sure how the testing is done for the QT client.
I have made a new commit with some changes suggested by Pavel.
While searching for examples of documentation I noticed
Here is a sample of the documentation when running
I used the
I've added a functional test to check for the uptime value. In this test I've placed a
As I've noted in the test comment:
@paveljanik I made the change to
Let me know when you think everything is in order and I will go ahead and squash the commits. Thank you for your help (and patience) in reviewing everything :)
A few nits. The only important one is
nStartupTime shouldn't be defined as static in the util.h header file.