Skip to content

Commit

Permalink
bugfixes and bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
dskvr committed Jan 8, 2023
1 parent 694ab33 commit d29671e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nostr-relay-inspector",
"version": "0.0.18",
"version": "0.0.19",
"description": "js library for inspecting nostr relays",
"main": "index.js",
"type": "module",
Expand Down
32 changes: 16 additions & 16 deletions src/inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,23 +276,24 @@ Inspector.prototype.handle_event = function(subid, event) {

if(this.opts.debug)
console.log(this.relay.url, method)

if(this.result.count[type] > 1)
return

if(this.result.count[type] < 1) {
this.result.check[type] = true
this.log.push(['event', event])

if("latency" == type)
this.result.latency.final = Date.now() - this.result.latency.start
if(!this.result.check.read) //if there's latency, there's a read, force read to true
this.result.check.read = true
if("latency" == type)
this.result.latency.final = Date.now() - this.result.latency.start
if(!this.result.check.read) //if there's latency, there's a read, force read to true
this.result.check.read = true

this.try_complete()
this.try_complete()

setTimeout( () => {
clearTimeout(this.timeout[type])
if(this.opts.debug)
console.log(this.relay.url, 'cleared timeout', type, this.timeout[type])
}, config.millis.clearTimeoutBuffer)
}
setTimeout( () => {
clearTimeout(this.timeout[type])
if(this.opts.debug)
console.log(this.relay.url, 'cleared timeout', type, this.timeout[type])
}, config.millis.clearTimeoutBuffer)

this.result.count[type]++
}
Expand Down Expand Up @@ -383,8 +384,7 @@ Inspector.prototype.on_error = function(err) {
Inspector.prototype.on_event = function(subid, event) {
if(this.opts.debug)
console.log(this.relay.url, "on_event", subid)

this.log.push(['event', event])

this.handle_event(subid, event)

this.cbcall("event", subid, event, this.result)
Expand Down Expand Up @@ -468,6 +468,6 @@ Inspector.prototype.on = function(method, fn) {
Inspector.prototype.cbcall = function(method) {
[].shift.call(arguments,1)

if(typeof this.cb[method] === 'function')
if(this.cb[method] instanceof Function)
this.cb[method](...arguments)
}

0 comments on commit d29671e

Please sign in to comment.