holepunch-hop 0.4.3 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "holepunch-hop",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "description": "data interface to HOP",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
package/src/bees.js CHANGED
@@ -115,6 +115,12 @@ class HyperBee extends EventEmitter {
115
115
  })
116
116
  await this.dbBentocues.ready()
117
117
  beePubkeys.push({store:'bentocues', privacy: 'public', pubkey: b4a.toString(core7.key, 'hex')})
118
+ // open the cues library
119
+ const discoveryCues = this.swarm.join(this.dbBentocues.discoveryKey)
120
+ // Only display the key once the Hyperbee has been announced to the DHT
121
+ discoveryCues.flushed().then(() => {
122
+ console.log('cues library open')
123
+ })
118
124
 
119
125
  const core13 = this.store.get({ name: 'bentomodels' })
120
126
  this.dbBentomodels = new Hyperbee(core13, {
@@ -884,9 +890,14 @@ class HyperBee extends EventEmitter {
884
890
  for await (const { key, value } of nodeData) {
885
891
  resData.push({ key, value })
886
892
  }
887
- this.repPublicHolder[dataIn.discoverykey] = resData
888
- // notify peer repliate complete, ask if want save
889
- this.emit('publib-replicate-notification', { data: { text: 'public library replication complete', publib: dataIn.discoverykey }})
893
+ // data received?
894
+ if (resData.length > 0) {
895
+ this.repPublicHolder[dataIn.discoverykey] = resData
896
+ // notify peer repliate complete, ask if want save
897
+ this.emit('publib-replicate-notification', { data: { text: 'public library replication complete', publib: dataIn.discoverykey }})
898
+ } else {
899
+ this.emit('publib-replicate-notification', { data: { text: 'no data received', publib: dataIn.discoverykey }})
900
+ }
890
901
  }
891
902
 
892
903
  /**
@@ -988,7 +999,7 @@ class HyperBee extends EventEmitter {
988
999
  saveRepliatePubLibary = async function (data) {
989
1000
  // add board nxp
990
1001
  let updatePubLib = this.repPublicHolder[data.discoverykey]
991
- if (data.library === 'publiclibrary') {
1002
+ if (data.library === 'public') {
992
1003
  await this.updatePublicLibrary(updatePubLib)
993
1004
  } else if (data.library === 'cues') {
994
1005
  await this.updateCuesLibrary(updatePubLib)
@@ -1039,7 +1050,7 @@ class HyperBee extends EventEmitter {
1039
1050
  */
1040
1051
  updateCuesLibrary = async function (libContracts) {
1041
1052
  // save entries required
1042
- const batch = this.dbPublicLibrary.batch()
1053
+ const batch = this.dbBentocues.batch()
1043
1054
  for (const { key, value } of libContracts) {
1044
1055
  await batch.put(key, JSON.parse(value))
1045
1056
  }
package/src/peers.js CHANGED
@@ -281,8 +281,6 @@ class NetworkPeers extends EventEmitter {
281
281
  } else if (dataShareIn.type === 'private-cue-space') {
282
282
  this.emit('cuespace-notification', { publickey: peerMatch, data: dataShareIn })
283
283
  } else if (dataShareIn.type === 'public-library') {
284
- console.log('public rep reque arrivee')
285
- console.log(dataShareIn)
286
284
  this.emit('publiclibrarynotification', { publickey: peerMatch, data: dataShareIn })
287
285
  } else if (dataShareIn.type === 'peer') {
288
286
  } else if (dataShareIn.type === 'peer-codename-inform') {