diff --git a/index.js b/index.js index 46ed432..501eb3f 100644 --- a/index.js +++ b/index.js @@ -401,7 +401,7 @@ class CableCore extends EventEmitter { // gets the local user's most recently set nickname getNick(cb) { - this.store.userInfoView.api.getLatestNameHash(this.kp.publicKey, (err, hash) => { + this.store.userInfoView.api.getLatestInfoHash(this.kp.publicKey, (err, hash) => { if (err) { return cb(err) } this.resolveHashes([hash], (err, results) => { if (err) { return cb(err) } @@ -444,7 +444,7 @@ class CableCore extends EventEmitter { const hex = util.hex(publicKey) users.set(hex, hex) }) - this.store.userInfoView.api.getLatestNameHashesAllUsers((err, latestNameHashes) => { + this.store.userInfoView.api.getLatestInfoHashAllUsers((err, latestNameHashes) => { if (err) return cb(err) this.resolveHashes(latestNameHashes, (err, posts) => { // TODO (2023-09-06): handle post/info deletion and storing null? @@ -532,7 +532,7 @@ class CableCore extends EventEmitter { this.store.channelMembershipView.api.getHistoricUsers(channel, (err, pubkeys) => { // get the latest nickname for each user that has been a member of channel const namePromise = new Promise((res, reject) => { - this.store.userInfoView.api.getLatestNameHashMany(pubkeys, (err, nameHashes) => { + this.store.userInfoView.api.getLatestInfoHashMany(pubkeys, (err, nameHashes) => { if (err) return reject(err) res(nameHashes) }) diff --git a/store.js b/store.js index 3d83411..a8a7a36 100644 --- a/store.js +++ b/store.js @@ -393,11 +393,11 @@ class CableStore extends EventEmitter { } _reindexInfoName (channel, publicKey, sendHash, done) { - this.channelStateView.api.getLatestNameHash(channel, publicKey, (err, hash) => { + this.channelStateView.api.getLatestInfoHash(channel, publicKey, (err, hash) => { storedebug("latest name err", err) storedebug("latest name hash", hash) if (err && err.notFound) { - this.userInfoView.api.clearName(publicKey) + this.userInfoView.api.clearInfo(publicKey) sendHash(null) return done() } diff --git a/views/channel-state.js b/views/channel-state.js index e46344d..13eb402 100644 --- a/views/channel-state.js +++ b/views/channel-state.js @@ -143,11 +143,11 @@ module.exports = function (lvl, reverseIndex) { cb(null, hashes) }) }, - // TODO (2023-04-20): remove this file's getLatestNameHash function when user-info.js has a latestNameHash operating without latest key - getLatestNameHash: function (channel, publicKey, cb) { + // TODO (2023-04-20): remove this file's getLatestInfoHash function when user-info.js has a latestNameHash operating without latest key + getLatestInfoHash: function (channel, publicKey, cb) { // return latest post/info hash for pubkey ready(async function () { - debug("api.getLatestNameHash") + debug("api.getLatestInfoHash") const iter = lvl.values({ lt: `name!${channel}!${util.timestamp()}!${util.hex(publicKey)}`, gt: "name!!", diff --git a/views/user-info.js b/views/user-info.js index c35c9af..ffe2a93 100644 --- a/views/user-info.js +++ b/views/user-info.js @@ -14,7 +14,6 @@ function noop () {} // takes a (sub)level instance module.exports = function (lvl, reverseIndex) { const events = new EventEmitter() - // callback processing queue. functions are pushed onto the queue if they are dispatched before the store is ready or // there are pending transactions in the pipeline let queue = [] @@ -96,8 +95,8 @@ module.exports = function (lvl, reverseIndex) { }, api: { - // return latest post/info name-setting hash for all recorded pubkeys - getLatestNameHashesAllUsers: function (cb) { + // return latest post/info hash for all recorded pubkeys + getLatestInfoHashAllUsers: function (cb) { ready(async function () { debug("api.getUsers") const iter = lvl.values({ @@ -109,11 +108,11 @@ module.exports = function (lvl, reverseIndex) { cb(null, hashes) }) }, - // return latest post/info name-setting hash for specified publicKey - getLatestNameHash: function (publicKey, cb) { + // return latest post/info hash for specified publicKey + getLatestInfoHash: function (publicKey, cb) { ready(function () { // TODO (2023-03-07): consider converting to using a range query with limit: 1 instead - debug("api.getLatestNameHash") + debug("api.getLatestInfoHash") lvl.get(`latest!${util.hex(publicKey)}`, (err, hash) => { if (err) { return cb(err, null) } return cb(null, hash) @@ -121,10 +120,10 @@ module.exports = function (lvl, reverseIndex) { }) }, // this function is needed to fulfilling channel state requests, in terms of getting the latest name hashes - getLatestNameHashMany: function (pubkeys, cb) { + getLatestInfoHashMany: function (pubkeys, cb) { // return latest post/info hash for many pubkeys ready(function () { - debug("api.getLatestNameHashMany") + debug("api.getLatestInfoHashMany") const keys = pubkeys.map(publicKey => { return `latest!${util.hex(publicKey)}` }) @@ -138,11 +137,11 @@ module.exports = function (lvl, reverseIndex) { }) }) }, - clearName: function (publicKey, cb) { + clearInfo: function (publicKey, cb) { if (!cb) { cb = noop } // remove the name record for this public key ready(function () { - debug("api.clearNameHash") + debug("api.clearInfoHash") lvl.del(`latest!${util.hex(publicKey)}`, (err) => { if (err) { return cb(er) } return cb(null)