~ev/bogbookv3

b961be39855c585a3627a53e3eb06aea3ed4d7eb — Ev Bogue 10 days ago 53d51fe
ask pubs when we do not have something
2 files changed, 13 insertions(+), 3 deletions(-)

M replicate.js
M routes/query.js
M replicate.js => replicate.js +7 -0
@@ 60,13 60,18 @@ function replicate (ws) {
  }
}

let serverId = 0

export function connect (server) {
  const id = ++serverId

  console.log('Connecting to ' + server)
  const ws = new WebSocket(server)
  ws.binaryType = 'arraybuffer'

  ws.onopen = () => {
    //ws.send(keys.pubkey())
    peers.set(id, ws)
    replicate(ws)
  }
  


@@ 75,6 80,7 @@ export function connect (server) {
  }

  ws.onclose = (e) => {
    peers.delete(id)
    setTimeout(function () {
      connect(server)
    }, 1000)


@@ 85,6 91,7 @@ export function connect (server) {
  ws.onerror = (err) => {
    setTimeout(function () {
      ws.close()
      peers.delete(id)
      retryCount++
    }, 10000 * retryCount)
  }

M routes/query.js => routes/query.js +6 -3
@@ 6,6 6,7 @@ import { adder } from './../adder.js'
import { make } from './../inpfs.js'
import { publish, open } from './../sbog.js'
import { render } from './../render.js'
import { blast } from './../replicate.js'

function photoAdder (src, div) {
  const uploadButton = h('button', {onclick: function () {


@@ 71,9 72,11 @@ export function query (scroller, src) {
    header.appendChild(h('span', ['Search: ' + src.substring(1)]))
  }



  logs.query(src).then(log => {
    adder(log, src, scroller)
    if (log[0]) {
      adder(log, src, scroller)
    } else {
      blast(JSON.stringify({req: src, seq: -1}))
    }
  })  
}