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.
OFF0 2023-01-17 09:11:04 +01:00
parent 4a68940681
commit 8ff1d2c1d8
Signed by: offbyn
GPG Key ID: 94A2F643C51F37FA
1 changed files with 6 additions and 1 deletions

View File

@ -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]) {