-
Notifications
You must be signed in to change notification settings - Fork 1
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
rpcclient: add spentandmissedtickets notification #10
Conversation
ae255de
to
fd2db69
Compare
notification_generator!( | ||
"notify_spent_and_missed_tickets registers the client to receive notifications | ||
when blocks are connected to the main chain and tickets are spent or missed. | ||
The notifications are delivered to the notification handlers associated with the client. | ||
Calling this function has no effect if there are no notification handlers and will result in | ||
an error if the client is configured to run in HTTP POST mode. | ||
\nThe notifications delivered as a result of this call will be those from OnSpentAndMissedTickets. | ||
\n**NOTE: This is a dcrd extension and requires a websocket connection.**", | ||
notify_spent_and_missed_tickets, | ||
NotificationsFuture, | ||
commands::METHOD_NOTIFY_SPEND_AND_MISSED_TICKETS, | ||
&[], | ||
all_defined(on_spent_and_missed_tickets), | ||
() | ||
); |
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.
This is a macro that generates notification commands. It comprises of 7 parameter.
- Documentation of the notification command
- Function name (which here is notify_spent_and_missed_tickets)
- Future type (which normally is
NotificationsFuture
- Command type as a string
- Notification parameters, which are to be sent as an array of
serde values
- Notification handlers that must
all be defined (all of the provided handler must be defined)
oreither be defined (one of the handlers must be defined)
- Functions input parameter with their types.
@@ -490,3 +509,69 @@ pub(super) fn on_tx_accepted_verbose( | |||
|
|||
on_tx_verbose_callback(tx_details); | |||
} | |||
|
|||
pub(super) fn on_spent_and_missed_tickets( |
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.
On response from the server, the response parameters are treated appropriately.
commands::NOTIFICATION_METHOD_SPENT_AND_MISSING_TICKETS => { | ||
match notif.on_spent_and_missed_tickets { | ||
Some(e) => chain_notification::on_spent_and_missed_tickets(&msg.params, e), | ||
None => { | ||
warn!("on spent and missing tickets callback not registered."); | ||
continue; | ||
} | ||
} | ||
} |
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.
We pass the appropriate function OnNotification
No description provided.