arc-malachitebft-peer 0.7.0-pre

Peer definition for the Malachite BFT consensus engine
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use {crate::PeerId, alloc::vec::Vec};

impl borsh::BorshSerialize for PeerId {
    fn serialize<W: borsh::io::Write>(&self, writer: &mut W) -> borsh::io::Result<()> {
        self.multihash.to_bytes().serialize(writer)
    }
}

impl borsh::BorshDeserialize for PeerId {
    fn deserialize_reader<R: borsh::io::Read>(reader: &mut R) -> borsh::io::Result<Self> {
        let bytes = Vec::<u8>::deserialize_reader(reader)?;
        PeerId::from_bytes(&bytes)
            .map_err(|e| borsh::io::Error::new(borsh::io::ErrorKind::InvalidData, e))
    }
}