Add vote account address to vote subscription
This commit is contained in:
parent
9d477d45c7
commit
331b953551
|
@ -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>,
|
||||
|
|
|
@ -688,7 +688,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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1316,12 +1316,12 @@ mod tests {
|
|||
hash: Hash::default(),
|
||||
timestamp: None,
|
||||
};
|
||||
subscriptions.notify_vote(VoteTransaction::from(vote));
|
||||
subscriptions.notify_vote(Pubkey::default(), VoteTransaction::from(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(VoteTransaction),
|
||||
Vote((Pubkey, VoteTransaction)),
|
||||
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: VoteTransaction) {
|
||||
self.enqueue_notification(NotificationEntry::Vote(vote));
|
||||
pub fn notify_vote(&self, vote_pubkey: Pubkey, vote: VoteTransaction) {
|
||||
self.enqueue_notification(NotificationEntry::Vote((vote_pubkey, vote)));
|
||||
}
|
||||
|
||||
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(),
|
||||
slots: vote_info.slots(),
|
||||
hash: bs58::encode(vote_info.hash()).into_string(),
|
||||
timestamp: vote_info.timestamp(),
|
||||
|
|
Loading…
Reference in New Issue