cfxcore/pos/protocol/message/
vote.rs1use crate::{
6 pos::{
7 consensus::network::ConsensusMsg,
8 protocol::sync_protocol::{Context, Handleable},
9 },
10 sync::Error,
11};
12use consensus_types::vote_msg::VoteMsg;
13use diem_logger::prelude::diem_debug;
14use std::mem::discriminant;
15
16impl Handleable for VoteMsg {
17 fn handle(self, ctx: &Context) -> Result<(), Error> {
18 diem_debug!("on_vote, msg={:?}", &self);
19
20 let peer_address = ctx.get_peer_account_address()?;
21
22 let author = self.vote().author();
29 let msg = ConsensusMsg::VoteMsg(Box::new(self));
30 ctx.manager
31 .consensus_network_task
32 .consensus_messages_tx
33 .push((author, discriminant(&msg)), (peer_address, msg))?;
34 Ok(())
35 }
36}