mirror of
https://github.com/nostr-protocol/nips.git
synced 2024-11-14 07:49:07 -05:00
nip45: a mike dilger fix and a change inspired by a mike dilger fix.
This commit is contained in:
parent
d6d3650978
commit
3cdfe3039e
6
45.md
6
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.
|
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;
|
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;
|
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:
|
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`;
|
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.
|
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.
|
That is all that has to be done on the relay side, and therefore the only part needed for interoperability.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user