diff options
| author | fiatjaf <fiatjaf@gmail.com> | 2024-11-11 22:12:37 -0300 |
|---|---|---|
| committer | fiatjaf <fiatjaf@gmail.com> | 2026-02-04 19:22:23 -0300 |
| commit | bef08781af876345d761aef7c263593170862060 (patch) | |
| tree | 55d3b41c7bc2c6a08b56bcc09d400eb77772128e | |
| parent | f1ed55e8e9d861938670f34c7251713d3ebab235 (diff) | |
nip45: a mike dilger fix and a change inspired by a mike dilger fix.
| -rw-r--r-- | 45.md | 6 |
1 files changed, 3 insertions, 3 deletions
| @@ -43,11 +43,11 @@ This is so it enables merging results from multiple relays and yielding a reason | |||
| 43 | 43 | ||
| 44 | This section describes the steps a relay should take in order to return HLL values to clients. | 44 | This section describes the steps a relay should take in order to return HLL values to clients. |
| 45 | 45 | ||
| 46 | 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; | 46 | 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`; |
| 47 | 2. Initialize 256 registers to 0 for the HLL value; | 47 | 2. Initialize 256 registers to `0` for the HLL value; |
| 48 | 3. For all the events that are to be counted according to the filter, do this: | 48 | 3. For all the events that are to be counted according to the filter, do this: |
| 49 | 1. Read byte at position `offset` of the event `pubkey`, its value will be the register index `ri`; | 49 | 1. Read byte at position `offset` of the event `pubkey`, its value will be the register index `ri`; |
| 50 | 2. Count the number of leading zero bits starting at position `offset+1` of the event `pubkey`; | 50 | 2. Count the number of leading zero bits starting at position `offset+1` of the event `pubkey` and add `1`; |
| 51 | 3. Compare that with the value stored at register `ri`, if the new number is bigger, store it. | 51 | 3. Compare that with the value stored at register `ri`, if the new number is bigger, store it. |
| 52 | 52 | ||
| 53 | That is all that has to be done on the relay side, and therefore the only part needed for interoperability. | 53 | That is all that has to be done on the relay side, and therefore the only part needed for interoperability. |