-
Notifications
You must be signed in to change notification settings - Fork 181
poll: Implement poll notifications in core #2804
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
poll: Implement poll notifications in core #2804
Conversation
37490f5
to
b8f99c3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements poll notifications by adding new command-line options for external commands, extending the poll registry to support notification types, and scheduling poll notifications to be executed on poll events and expiration warnings.
- Adds -pollnotify and -pollexpirewarningtime arguments in src/init.cpp.
- Introduces a new PollNotificationType enum and associated notification functions in src/gridcoin/voting/registry.
- Schedules poll notifications using a new NotifyPoll function in src/gridcoin/gridcoin.cpp.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
src/init.cpp | Added new arguments for poll notifications and expiration warnings. |
src/gridcoin/voting/registry.h | Introduced PollNotificationType enum and new notification methods. |
src/gridcoin/voting/registry.cpp | Implemented the notification functions and updated poll handling. |
src/gridcoin/gridcoin.h | Declared the NotifyPoll function. |
src/gridcoin/gridcoin.cpp | Scheduled poll notifications via the scheduler and defined NotifyPoll. |
Comments suppressed due to low confidence (1)
src/gridcoin/gridcoin.cpp:634
- [nitpick] Typo in variable name 'poll_registy'; consider renaming it to 'poll_registry' for clarity.
PollRegistry& poll_registy = GetPollRegistry();
This commit implements the ability to specify an external command to run via -pollnotify=<cmd> argument that takes two placeholders, %s1 and %s2, which are replaced with the poll txid and the notification status (added, deleted, or expiration_warning). The notifications are sent on all non-expired polls. Add/delete notifications are executed by the poll contract handlers. The expiration warning is handled by a scheduler function which checks every 5 minutes and does a single shot notification for polls that are within -pollexpirewarningtime=<hours> of expiration. This should be sufficient to drive an external script for notification via email or other desired approach.
e024f31
to
ff69c34
Compare
I mean it's kind of fine now since you implemented it but since the poll notify consumers already need to handle things like 1-block forks, you could've just passed the poll txid and left the extra machinery of type and expire to the consumer. |
I get where you are coming from; however, not every person using this will have a sophisticated state machine that tracks polls. Some are just enthusiasts running a command line wallet. On the expire warning, it is more efficient to implement an internal scheduler to check this rather than having someone either 1. creating a sophisticated external state machine to track poll expirations, and/or 2. poll the wallet to check. This allows the external script to be much simpler for most uses. The extra little bit of functionality wasn't that hard, anyway! :) |
c7e560c
to
421feab
Compare
421feab
to
227d317
Compare
Tested this. Both the test rpc and the expiration warning works. |
This implements a simple rpc command to test poll notification. It also makes changes to the poll_notify.sh script and a few other refinements.
c5c9973
to
5e379a8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested ACK 5e379a8689b0af90a1fb613e454ee744b7a9f75b
.
This PR implements the ability to specify an external command to run via -pollnotify=<cmd> argument that takes two placeholders, %s1 and %s2, which are replaced with the poll txid and the notification status (added, deleted, or expiration_warning).
The notifications are sent on all non-expired polls. Add/delete notifications are executed by the poll contract handlers. The expiration warning is handled by a scheduler function which checks every 5 minutes and does a single shot notification for polls that are within -pollexpirewarningtime=<hours> of expiration.
This should be sufficient to drive an external script for notification via email or other desired approach. The external script can call gridcoinresearchd getpollresults <poll txid> or listpolls to get the details of the poll.
This PR includes an example script, poll_notify.sh, to email the poll notification that can be found in the contrib directory.
Closes #2803 and gridcoin-community/Gridcoin-Tasks#255.