44 Commits

Author SHA1 Message Date
jholdstock
bac0dcef71 multi: Hoist database integrity checks up to vspd.
Moving the existing integrity checks up into vspd removes the
depdendancy on rpc clients from the database client, and also creates a
natural home for future integrity checks to be added.
2023-08-23 12:48:19 +01:00
jholdstock
3ddad3eeb5 database: Try get purchase height for all tickets.
Only fatal errors should result in data integrity checks being stopped.
If a single ticket encounters an error, that error should be logged and
other tickets should still be attempted.
2023-08-22 15:58:48 +01:00
jholdstock
32790984fe Make database backups optional.
Periodic database backups are no longer started automatically in database.Open(), and the backup written by database.Close() can now be disabled.

Only vspd itself requires backups, they are not useful for test code or future upcoming tools such as vote-validator.
2022-09-29 14:54:40 +01:00
jholdstock
65fab01225 Remove remaining global loggers.
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.
2022-06-29 08:31:44 +01:00
jholdstock
1db99bfddf db.Close() if an error occurs in db.Open(). 2022-05-19 07:59:44 +01:00
jholdstock
75026f5e91 Clean up use of shutdown context.
- 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.
2022-05-19 07:59:44 +01:00
jholdstock
d4b3d2fafb Make writeHotBackupFile a method of VspDatabase.
No reason for this to be a standalone func with a param when it can be a method of VspDatabase. This will be useful later when VspDatabase contains its own logger.
2022-05-19 07:59:44 +01:00
Jamie Holdstock
78bb28056c
Remove global cache variable. (#341)
* 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`.
2022-03-30 11:00:42 -05:00
jholdstock
c91ec5c697 Use time.After instead of tickers. 2022-03-28 16:37:25 +01:00
jholdstock
fba9fe5b0a Move database encoding helpers. 2022-03-28 16:37:25 +01:00
jholdstock
ab5aa4dd6d Clarify "setaltsig" terminology.
Stardardize "alt sig"/"alt signature"/"alt signing address" terminology to "alternate signing address".
2021-11-16 14:49:13 +00:00
jholdstock
6acc5be10c Add dcrd to VSP status.
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.
2021-11-16 14:33:39 +00:00
JoeGruff
6e13d23214 db/ticket: Add AltSigAddress.
To allow signing with addresses other than the commitment address, add
an alternate signature address. In order to continue to prove that the
address was chosen by the user, add an alternate signature history. Only
allow one record per ticket to be saved to cap needed db space.
2021-10-23 11:14:11 +01:00
Jamie Holdstock
74d32c5f09 Ensure PurchaseHeight is set for all tickets.
This is necessary because of an old bug which, in some circumstances, would prevent purchase height from being stored.
2021-06-25 15:56:35 +08:00
Jamie Holdstock
4db50a4439 Helpers for bool<>[]byte conversion. 2021-06-09 21:25:21 +08:00
Jamie Holdstock
e05ced391a Various minor cleanups.
- Updating and adding some copyrights which were missed recently.
- Slight improvements to some commenting and naming.
2021-06-01 07:17:11 +08:00
Jamie Holdstock
20cb546e74
Store each ticket in its own DB bucket.
**NOTE: This contains a backwards incompatible database migration, so if you plan to test it, please make a copy of your database first.**

Moves tickets from a single database bucket containing JSON encoded strings, to a bucket for each ticket.

This change is to preemptively deal with scaling issues seen with databases containing tens of thousands of tickets.
2021-05-24 17:45:47 +08:00
Jamie Holdstock
2d0db6f6b3 Remove confirmed fee tx hex.
This PR introduces a database migration which deletes any raw fee transactions which remain in the database after already having been confirmed on-chain. There is no need to keep these, and they take up a lot of space.

There is also a change in the background handler to ensure that in future, tx hex is always removed from the database when the tx is confirmed.
2021-05-20 13:33:41 +08:00
Jamie Holdstock
5f8ad656f7
Add framework for database upgrades. (#242)
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.
2021-05-05 08:54:51 -05:00
David Hill
2a096d81f9
fix errorlint warnings (#193) 2020-11-25 15:14:18 +00:00
jholdstock
825a717ca7 Store records of vote choice changes 2020-09-17 16:05:07 +00:00
jholdstock
4a207b15f8 Add missing copyright notices 2020-08-19 20:22:12 +00:00
jholdstock
e2483b6cea Fix backup file mode 2020-08-17 19:14:57 +00:00
jholdstock
6c12ddeb31 Write a backup after closing the db, not before 2020-08-17 19:14:57 +00:00
jholdstock
ba77d39f35 Comment exported methods 2020-08-07 17:03:03 +00:00
David Hill
4f0c980aca
database: protect access with a mutex (#150) 2020-07-06 10:06:43 +01:00
jholdstock
5a1a1b487e Dont use byte slices outside of db tx. 2020-06-16 13:29:32 +00:00
Jamie Holdstock
bfeddd25d1 Download db backup from admin page. 2020-06-12 13:35:43 +00:00
jholdstock
a304fc9890 Close the database after web server is stopped.
Previously all of the shutdown tasks were running concurrently, which meant the db could be closed before the webserver is finished using it.
2020-06-12 13:23:55 +00:00
jholdstock
b50615bc6f Add very basic admin page. 2020-06-08 15:24:49 +00:00
jholdstock
c7835e8811 Update log level and add some TODOs 2020-06-04 15:04:39 +00:00
Jamie Holdstock
d407af35c0
Accept feexpub once at startup. (#97) 2020-06-03 18:10:30 +01:00
jholdstock
81a6bf1ea8 Reject unvotable tickets.
/payfee and /getaddress will now only accept tickets which are immature or live.
2020-06-03 12:49:14 +00:00
Jamie Holdstock
6b6bc20522
Periodically write a database backup. (#76) 2020-05-28 06:58:34 +01:00
Jamie Holdstock
9151f4f221
Generate fee addresses in dcrvsp, not dcrwallet (#59)
* Remove unnecessary error handling.

* Generate fee addresses in dcrvsp, not dcrwallet

* Break loop if multiple invalid children are generated.

* Use Mutex instead of RWMutex
2020-05-26 14:51:05 +01:00
Jamie Holdstock
1ff55f4b30
Add some stats to homepage (#51) 2020-05-22 18:43:41 +01:00
David Hill
fff8132b13
Store signing key in db. (#34) 2020-05-19 14:24:02 +01:00
Jamie Holdstock
6ca2f620b7
Use a waitgroup to wait for shutdown tasks (#21) 2020-05-18 09:05:10 +01:00
Jamie Holdstock
8768014348
Add shutdown context. (#20) 2020-05-17 07:49:53 +01:00
Jamie Holdstock
57dfc1ed6d
Add decred logging and config (#8) 2020-05-14 19:02:45 +01:00
Jamie Holdstock
d0236e5c04
Implement ticket storage and retrieval (#5) 2020-05-14 14:04:14 +01:00
Jamie Holdstock
b45bbf8896
Enable CI through GitHub Actions (#4) 2020-05-14 13:53:48 +01:00
jholdstock
fcd068deb3 Rename Fees => Tickets 2020-05-13 21:48:59 +01:00
jholdstock
f919d4d8fc Add missing db stubs and begin db implementation 2020-05-13 21:25:35 +01:00