rsd/net/
types.rs

1use std::net::SocketAddr;
2use std::time::SystemTime;
3
4//TODO I think tear down SocketAddr and store more raw
5pub struct PeerAddr {
6    address: SocketAddr,
7
8    //TODO make this a custom type.
9    services: u32,
10    //TODO check type on this.
11    time: SystemTime,
12    key: IdentityKey,
13}
14
15//I think this has to be a
16//33 byte array, but let's double check this.
17//Also I think we should base this off Buffer?
18//TODO new type called SetBuffer? Which has a preset length.
19pub struct IdentityKey([u8; 33]);
20
21pub enum Services {
22    Network,
23    Bloom,
24    FullNode,
25    RequiredServices,
26}
27
28//Service constants
29const NETWORK: u64 = (1 << 0);
30const BLOOM: u64 = (1 << 1);
31//I don't think the 0 is needed here, let's double check that.
32const FULL_NODE: u64 = 0 | NETWORK | BLOOM;
33const REQUIRED_SERVICES: u64 = 0 | NETWORK | BLOOM;
34
35impl Services {
36    pub fn value(&self) -> u64 {
37        match *self {
38            //1
39            Services::Network => NETWORK,
40            //2
41            Services::Bloom => BLOOM,
42            Services::FullNode => FULL_NODE,
43            Services::RequiredServices => REQUIRED_SERVICES,
44        }
45    }
46}