Ava Chow
9ec1ae0e98
Merge bitcoin/bitcoin#34437 : rpc: uptime should begin on application start
...
e67a676df9 fix: uptime RPC returns 0 on first call (Lőrinc)
Pull request description:
### Problem
#34328 switched uptime to use monotonic time, but `g_startup_time` was a function-local static in `GetUptime()`, meaning it was initialized on first call rather than at program start.
This caused the first uptime RPC to always return 0.
### Fix
Move `g_startup_time` to namespace scope so it initializes at program start, ensuring the first `uptime()` call returns actual elapsed time.
### Reproducer
Revert the fix and run the test or alternatively:
```bash
cmake -B build && cmake --build build --target bitcoind bitcoin-cli -j$(nproc)
./build/bin/bitcoind -regtest -daemon
sleep 10
./build/bin/bitcoin-cli -regtest uptime
./build/bin/bitcoin-cli -regtest stop
```
<details>
<summary>Before (uptime is initialized on first call)</summary>
```bash
Bitcoin Core starting
0
Bitcoin Core stopping
```
</details>
<details>
<summary>After (first uptime call is in-line with sleep)</summary>
```bash
Bitcoin Core starting
10
Bitcoin Core stopping
```
</details>
----
Fixes #34423 , added reporter as coauthor.
ACKs for top commit:
maflcko:
lgtm ACK e67a676df9
optout21:
crACK e67a676df9
carloantinarella:
Tested ACK e67a676df9
achow101:
ACK e67a676df9
musaHaruna:
Tested ACK [e67a676 ](e67a676df9 )
Tree-SHA512: b156f7ed15c3fbb50e8a15f6c9a0d4e2ffb956d0c6ef949e0f8a661a564a20c0d3ed2149fae75ce7e2baa9326788d5037e726e7a7ac2c6ef4e70e4862cd5763f
2026-02-05 17:02:37 -08:00
..
2026-02-04 11:06:36 -08:00
2026-01-29 19:53:48 +01:00
2026-01-22 12:39:52 +01:00
2026-01-20 15:47:17 -08:00
2026-01-30 11:50:17 +00:00
2026-01-30 11:50:17 +00:00
2026-01-27 13:08:50 +01:00
2026-01-28 13:43:56 +01:00
2026-01-21 15:07:23 +00:00
2026-02-05 12:18:51 +00:00
2026-02-03 11:19:01 +01:00
2025-12-16 22:21:15 +01:00
2025-10-13 12:33:23 +01:00
2026-02-02 15:21:16 -08:00
2026-02-03 13:53:41 +00:00
2026-01-28 17:08:34 +01:00
2026-02-04 11:06:36 -08:00
2026-02-02 15:21:16 -08:00
2026-02-02 08:16:43 +01:00
2026-02-02 15:21:14 +00:00
2026-01-20 15:35:19 +01:00
2026-02-04 13:48:21 +00:00
2026-01-31 10:41:50 +00:00
2026-02-02 18:22:31 +01:00
2026-02-05 13:32:24 -08:00
2026-01-29 14:38:35 +00:00
2026-01-29 14:38:35 +00:00
2026-01-28 14:44:22 +01:00
2025-12-16 22:21:15 +01:00
2025-12-16 22:21:15 +01:00
2025-12-16 22:21:15 +01:00
2026-01-14 23:04:12 +01:00
2026-01-20 23:45:29 +01:00
2026-01-14 23:04:12 +01:00
2025-12-16 22:21:15 +01:00
2025-09-12 22:28:41 +02:00
2025-12-16 22:21:15 +01:00
2025-12-16 22:21:15 +01:00
2026-01-21 19:40:25 +05:30
2026-01-12 15:02:14 -05:00
2025-12-19 16:56:02 +00:00
2025-12-16 22:21:15 +01:00
2025-10-06 19:41:35 +01:00
2025-12-16 22:21:15 +01:00
2025-12-16 22:21:15 +01:00
2026-01-19 20:20:13 +01:00
2025-12-16 22:21:15 +01:00
2025-12-16 22:21:15 +01:00
2025-12-16 22:21:15 +01:00
2026-01-14 11:38:07 -08:00
2026-01-29 11:51:41 +01:00
2025-12-16 22:21:15 +01:00
2026-01-14 23:04:12 +01:00
2026-01-14 23:04:12 +01:00
2025-12-16 22:21:15 +01:00
2025-11-13 09:33:36 +01:00
2025-12-16 22:21:15 +01:00
2026-01-12 17:38:30 -05:00
2026-02-02 15:21:14 +00:00
2026-01-29 14:59:36 -08:00
2026-01-29 14:59:36 -08:00
2025-12-16 22:21:15 +01:00
2026-01-20 15:41:30 -08:00
2026-01-19 12:57:16 +01:00
2025-12-16 22:21:15 +01:00
2025-12-12 06:49:59 -04:00
2025-12-12 06:49:59 -04:00
2025-12-16 22:21:15 +01:00
2026-01-14 23:04:12 +01:00
2025-12-16 22:21:15 +01:00
2025-12-16 22:21:15 +01:00
2025-12-16 22:21:15 +01:00
2026-01-14 23:03:47 +01:00
2026-01-14 23:04:12 +01:00
2025-12-16 22:21:15 +01:00
2025-12-16 22:21:15 +01:00
2025-11-20 11:34:21 +09:00
2025-11-20 11:34:21 +09:00
2025-12-19 16:56:02 +00:00
2025-12-16 22:21:15 +01:00
2026-01-28 13:43:56 +01:00
2025-12-16 22:21:15 +01:00
2025-12-13 13:43:24 +01:00
2025-12-16 22:21:15 +01:00
2025-12-16 22:21:15 +01:00
2026-02-02 18:22:31 +01:00
2025-12-16 22:21:15 +01:00
2025-12-16 22:21:15 +01:00
2025-10-14 16:25:52 -04:00
2025-09-30 11:06:43 -07:00
2026-01-12 15:02:14 -05:00
2026-01-12 15:02:14 -05:00
2025-12-16 22:21:15 +01:00
2025-12-16 22:21:15 +01:00
2025-12-16 22:21:15 +01:00
2026-01-14 11:38:07 -08:00
2025-12-16 22:21:15 +01:00
2025-11-24 18:48:43 +01:00
2025-11-24 18:48:43 +01:00
2025-12-16 22:21:15 +01:00
2025-12-16 22:21:15 +01:00
2026-01-30 23:35:23 +01:00
2026-01-14 23:04:12 +01:00
2025-12-16 22:21:15 +01:00
2025-12-16 22:21:15 +01:00
2026-01-28 13:43:56 +01:00
2026-01-20 16:45:18 +01:00
2025-10-02 12:53:55 +01:00
2026-01-14 23:04:12 +01:00
2026-01-22 10:35:14 -05:00
2026-01-23 13:25:42 +01:00
2026-01-20 23:59:41 +01:00
2026-01-20 23:59:41 +01:00
2025-12-16 22:21:15 +01:00
2026-01-14 19:39:01 +01:00
2026-01-14 19:36:14 +01:00
2025-10-02 12:53:55 +01:00
2025-10-02 12:53:55 +01:00
2025-12-16 22:21:15 +01:00
2026-01-14 23:04:12 +01:00
2025-11-03 14:39:50 +01:00
2025-12-16 17:53:50 +01:00
2025-12-16 17:53:50 +01:00
2025-12-16 22:21:15 +01:00
2025-12-16 22:21:15 +01:00
2026-01-14 23:03:47 +01:00
2026-01-14 23:03:47 +01:00
2025-09-30 11:06:09 -07:00
2025-11-03 14:39:48 +01:00
2026-01-14 23:04:12 +01:00
2025-12-16 22:21:15 +01:00
2025-12-16 22:21:15 +01:00
2025-12-14 10:04:37 +01:00
2025-12-16 22:21:15 +01:00
2025-12-16 22:21:15 +01:00
2025-12-16 22:21:15 +01:00
2025-10-30 17:51:53 +01:00
2026-01-20 15:47:17 -08:00
2025-12-21 10:24:09 +01:00
2025-11-14 01:17:38 +02:00
2025-11-14 01:17:38 +02:00
2025-12-19 16:56:02 +00:00
2026-01-21 14:51:12 +01:00
2025-12-16 22:21:15 +01:00
2026-01-20 15:30:46 +01:00
2025-12-16 22:21:15 +01:00
2026-01-06 12:16:45 +01:00
2026-01-02 16:49:23 -08:00
2026-01-12 17:38:30 -05:00
2025-11-25 07:36:50 -05:00
2026-01-22 21:51:13 -05:00
2026-01-22 21:51:13 -05:00
2025-12-18 22:38:02 +01:00
2025-12-30 12:12:26 -08:00
2025-12-16 22:21:15 +01:00
2025-11-03 14:39:48 +01:00
2025-12-16 22:21:15 +01:00
2026-02-02 08:49:02 +01:00
2026-02-02 07:57:34 +01:00
2025-12-16 22:21:15 +01:00
2025-12-12 06:49:59 -04:00
2025-12-16 22:21:15 +01:00
2025-12-19 16:56:02 +00:00
2025-12-16 22:21:15 +01:00
2025-12-16 22:21:15 +01:00