cfxcore/pos/protocol/message/
proposal.rs1use crate::{
6 pos::{
7 consensus::network::ConsensusMsg,
8 protocol::sync_protocol::{Context, Handleable},
9 },
10 sync::Error,
11};
12
13use consensus_types::proposal_msg::ProposalMsg;
14use diem_logger::prelude::diem_debug;
15use std::mem::discriminant;
16
17impl Handleable for ProposalMsg {
18 fn handle(self, ctx: &Context) -> Result<(), Error> {
19 diem_debug!("on_proposal, msg={:?}", &self);
20
21 let peer_address = ctx.get_peer_account_address()?;
22
23 let author = self.proposer();
29 let msg = ConsensusMsg::ProposalMsg(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}