Commit 4792f8c59a98c02045a1e6f1c7d9811d4abf18ef
validate peer objects as we go
Dominic Tarr committed on 10/9/2016, 8:46:53 PMParent: 0eaf39e541bcbdfaf1ec38d1b89438f9cf37fead
Files changed
modules_extra/network.js | changed |
modules_extra/network.js | ||
---|---|---|
@@ -31,20 +31,20 @@ | ||
31 | 31 … | |
32 | 32 … | //pub is running scuttlebot >=8 |
33 | 33 … | //have connected successfully. |
34 | 34 … | function isLongterm (e) { |
35 | - return e.ping && e.ping.rtt.mean > 0 | |
35 … | + return e.ping && e.ping.rtt && e.ping.rtt.mean > 0 | |
36 | 36 … | } |
37 | 37 … | |
38 | 38 … | //pub is running scuttlebot < 8 |
39 | 39 … | //have connected sucessfully |
40 | 40 … | function isLegacy (peer) { |
41 | - return /connect/.test(peer.state) || peer.duration.mean > 0 && !exports.isLongterm(peer) | |
41 … | + return /connect/.test(peer.state) || (peer.duration && peer.duration.mean > 0 && !isLongterm(peer)) | |
42 | 42 … | } |
43 | 43 … | |
44 | 44 … | //tried to connect, but failed. |
45 | 45 … | function isInactive (e) { |
46 | - return e.stateChange && e.duration.mean == 0 | |
46 … | + return e.stateChange && (e.duration && e.duration.mean == 0) | |
47 | 47 … | } |
48 | 48 … | |
49 | 49 … | //havn't tried to connect peer yet. |
50 | 50 … | function isUnattempted (e) { |
@@ -117,11 +117,11 @@ | ||
117 | 117 … | ' ', |
118 | 118 … | getType(peer), |
119 | 119 … | ' ', |
120 | 120 … | //TODO: show nicer details, with labels. etc. |
121 | - peer.ping ? duration(peer.ping.rtt.mean) : '', | |
121 … | + (peer.ping && peer.ping.rtt) ? duration(peer.ping.rtt.mean) : '', | |
122 | 122 … | ' ', |
123 | - peer.ping ? duration(peer.ping.skew.mean) : '', | |
123 … | + (peer.ping && peer.ping.skew) ? duration(peer.ping.skew.mean) : '', | |
124 | 124 … | h('label', |
125 | 125 … | {title: new Date(peer.stateChange).toString()}, |
126 | 126 … | peer.stateChange && ('(' + human(new Date(peer.stateChange))) + ')') |
127 | 127 … | ), |
@@ -145,21 +145,4 @@ | ||
145 | 145 … | return h('div.column.scroll-y', ol) |
146 | 146 … | |
147 | 147 … | } |
148 | 148 … | |
149 | - | |
150 | - | |
151 | - | |
152 | - | |
153 | - | |
154 | - | |
155 | - | |
156 | - | |
157 | - | |
158 | - | |
159 | - | |
160 | - | |
161 | - | |
162 | - | |
163 | - | |
164 | - | |
165 | - |
Built with git-ssb-web