diff --git a/lib/feed-v1/index.js b/lib/feed-v1/index.js index 447f680..135a43b 100644 --- a/lib/feed-v1/index.js +++ b/lib/feed-v1/index.js @@ -70,33 +70,6 @@ function isEmptyObject(obj) { * @property {string} keys.private */ -/** - * @param {Msg} msg - */ -// function getFeedId(msg) { -// if (msg.metadata.type) { -// return `ppppp:feed/v1/${msg.metadata.who}/${msg.metadata.type}` -// } else { -// return `ppppp:feed/v1/${msg.metadata.who}` -// } -// } - -// function isMsg(x) { -// return ( -// typeof x === 'object' && -// !!x && -// typeof x.metadata.author === 'string' && -// x.metadata.author && -// typeof x.metadata.type === 'string' && -// x.metadata.type -// ) -// } - -// function isFeedId(author) { -// if (typeof author !== 'string') return false -// return author.startsWith('ppppp:feed/v1/') -// } - function isFeedRoot(msg, authorId, findType) { const findWho = stripAuthor(authorId) const { who, type, tangles } = msg.metadata @@ -231,9 +204,6 @@ module.exports = { getMsgId, isFeedRoot, getFeedRootHash, - // getFeedId, - // isFeedId, - // isMsg, create, createRoot, erase, diff --git a/lib/feed-v1/tangle.js b/lib/feed-v1/tangle.js index 18dd5bc..9e7f1e4 100644 --- a/lib/feed-v1/tangle.js +++ b/lib/feed-v1/tangle.js @@ -229,6 +229,16 @@ class Tangle { getMaxDepth() { return this.#maxDepth } + + debug() { + let str = '' + const max = this.#maxDepth + for (let i = 0; i <= max; i++) { + const atDepth = this.#getAllAtDepth(i) + str += `Depth ${i}: ${atDepth.join(', ')}\n` + } + return str + } } module.exports = Tangle diff --git a/lib/feed-v1/validation.js b/lib/feed-v1/validation.js index 2295b96..87ae79d 100644 --- a/lib/feed-v1/validation.js +++ b/lib/feed-v1/validation.js @@ -40,7 +40,6 @@ function validateWho(msg) { } catch (err) { return new Error('invalid message: must have "who" as base58 string') } - // FIXME: if there are prev, then `who` must match } function validateMsgHash(str) { @@ -199,8 +198,6 @@ function validateContent(msg) { } } -// FIXME: validateDepth should be +1 of the max of prev depth - function validate(msg, tangle, msgHash, rootHash) { let err if ((err = validateShape(msg))) return err @@ -214,22 +211,9 @@ function validate(msg, tangle, msgHash, rootHash) { if ((err = validateSignature(msg))) return err } -// function validateBatch(nativeMsgs, prevNativeMsg, hmacKey, cb) { -// let err -// let prev = prevNativeMsg -// for (const nativeMsg of nativeMsgs) { -// err = validateSync(nativeMsg, prev, hmacKey) -// if (err) return cb(err) -// prev = nativeMsg -// } -// cb() -// } - module.exports = { validateType, validateContent, - validate, validateMsgHash, - // validateBatch, }