From 8ff1d2c1d8a1537cd204694c4ba737a26b78ef98 Mon Sep 17 00:00:00 2001 From: OFF0 Date: Tue, 17 Jan 2023 09:11:04 +0100 Subject: [PATCH] nip-13: check zero leading bits before it was only testing if the nonce commitment is high enough but didn't verify leading zero bits. with this change rendering checks now the leading zero bits count of the event id. --- src/main.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main.js b/src/main.js index cf7a66e..4806af8 100644 --- a/src/main.js +++ b/src/main.js @@ -328,7 +328,12 @@ function renderFeed() { const sortedFeeds = textNoteList // dont render notes from the future .filter(note => note.created_at < now) - .filter(note => !fitlerDifficulty || note.tags.some(([tag, , commitment]) => tag === 'nonce' && commitment >= fitlerDifficulty)) + // if difficulty filter is configured dont render notes with too little pow + .filter(note => { + return !fitlerDifficulty || note.tags.some(([tag, , commitment]) => { + return tag === 'nonce' && commitment >= fitlerDifficulty && zeroLeadingBitsCount(note.id) >= fitlerDifficulty; + }); + }) .sort(sortByCreatedAt).reverse(); sortedFeeds.forEach((evt, i) => { if (feedDomMap[evt.id]) {