From 3cdfe3039eb56616657a55ca46701b1ffbf2025d Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Mon, 11 Nov 2024 22:12:37 -0300 Subject: [PATCH] nip45: a mike dilger fix and a change inspired by a mike dilger fix. --- 45.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/45.md b/45.md index a5ce02db..d2af7c26 100644 --- a/45.md +++ b/45.md @@ -43,11 +43,11 @@ This is so it enables merging results from multiple relays and yielding a reason This section describes the steps a relay should take in order to return HLL values to clients. -1. Upon receiving a filter, if it has a single `#e`, `#p`, `#a` or `#q` item, read its 32th ascii character as a byte and take its modulo over 24 to obtain an `offset` -- in the unlikely case that the filter doesn't meet these conditions, set `offset` to the number 16; -2. Initialize 256 registers to 0 for the HLL value; +1. Upon receiving a filter, if it has a single `#e`, `#p`, `#a` or `#q` item, read its 32th ascii character as a nibble (a half-byte, a number between 0 and 16) and add `8` to it to obtain an `offset` -- in the unlikely case that the filter doesn't meet these conditions, set `offset` to the number `16`; +2. Initialize 256 registers to `0` for the HLL value; 3. For all the events that are to be counted according to the filter, do this: 1. Read byte at position `offset` of the event `pubkey`, its value will be the register index `ri`; - 2. Count the number of leading zero bits starting at position `offset+1` of the event `pubkey`; + 2. Count the number of leading zero bits starting at position `offset+1` of the event `pubkey` and add `1`; 3. Compare that with the value stored at register `ri`, if the new number is bigger, store it. That is all that has to be done on the relay side, and therefore the only part needed for interoperability.