Add vote account address to vote subscription
(cherry picked from commit 331b953551
)
# Conflicts:
# core/src/cluster_info_vote_listener.rs
# rpc/src/rpc_pubsub.rs
# rpc/src/rpc_subscriptions.rs
This commit is contained in:
@ -290,6 +290,8 @@ pub struct RpcIdentity {
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RpcVote {
|
||||
/// Vote account address, as base-58 encoded string
|
||||
pub vote_pubkey: String,
|
||||
pub slots: Vec<Slot>,
|
||||
pub hash: String,
|
||||
pub timestamp: Option<UnixTimestamp>,
|
||||
|
@ -684,7 +684,7 @@ impl ClusterInfoVoteListener {
|
||||
}
|
||||
|
||||
if is_new_vote {
|
||||
subscriptions.notify_vote(&vote);
|
||||
subscriptions.notify_vote(*vote_pubkey, &vote);
|
||||
let _ = verified_vote_sender.send((*vote_pubkey, vote.slots));
|
||||
}
|
||||
}
|
||||
|
@ -1315,12 +1315,12 @@ mod tests {
|
||||
hash: Hash::default(),
|
||||
timestamp: None,
|
||||
};
|
||||
subscriptions.notify_vote(&vote);
|
||||
subscriptions.notify_vote(Pubkey::default(), &vote);
|
||||
|
||||
let response = receiver.recv();
|
||||
assert_eq!(
|
||||
response,
|
||||
r#"{"jsonrpc":"2.0","method":"voteNotification","params":{"result":{"slots":[1,2],"hash":"11111111111111111111111111111111","timestamp":null},"subscription":0}}"#
|
||||
r#"{"jsonrpc":"2.0","method":"voteNotification","params":{"result":{"votePubkey":"11111111111111111111111111111111","slots":[1,2],"hash":"11111111111111111111111111111111","timestamp":null},"subscription":0}}"#
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ impl From<NotificationEntry> for TimestampedNotificationEntry {
|
||||
pub enum NotificationEntry {
|
||||
Slot(SlotInfo),
|
||||
SlotUpdate(SlotUpdate),
|
||||
Vote(Vote),
|
||||
Vote((Pubkey, Vote)),
|
||||
Root(Slot),
|
||||
Bank(CommitmentSlots),
|
||||
Gossip(Slot),
|
||||
@ -677,8 +677,8 @@ impl RpcSubscriptions {
|
||||
self.enqueue_notification(NotificationEntry::SignaturesReceived(slot_signatures));
|
||||
}
|
||||
|
||||
pub fn notify_vote(&self, vote: &Vote) {
|
||||
self.enqueue_notification(NotificationEntry::Vote(vote.clone()));
|
||||
pub fn notify_vote(&self, vote_pubkey: Pubkey, vote: &Vote) {
|
||||
self.enqueue_notification(NotificationEntry::Vote((vote_pubkey, vote.clone())));
|
||||
}
|
||||
|
||||
pub fn notify_roots(&self, mut rooted_slots: Vec<Slot>) {
|
||||
@ -760,8 +760,9 @@ impl RpcSubscriptions {
|
||||
// These notifications are only triggered by votes observed on gossip,
|
||||
// unlike `NotificationEntry::Gossip`, which also accounts for slots seen
|
||||
// in VoteState's from bank states built in ReplayStage.
|
||||
NotificationEntry::Vote(ref vote_info) => {
|
||||
NotificationEntry::Vote((vote_pubkey, ref vote_info)) => {
|
||||
let rpc_vote = RpcVote {
|
||||
vote_pubkey: vote_pubkey.to_string(),
|
||||
// TODO: Remove clones
|
||||
slots: vote_info.slots.clone(),
|
||||
hash: bs58::encode(vote_info.hash).into_string(),
|
||||
|
Reference in New Issue
Block a user