Add repository settings
parent: tbd commit: f8eaf38
1 | use Ordering; |
2 | |
3 | use Error; |
4 | use |
5 | HandshakeFinalize, HandshakeResponse, InitiateHandshake, |
6 | ; |
7 | use Version; |
8 | |
9 | use crate:: |
10 | , |
11 | version, |
12 | ; |
13 | |
14 | use ; |
15 | |
16 | pub async |
17 | message: &NetworkMessage, |
18 | state: &ConnectionState, |
19 | |
20 | if initiate_handshake |
21 | .handle_message |
22 | .await |
23 | .is_ok |
24 | |
25 | Ok |
26 | else if handshake_response |
27 | .handle_message |
28 | .await |
29 | .is_ok |
30 | |
31 | Ok |
32 | else if handshake_finalize |
33 | .handle_message |
34 | .await |
35 | .is_ok |
36 | |
37 | Ok |
38 | else |
39 | Err |
40 | |
41 | |
42 | |
43 | async |
44 | HandshakeMessage | : ,
45 | State | : ,
46 | |
47 | info!; |
48 | connection_state |
49 | .send |
50 | identity: connection_state.instance.clone, |
51 | version: version, |
52 | |
53 | .await |
54 | .map_err?; |
55 | |
56 | Ok |
57 | // if !validate_version(&initiation.version) { |
58 | // error!( |
59 | // "Version compatibility failure! Our Version: {}, Their Version: {}", |
60 | // Version::from_str(&std::env::var("CARGO_PKG_VERSION").unwrap()).unwrap(), |
61 | // initiation.version |
62 | // ); |
63 | |
64 | // connection_state |
65 | // .send(HandshakeFinalize { success: false }) |
66 | // .await |
67 | // .map_err(|e| HandshakeError::SendError(e))?; |
68 | |
69 | // Ok(()) |
70 | // } else { |
71 | // connection_state |
72 | // .send(HandshakeResponse { |
73 | // identity: connection_state.instance.clone(), |
74 | // version: version(), |
75 | // }) |
76 | // .await |
77 | // .map_err(|e| HandshakeError::SendError(e))?; |
78 | |
79 | // Ok(()) |
80 | // } |
81 | |
82 | |
83 | async |
84 | HandshakeMessage | : ,
85 | State | : ,
86 | |
87 | connection_state |
88 | .send |
89 | .await |
90 | .map_err?; |
91 | |
92 | Ok |
93 | // if !validate_version(&response.version) { |
94 | // error!( |
95 | // "Version compatibility failure! Our Version: {}, Their Version: {}", |
96 | // Version::from_str(&std::env::var("CARGO_PKG_VERSION").unwrap()).unwrap(), |
97 | // response.version |
98 | // ); |
99 | |
100 | // connection_state |
101 | // .send(HandshakeFinalize { success: false }) |
102 | // .await |
103 | // .map_err(|e| HandshakeError::SendError(e))?; |
104 | |
105 | // Ok(()) |
106 | // } else { |
107 | // connection_state |
108 | // .send(HandshakeFinalize { success: true }) |
109 | // .await |
110 | // .map_err(|e| HandshakeError::SendError(e))?; |
111 | |
112 | // Ok(()) |
113 | // } |
114 | |
115 | |
116 | async |
117 | HandshakeMessage | : ,
118 | State | : ,
119 | |
120 | connection_state.handshaked.store; |
121 | |
122 | connection_state |
123 | .send |
124 | .await |
125 | .map_err?; |
126 | |
127 | Ok |
128 | // if !finalize.success { |
129 | // error!("Error during handshake, aborting connection"); |
130 | // return Err(Error::from(ConnectionError::Shutdown).into()); |
131 | // } else { |
132 | // connection_state.handshaked.store(true, Ordering::SeqCst); |
133 | |
134 | // connection_state |
135 | // .send(HandshakeFinalize { success: true }) |
136 | // .await |
137 | // .map_err(|e| HandshakeError::SendError(e))?; |
138 | |
139 | // Ok(()) |
140 | // } |
141 | |
142 | |
143 | |
144 | |
145 | |
146 | VersionMismatch, |
147 | |
148 | SendError, |
149 | |
150 | Other, |
151 | |
152 |