This removes all of the global loggers from the project and replaces them with loggers which are instantiated in vspd.go and passed down as params.
To support this, the background package was removed. It only contained one file so it was a bit pointless anyway. It only existed so background tasks could have their own named logger.
- Rename all instances to "shutdownCtx" to be really explicit. This context is special in that it can be closed at any time without warning, so it should be obvious to the reader.
- Don't use shutdownCtx in RPC clients. Clients should not stop working immediately when shutdown is signalled, they need to keep working while the process is shutting down.
* Remove global cache variable.
Rather than maintaining cached data in a global variable, instantiate a cache struct and keep it in the `Server` struct.
* Store net params in RPC clients.
This means net params only need to be supplied once at startup, and also removes a global instance of net params in `background.go`.
This renames "Voting wallet status" to "VSP status" and it now includes the status of the local dcrd instance. This change impacts both the /admin page of the UI, and the response of the /admin/status API endpoint.
Bring in some updates from the signal handling code in other projects:
- Rename `signals` to more descriptive `interruptSignals`.
- Add SIGHUP to unix shutdown signals. Rename `signalsigterm.go` to `signal_unix.go` accordingly.
- Include extra detail in "Already shutting down..." messages log lines.
- Pass a shutdown func into `webapi.go` rather than a channel. It's more obvious how to invoke a func, whereas a channel can be used in multiple ways.
* Remove static cfg values from GUI cache.
Theres no need for these values to be copied into the cache when templates could simply access the config struct directly.
This also changes the cache accessor so it returns a copy of the cache rather than a pointer, which removes a potential race.
* Rename and move cache.
Cache code was previous in `homepage.go`, but its used in multiple places and not just on the homepage. Its enough code to go into its own dedicated `cache.go`.
* Add network proportion to homepage and /vspinfo.
Proportion is calculated using the number of tickets currently registered with the VSP, divided by the total size of the network ticket pool as reported by `getblockheader`.
The value will only ever be an estimate because:
- it's possible for a single ticket to be added to multiple VSPs.
- vspd does not distinguish between immature and live tickets, whereas `getblockheader` only reports live tickets.
- `getblockheader` is reporting the size of the ticket pool as of the previous block, not the current block.
* xaur suggestions
* Show missed ticket %, not just the raw number.
* Ensure purchase height set for confirmed tickets.
* Show purchase height in admin screen.
Only show purchase height when the ticket is confirmed, because if a ticket is not confirmed, its purchase height is not yet known.
Plus a few other miscellaneous pieces which will be usedful soon:
- Remove `Get` from func names `GetCookieSecret` and `GetFeeXPub`.
- Add helpers to encode/decode integers/bytes.
- Use bootstrap to improve layout.
- Add warning banners for webserver debug mode and vspd closed.
Admin page:
- Replace listing of all tickets with form to search by ticket hash