Do not retry and wait, let GunSmith handle

This commit is contained in:
Daniel Lugo 2021-09-12 20:49:32 -04:00
parent 289fe1c918
commit 6ec931e1fa

View file

@ -2288,26 +2288,17 @@ module.exports = async (
epubForDecryption epubForDecryption
}) => { }) => {
const keys = path.split('>') const keys = path.split('>')
const { tryAndWait } = require('../services/gunDB/contact-api/utils') const { gun, user } = require('../services/gunDB/Mediator')
return tryAndWait((gun, user) => {
// eslint-disable-next-line no-nested-ternary // eslint-disable-next-line no-nested-ternary
let node = startFromUserGraph let node = startFromUserGraph
? user ? user
: publicKey : publicKey
? gun.user(publicKey) ? gun.user(publicKey)
: gun : gun
logger.info(`fetching: ${keys}`)
keys.forEach(key => (node = node.get(key))) keys.forEach(key => (node = node.get(key)))
logger.info(`fetching: ${keys}`)
if (!publicKeyForDecryption || !epubForDecryption) {
logger.warn('[GUN] Missing public key for decryption!', {
publicKeyForDecryption,
epubForDecryption
})
}
return new Promise((res, rej) => { return new Promise((res, rej) => {
try {
const listener = data => { const listener = data => {
logger.info(`got res for: ${keys}`) logger.info(`got res for: ${keys}`)
logger.info(data || 'falsey data (does not get logged)') logger.info(data || 'falsey data (does not get logged)')
@ -2326,10 +2317,6 @@ module.exports = async (
if (type === 'once') node.once(listener) if (type === 'once') node.once(listener)
if (type === 'load') node.load(listener) if (type === 'load') node.load(listener)
} catch (err) {
logger.error('Gun Fetch Error:', err)
}
})
}) })
} }