git ssb

16+

Dominic / patchbay



Commit 4792f8c59a98c02045a1e6f1c7d9811d4abf18ef

validate peer objects as we go

Dominic Tarr committed on 10/9/2016, 8:46:53 PM
Parent: 0eaf39e541bcbdfaf1ec38d1b89438f9cf37fead

Files changed

modules_extra/network.jschanged
modules_extra/network.jsView
@@ -31,20 +31,20 @@
3131
3232 //pub is running scuttlebot >=8
3333 //have connected successfully.
3434 function isLongterm (e) {
35- return e.ping && e.ping.rtt.mean > 0
35 + return e.ping && e.ping.rtt && e.ping.rtt.mean > 0
3636 }
3737
3838 //pub is running scuttlebot < 8
3939 //have connected sucessfully
4040 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))
4242 }
4343
4444 //tried to connect, but failed.
4545 function isInactive (e) {
46- return e.stateChange && e.duration.mean == 0
46 + return e.stateChange && (e.duration && e.duration.mean == 0)
4747 }
4848
4949 //havn't tried to connect peer yet.
5050 function isUnattempted (e) {
@@ -117,11 +117,11 @@
117117 ' ',
118118 getType(peer),
119119 ' ',
120120 //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) : '',
122122 ' ',
123- peer.ping ? duration(peer.ping.skew.mean) : '',
123 + (peer.ping && peer.ping.skew) ? duration(peer.ping.skew.mean) : '',
124124 h('label',
125125 {title: new Date(peer.stateChange).toString()},
126126 peer.stateChange && ('(' + human(new Date(peer.stateChange))) + ')')
127127 ),
@@ -145,21 +145,4 @@
145145 return h('div.column.scroll-y', ol)
146146
147147 }
148148
149-
150-
151-
152-
153-
154-
155-
156-
157-
158-
159-
160-
161-
162-
163-
164-
165-

Built with git-ssb-web