cfxcore/pos/protocol/message/
epoch_change.rs

1// Copyright 2019-2020 Conflux Foundation. All rights reserved.
2// TreeGraph is free software and distributed under Apache License 2.0.
3// See https://www.apache.org/licenses/LICENSE-2.0
4
5use crate::{
6    pos::{
7        consensus::network::ConsensusMsg,
8        protocol::sync_protocol::{Context, Handleable},
9    },
10    sync::Error,
11};
12use diem_types::epoch_change::EpochChangeProof;
13use std::mem::discriminant;
14
15impl Handleable for EpochChangeProof {
16    fn handle(self, ctx: &Context) -> Result<(), Error> {
17        let peer_address = ctx.get_peer_account_address()?;
18        let msg = ConsensusMsg::EpochChangeProof(Box::new(self));
19        ctx.manager
20            .consensus_network_task
21            .consensus_messages_tx
22            .push((peer_address, discriminant(&msg)), (peer_address, msg))?;
23        Ok(())
24    }
25}