465 Commits

Author SHA1 Message Date
jholdstock
030a4c6874 webapi: Display testnet/simnet in homepage banner.
Don't hardcode the banner to testnet because it is also displayed for
simnet.
2023-09-06 17:14:53 +01:00
jholdstock
939f094104 vspd: Stop scanning when ticket spender found.
Once the spender of a given ticket is found, the rest of the blocks
don't need to be checked.
2023-09-05 15:55:32 +01:00
jholdstock
2af3d4eca7 vspd: Fix OOB panic in spent ticket scanner.
Range expressions are only evaluated once before beginning a for loop,
which makes them unsuitable for loops which manually alter the index.
2023-09-05 15:55:32 +01:00
jholdstock
7d1b7deb01 multi: Remove GetBlockHeaderVerbose.
A slight performance improvement becase vspd can do everything it needs
without the verbose block header.
2023-09-04 16:51:27 +01:00
jholdstock
fb47e65ef3 webapi: Use GetBlockCount not GetBestBlockHeader.
GetBestBlockHeader is a more demanding RPC so using GetBlockCount offers
a slight performance improvement.
2023-09-04 16:51:27 +01:00
JoeGruff
61911a3f3b config: Add back simnet. 2023-09-04 16:51:17 +01:00
jholdstock
96b99f35d7 webapi: Add expired/missed to /vspinfo. 2023-09-04 16:51:09 +01:00
jholdstock
54e243526e multi: Display expired/missed tickets on webpage.
Revoked ticket count is replaced by separate counts for expired/missed
tickets.

/vspinfo API response remains unchanged.
2023-09-04 16:47:00 +01:00
jholdstock
fc1f7f2955 webapi: Fix revoked % calculation. 2023-09-04 16:47:00 +01:00
jholdstock
1dbcb785df webapi: Display testnet as a banner.
A banner notice is now displayed when a VSP is running on testnet
rather than including it in the row of statistics.
2023-09-04 16:47:00 +01:00
Jamie Holdstock
50c343e177
vspd: Use filter.MatchAny instead of filter.Match.
This brings a notable performance improvement to spent ticket scanning
without changing functionality. Can cut scanning time in half.
2023-09-04 16:46:24 +01:00
jholdstock
0c5016ae62 types: Add expired/missed to /vspinfo response.
Adding fields for expired/missed to /vspinfo response, deprecate
revoked.

This will need a minor version bump in the types module.
2023-08-31 09:18:03 +01:00
jholdstock
a52034cda7 multi: Update revoked tickets to expired/missed.
Any tickets in the database which are currently revoked should be
updated to either expired or missed.

This is achieved with a heuristic based on the expiry height and
revoke height of the tickets. It is not guaranteed to be 100% correct
but should be pretty close.

The web api is not yet updated to reflect this change, missed/expired
tickets will continue to be counted as revoked.
2023-08-29 10:12:30 +01:00
jholdstock
2fc60321e0 database: Return explicit nil instead of err.
No functional change because err is already checked and known to be nil,
but explicitly returning nil is easier/quicker to interpret when
reading.
2023-08-26 09:33:40 +01:00
jholdstock
9be203c923 multi: Find voted/revoked tickets with GCS filters
Use dcrd and GCS filters to find voted/revoked tickets rather than using
the dcrwallet TicketInfo RPC.

Using TicketInfo was a bit flakey because wallets do not always
correctly detect votes/revokes, and as a result VSP admins may notice
that with this change vspd detects some historic voted/revoked tickets
which TicketInfo never detected.
2023-08-26 09:33:30 +01:00
jholdstock
618cfc7cf1 vspd: Remove simnet params.
Simnet params were added in the very first commit of vspd purely because
of copy/pasting from another project.

vspd has never actually been tested on simnet, so its possible
(probable) that it won't even operate correctly without additional dev
work. If we want simnet to be a properly supported network it can be
re-added and tested in the future.
2023-08-26 09:33:30 +01:00
jholdstock
fe8e63a295 build: Use latest golangci-linter. 2023-08-24 07:52:40 +01:00
jholdstock
a4d21d7838 build: Add extra linters.
Some of these cover points which have recently been highlighted in
reviews, such as contexts contained in structs, slices initialized with
zero length, and periods missing from the end of comments.
2023-08-24 07:52:40 +01:00
jholdstock
5f81b0b40e database: Ensure comments end with period. 2023-08-24 07:52:40 +01:00
jholdstock
c052365be8 client: Use %w to wrap error correctly. 2023-08-24 07:52:40 +01:00
jholdstock
e80ebfea13 rpc: Do not store contexts in structs.
Documentation for the context package suggests that Contexts should
never be stored in structs.
2023-08-24 07:52:40 +01:00
jholdstock
49b9db1a64 rpc: Fix block connected handler.
Fix a bug where it appeared as though a notification handler was being
attached to the dcrd RPC client, but actually no notifications were
received until the client was disconnected a new one was created.

Now, rather than delaying attaching the notification handler, it is
attached immediately upon client creation and vspd does not start
handling the received notifications until it is ready.
2023-08-24 07:27:04 +01:00
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
b1fbced17c vspd: Move vspd code to its own file.
Moving all vspd code into its own vspd.go file (fka background.go). This
leaves main.go as a minimal entry point for the vspd executable.
2023-08-23 12:32:14 +01:00
jholdstock
4419ae3a6e vspd: Introduce vspd struct.
Storing all of the essential resources such as db, rpcs and logger in a
vspd struct enables vspd functions to be called without passing a bunch
of parameters unnecessarily. This will be increasingly useful later when
further changes are introduced.
2023-08-23 12:32:14 +01:00
jholdstock
c039dc86cb multi: Use const instead of var when possible. 2023-08-22 15:58:48 +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
010da298c4 rpc: Break out GetBlockHeaderVerbose func.
This makes the RPC reusable by other code in future.
2023-08-22 15:58:48 +01:00
jholdstock
bca2a32a30 database: Add TicketList struct.
This enables a func to find the earliest purchase height to be reused in
multiple packages.
2023-08-22 15:58:48 +01:00
jholdstock
8b50fe619a vspd: Simplify shutdown listener.
The existing signal.go was inherited directly from dcrwallet, and was
slightly more flexible/complicated than required for vspd. This brings
the code more inline with the dcrd implementation which can be
instantiated in one line and with only one parameter.
2023-08-22 15:10:03 +01:00
jholdstock
350a3f5bb2 vspd: Create context and waitgroup near usage.
Creating these closer to where they are needed tidies things up a bit,
and reduces the chance of them being used unnecessarily (as was being
done previously).
2023-08-21 08:33:54 +01:00
jholdstock
bd41dbee63 vspd: Listen for dcrd notifs after startup.
Only attach the dcrd notification listener after all other startup tasks
have been completed.

Attaching the listener before this can result in the notification
handler being invoked whilst startup tasks are still running, which
isn't necessarily a problem, but it is unnecessary and makes a mess of
logging.
2023-08-21 08:33:54 +01:00
jholdstock
2db761e072 client: Remove autoclient & bump to v3
Adding the autoclient to vspd created a circular dependency between vspd
and dcrwallet which is cumbersome and not worth the maintence burden.

At this point there are no known consumers of the vspd version of
autoclient, so removing it is not expected to cause problems for
anybody.

The autoclient will continue to live in the dcrwallet repo.
2023-08-18 14:32:37 +01:00
jholdstock
45addd2a18 build: Use go 1.21 & update GitHub actions. 2023-08-18 14:32:30 +01:00
jholdstock
0a38bd8152 multi: Replace interface{} with 'any' alias 2023-08-18 14:32:17 +01:00
jholdstock
820f130f59 webapi: Add test for securecookie error.
A simple test to ensure an error string returned by the securecookie lib
does not change when we upgrade to newer versions. Important because
vspd checks for this error using string comparison.
2023-08-18 14:31:26 +01:00
jholdstock
7a30e22d0a main: Update gitignore to only ignore executables.
A line such as "v3tool" is not specific enough as it does not only
ignore files named "v3tool", but also directories. This is problematic
when adding new files to the directory "/cmd/v3tool/".
2023-08-18 14:31:19 +01:00
jholdstock
de79ce74bb docs: Add 1.2.1 release note. 2023-07-05 09:07:20 +01:00
Jamie Holdstock
0272d713b6
docs: Move 1.2.0 release note to proper dir. (#400)
Not sure how this made it into the root dir, should have been with the rest of the docs.
2023-07-04 09:54:45 -05:00
Jamie Holdstock
d8bcc9292f rpc: Ignore another "duplicate tx" error.
sendrawtransaction is expected to fail if the transaction already exists in the mempool or a mined block. dcrd returns two different errors which can indicate this situation. Handling for one of them already existed, and this commit adds handling for the other.
2023-07-04 11:27:57 +01:00
jholdstock
a88c261cb1 webapi: Display decoded fee tx, not just raw bytes
When searching for a ticket in the admin interface, use GetRawTransaction RPC to get the decoded transaction and display it as formatted JSON.
2023-06-27 14:52:24 +01:00
jholdstock
4dc2cc4d8d webapi: Use raw whitespace to format JSON.
No need to manually construct HTML in this formatting func, it can simply deal with whitespace and then use <pre> tags to display.

Add some tests to validate behaviour.
2023-06-27 14:52:24 +01:00
jholdstock
78cf99bc2c webapi: Use input type "search" for ticket hash.
The "search" input type is functionally the same as "text" but has a nice extra property - most browsers will render it with a "Clear" button to wipe the current input.

Also disable spellchecking on this input.
2023-06-27 14:52:24 +01:00
Jamie Holdstock
ac973bd056
main: Update .gitignore
- Remove redundant duplication
- Add v3tool executable
- Add harness dir
2023-06-27 14:03:18 +01:00
jholdstock
fc0ed6b2c7 version: Bump to 1.3.0-pre 2023-06-15 08:32:58 +01:00
jholdstock
a06a62bfd0 docs: Add 1.2.0 release note. 2023-06-14 10:24:48 +01:00
Jamie Holdstock
f46ffcb60d
docs: Review and polish existing docs. (#390)
Also includes a couple of updates to comments in webapi code.
2023-06-13 13:22:57 -05:00
jholdstock
43a1b9fbdc build: Update transitive deps. 2023-06-13 09:32:14 +01:00
jholdstock
85ebeefafa build: Use tagged dcrwallet v3 2023-06-13 09:32:14 +01:00
jholdstock
9863636978 webapi: Update to gin 1.9.1. 2023-06-13 08:48:56 +01:00